[R] prcomp function

kicker dreamcatcher101 at web.de
Wed Nov 10 14:41:03 CET 2010


I have a short question about the prcomp function. First I cite the
associated help page (help(prcomp)):

SDEV the standard deviations of the principal components (i.e., the square
roots of the eigenvalues of the covariance/correlation matrix, though the
calculation is actually done with the singular values of the data matrix). 
ROTATION the matrix of variable loadings (i.e., a matrix whose columns
contain the eigenvectors). The function princomp returns this in the element

Now please take a look at the following easy example:

first I  define a matrix A
then I apply PCA on A

>eval<-trans$sdev*trans$sdev #eval is the vector of the eigenvalues of
cov(A) (according to the cited help text above)
>evec<-trans$rotation #evec is the matrix with the eigenvectors of cov(A) as
columns  (according to the cited help text above)

now the eigenvalue equation should be valid, i.e. it should hold
cov(A)%*%ev[,1]=ew[1]*ev[,1]. But it doesn´t, my result:
cov(A)%*%ev[,1]= t(-0.8244927, -0.8325664,0.8244927)

So my question is : why does the eigenvalue equation not hold ? 

The eigenvalue equation holds when I set center=T in the options of the
prcomp function. But as far as I know and as I understand the help text it
should have no influence on the eigenvalue equation whether the data are
centered or not. I know about the advantages of centered date but I want to
understand how the prcomp function works in the case of uncentered data.

Thank you very much for your efforts.

View this message in context: http://r.789695.n4.nabble.com/prcomp-function-tp3036088p3036088.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list