[R] Confused by SVD and Eigenvector Decomposition in PCA

Stephane Dray dray at biomserv.univ-lyon1.fr
Sat Feb 8 10:28:08 CET 2003


At 21:16 07/02/2003 -0600, Feng Zhang wrote:
>I used Matlab to do this case study.
> >x = randn(200,3); %%generating a 200x3 Gaussian matrix
> >[a,b,c]=svd(x); %%SVD composition
> >S=diag(b)
>   S =[15.6765   14.8674   13.4016]'
>
> >S(1)^2/sum(S.^2);
>  0.3802

> >ZeroedX = X - repmat(mean(X),200,1); %%ZeroedX is now zero centered data
> >C = cov(ZeroedX); %%Covariance matrix of ZeroedX
> >[U,L] = eig(C); %% Eigen decompostion of C
> > SE = diag(L);
>   [0.8918    1.1098    1.2337]'
> >SE(1)/sum(SE)
>   0.3813
>
>This is the case that I was confused by.
>
>Fred

You must also apply svd on your centred table X (i.e. ZeroeX)




More information about the R-help mailing list