Skip to content

PCA functions

2 messages · S Ellison, Gavin Simpson

#
princomp uses the raw data and calculates the correlation or covariance matrix on the way to the PC's, so that doesn't use a correlation matrix itself. You do, however, get the choice.

However, PC's are the eigenvectors of the correlation (or covariance) matrix, so in principle calling eigen() on either would be sufficient for the PC's. The signs may differ, though, as they are arbitrary; compare prcomp(USArrests)$rotation with eigen(cov(USArrests)).

S
"glenn" <g1enn.roberts at btinternet.com> writes:
Yes, there is: princomp(). :-)
#
On Mon, 2009-02-16 at 10:45 +0000, S Ellison wrote:
That *isn't* what princomp() does. If you supply a valid covariance
matrix via argument 'covmat', princomp() uses that instead of
calculating one from the input data.

That is what ?princomp says it does, as does the R source, the true
reference.

G