Problem reconstructing retained principal components
Show older comments
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
Accepted Answer
More Answers (0)
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!