1

I am trying to write a PCA function in MATLAB. I know that there is the function princomp, I just wanted to understand the process for myself. One problem I've encountered is that the eig matrix calculation on the covariance matrix is incorrect. I have this covariance matrix:

matCov =

0.6166    0.6154
0.6154    0.7166

And when I call the eig function, I get:

eVec =

-0.7352    0.6779
 0.6779    0.7352

Whereas, with the function princomp I get:

eVec =

-0.7352    -0.6779
 0.6779    -0.7352

I know that it's the same, but each time I calculate the eigenvectors matrix (ordered by decreasing variance values) using the princomp function and the eigfunction, the last column of the eigVectors matrix are different. Can anyone explain this?

amoeba
  • 104,745
  • The sign of the principal component / eigenvector does not matter, it is arbitrary. There is nothing "false" in your example. Pca() and eig() functions uses different algorithms, so no wonder that they converge to solutions that can differ in sign. – amoeba Mar 10 '14 at 14:52

0 Answers0