Problem reconstructing retained principal components
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I think I am having an issue reconstructing retained principal components. I have a data set called data, size(40,101). So, I have 40 observations (subjects) and 101 variables (PCs). I would like to reconstruct the signal using all 101 pcs, then only PC1, PC2, and PC3. Here is my code:
[coeff, score, eigval] = princomp(data); subjects = 40;
pc_all = repmat(mean((data),1),subjects,1) + score(:,:)*coeff(:,:)';%all PC
pc1 = repmat(mean((data),1),subjects,1) + score(:,1)*coeff(:,1)';%PC1
pc2 = repmat(mean((data),1),subjects,1) + score(:,2)*coeff(:,2)';%PC2
pc3 = repmat(mean((data),1),subjects,1) + score(:,3)*coeff(:,3)';%PC3
When I take the mean(sd) for each PC, I end up with the same mean for each variable but a different sd.
ensem_pc_all(:,1) = mean(pc_all(1:subjects,:),1);
ensem_pc_all(:,2) = std(pc_all(1:subjects,:),0,1);
ensem_pc1(:,1) = mean(pc1(1:subjects,:),1);
ensem_pc1(:,2) = std(pc1(1:subjects,:),0,1); %...etc
Is there a reason the mean does not change depending on the number of components I retain?
Thanks, Eric
0 commentaires
Réponse acceptée
Ilya
le 14 Août 2013
PCA is applied to centered data. Observe that mean(score) is close to a vector of zeros. Rotating the scores back to the original coordinates should also produce vectors with means close to zero. For all pc's defined as they are above, the mean should be fairly close to mean(data).
4 commentaires
Ilya
le 14 Août 2013
Suppose you center your data. Or, to put it differently, move the coordinate origin to the computed center of the dataset. After you do that, the mean of observed values for any variable is zero. Equivalently, if you draw a vector from the new origin to each point in the dataset and add all the vectors, you will get a vector of zeros. The PCA transformation is an orthogonal rotation with respect to the new origin. An orthogonal rotation applied to a zero vector returns a zero vector. The mean of any variable, either in the (centered) space of original variables or in the rotated space, is zero.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dimensionality Reduction and Feature Extraction dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!