I have been testing the princomp() function in MATLAB:


As part of the answer given there they pointed me to a this thread:

What is the intuitive relationship between SVD and PCA

This contains a link to a tutorial on PCA (which is wonderful!) included in the tutorial is MATLAB code to calculate PCA's based on eigen-vectors and SVD. The answers produced by the three functions are consistent except for the fact that the Principal components for the SVD method in the tutorial is the negative of the eigen-vector based answer? Princomp() also uses SVD to compute its answer but then alters the principal componets to ensure that the largest element in each column is positive. After this seemingly rather ad-hock adjustment the result from Princomp() matches the one from the eigen-vector based approach exactly. Prior to this change Princomp() matches the results from the SVD based method exactly.

It just strikes me as odd that such adjustments are necessary!

1.) why do the eigenvalue and SVD based methods not match without this adjustment?

2.) More generally when should I always ensure that the largest element in each column has positive sign?

3.) Is there a mathematical reason for doing so? Or is it simply convention?

  • $\begingroup$ If $u$ is a normalized eigenvector of a matrix, then so is $-u$ (with the same eigenvalue). There's no mathematical reason to prefer one to the other; it depends on the application. $\endgroup$ – mjqxxxx Oct 30 '13 at 16:50
  • $\begingroup$ Thanks, I understand that the answers are equivalent (but did not make that clear in the question), but still strikes me as slightly odd that the two methods produce different answers when calculated from the same data set? $\endgroup$ – Bazman Oct 30 '13 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.