Specifics on using PCA via SVD ... use data matrix or covariance matrix of data matrix

452 Views Asked by At

So I want to clarify something: if I want to use SVD to compute PCA of matrix X, do I need to use the SVD on $X$ or $X^TX$. If the former, do I need to square the eigenvalues returned by the SVD? If the latter do I need to take the square root of the eigenvalues by SVD?

1

There are 1 best solutions below

2
On

You should use the SVD of $X$. The principal components are the right singular vectors of $X$.

What may have led to the confusion is this: the singular values are the square roots of the eigenvalues of $\Sigma\triangleq X^TX$, the sample covariance matrix of $X$. The right singular vectors of $X$ are the same as the eigenvectors of $X^TX$.

Frankly, the Wikipedia article is not bad here.