Centering data in PCA - PC1 does not pass through 0
2 views (last 30 days)
Show older comments
Caroline
on 2 Mar 2017
Answered: Darshan Ramakant Bhat
on 6 Mar 2017
I've a question regarding the pca function. I'm using it on a [28x79] matrix and the resulting principal component coefficients are confusing me somewhat. According to the documentation, pca centers the column data by subtracting the mean. However, when I plot the coordinates of the coefficients of principal components 1-3 in state space (i.e x-axis contains principal component 1 (PC1), y-axis contains principal component 2 (PC2), z-axis contains principal component 3 (PC3), principal component 1 does not pass through 0. Instead the typical range is somewhere between [0.05 2]. Could you explain this? PC2 and PC3 behave as I would expect after centering, in that their range contains 0.
Thank you for your help.
0 Comments
Accepted Answer
Darshan Ramakant Bhat
on 6 Mar 2017
I think you are mixing up something. The pca() documentation says " by default, pca centers the data and uses the singular value decomposition (SVD) algorithm". This means when you do _coeff = pca(X), the data X will be centered. That means the function will preprocess the data ' X' by subtracting the means from from its column.It is equivalent to doing
[m n]=size(X);
X_processed=zeros(m,n)
for i=1:n
X_processed(:,i)=X(:,i)-mean(X(:,i));
end
This is nothing to do with PCA coefficients, this can vary from any range. Try pca() function with X and X_processed, ideally you should get the same result.
I hope this answer will help you.
Regards
Darshan Bhat
0 Comments
More Answers (0)
See Also
Categories
Find more on Dimensionality Reduction and Feature Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!