Skip to content

question about Principal Component Analysis in R?

2 messages · Michael, Bjørn-Helge Mevik

#
Michael wrote:

            
This is because you have subtracted a different means vector.  You
should use the coloumn means of the training data (as predict does;
see the last line of stats:::predict.prcomp):

d1=scale(test_data, center=pca$center, scale=FALSE) %*% pca$rotation;