I try to calculate the PCA in my matrix and I use two ways for this:
PCA function
[coeff, score, eigenvalues] = pca(M);
And for compare and understand the PCA calculus, I try to calculate step by step the PCA without the matlab function pca.
%// first I "z-scored" my matrix X = zscore(M); %// second I calculate the covariance matrix %// this matrix is equals to the correlation matrix V = cov(X); %// Third, I calculate the eigenvalues(E) and eigenvectors(U) [U,E] = eig(V);
The pca
function's eigenvalues are not equal to E
and I think the columns of U
are principal components and rows of U
are variables and it's not equal to coeff
.
So, I think that I don't understand how calculate the PCA of a matrix?
pca
function might not do a z-score first. The preliminary standardization is helpful for statistical applications, but other applications of PCA don't require any transformation so the standard MATLAB call might not include it. $\endgroup$ – EdM Jul 29 '15 at 23:38pca(data)
centers the data. But you did z-standardizationX = zscore(M)
. That is, center-then-scale operation. $\endgroup$ – ttnphns Jul 30 '15 at 10:39