Determining variables that contribute to principal components

20 Ansichten (letzte 30 Tage)
Eric
Eric am 26 Sep. 2012
Hi,
I am trying to do a PCA analysis on a (24x3333) matrix where 24 is the number of observations and 3333 is the number of variables. I am using:
[coeff,score,eigval] = princomp(zscore(aggregate));
23 PCs are needed to explain 95% of the variance in the data. My question is how do I know which variables are contributing to each component. I believe I need to make a variable spreadsheet naming all 3333 variables. However, it is not clear how I would be able to identify the variables contributing to each component.
I also am creating a variable: %percent variation explained (PVE): variation in the original variable explained by a principal component
Because ultimately I want to quantify how much a variable contributes to its respective principal component.
for i = 1:3333
pve(:,i) = 100*coeff(i,i)*sqrt(var(score(:,i)))/(var(aggregate(:,i)));
end
Any insight would be a big help. I've been trying to figure this out for for weeks with no luck.
Thanks,
Eric

Akzeptierte Antwort

Ilya
Ilya am 26 Sep. 2012
The first paragraph in the doc description for princomp says "COEFF is a p-by-p matrix, each column containing coefficients for one principal component." For example, to project your data onto the 1st principal axis, do zscore(aggregate)*coeff(:,1). Why not measure the contribution of a variable to a component by the size of the respective coefficient? Especially since you have standardized your data by zscore.
Since you have 23 components, the columns in score past 23 are filled with zeros. If you need to get the principal component variance, take the 3rd output from princomp.
  5 Kommentare
Ilya
Ilya am 28 Sep. 2012
Bearbeitet: Ilya am 28 Sep. 2012
I could understand what you mean if you wanted to go in the opposite direction, that is, explain variance in an original variable by a specific principal component. Since the covariance matrix is diagonal in the PCA space, we can separate contributions of the principal components to the variance of a variable. I do not see how to separate variable contributions to the variance of a principal component since the variables are not independent (and if they were, you would not need PCA in the first place). Here is what you could do:
% Load data and perform PCA
load hald
[coeff,~,latent] = princomp(ingredients);
cov(ingredients)
% Variance in variable I explained by principal component J
i = 2;
j = 1;
varI = coeff(i,:)*(latent.*coeff(i,:)')
varIfromJ = coeff(i,j)*latent(j)*coeff(i,j)
percVarIfromJ = varIfromJ/varI
Alternatively, you could, of course, ask the authors of those gait studies what exactly they did.
Eric
Eric am 30 Sep. 2012
Thank you. Your way to find percVarIformJ was what I was attempting to do with my original for loop.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dimensionality Reduction and Feature Extraction finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by