Problem reconstructing retained principal components
4 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Ilya
2013 年 8 月 14 日
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 件のコメント
Ilya
2013 年 8 月 14 日
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.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!