# prcomp function

3 messages
Open this post in threaded view
|

## prcomp function

 Hello, I have a short question about the prcomp function. First I cite the associated help page (help(prcomp)): "Value: ... 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 loadings. ..." Now please take a look at the following easy example: first I  define a matrix A >A<-matrix(c(0,1,4,1,0,3,4,3,0),3,3) then I apply PCA on A >trans<-prcomp(A,retx=T,center=F,scale.=F,tol=NULL) >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) ew[1]*ev[,1]=t(-8.695427,-7.129314,-10.194816) 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.