MATLAB: Principal Component Coefficients in princomp

principal component coefficientsStatistics and Machine Learning Toolbox

Hi all, The first output of the princomp function is The Principal Component Coefficients(the normalized eigenvectors)and the second output is The Component Scores.I used this code:[_coefs,scores,variances,t2_] = princomp(sr); but the computed result of sr*coefs is not euqal to scores.Why? I am confused!How can I get the eigenvectors of the input matrix?
Thanks for all your kindly answering.

Best Answer

The princomp function works on the centered data (variance/covariance matrix), so you need to remove the mean to reproduce the scores:
load hald
[a,b] = princomp(ingredients);
bsxfun(@minus,ingredients,mean(ingredients))*a
Related Question