The relationship between SCORE and LOADING from PCA using princomp in MATLAB
    3 views (last 30 days)
  
       Show older comments
    
I'm doing PCA using princomp.
I'd like to confirm score is derived from X and loading. As far as I know, score = X*loading
My code is [loadb fact] = princomp( X , 'econ' );
But, "X*loadb" and "fact" are different.
Is there anybody explain how can I get score from loading and X?
0 Comments
Answers (1)
  Aditya
      
 on 5 Feb 2025
        Hi Torsionfree,
When you perform PCA using MATLAB's princomp function (or its successor pca), the output score (also known as fact in your code) represents the principal component scores, which are the projections of the original data X onto the principal component axes defined by the loadings (or loadb).
Following is aan example for data centering:
% Example data matrix X
% X = [...]; % Your data matrix
% Perform PCA using princomp
[loadb, fact, latent, tsquared, explained, mu] = princomp(X, 'econ');
% Manually compute the scores
X_centered = X - mean(X); % Center the data
manual_fact = X_centered * loadb;
% Compare the manually computed scores with those from princomp
disp('Difference between computed scores and princomp scores:');
disp(norm(fact - manual_fact));
0 Comments
See Also
Categories
				Find more on Statistics and Machine Learning Toolbox 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!
