# PCA in MultivariateStats

**URL:** <https://discourse.julialang.org/t/pca-in-multivariatestats/307>\
**Category:** Statistics\
**Created:** [November 14, 2016, 10:05pm UTC](https://discourse.julialang.org/t/pca-in-multivariatestats/307 "2016-11-14T22:05:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jianghaizhu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jianghaizhu/32/1866_2.png) [@jianghaizhu](https://discourse.julialang.org/u/jianghaizhu)\
**Post date:** [November 14, 2016, 10:05pm UTC](https://discourse.julialang.org/t/pca-in-multivariatestats/307/1 "2016-11-14T22:05:12Z")

</div>

I am using **PCA** in **MultivariateStats** and trying to covert an old Matlab script to Julia. I am dealing with a serials of images. First I want to make sure I got the matrix right. I reshaped each image to a vector and put n images to a `m x n` matrix. I think the format of this data is correct, same as Matlab. Then I generated a pca model by `M = fit(PCA, data)`. Matlab would return `[coeff,score,latent]`. I believe that `M.prinvars` is `latent` in Matlab and `M.proj` is `score` in Matlab. Using `transform(M, data)` I will get the transpose of `coeff` in Matlab. To reconstruct the images, I use `score*coeff'` in Matlab. In Julia, I use `reconstruct(M, coeff)`. Am I doing this right?
