Skip to content

Princomp and calculations of original values

1 message · Stefaan Lhermitte

#
Dear R-ians,

I am working with princomp and I now want to manually recalculate my 
original values. I want to do it to completely understand the procedure 
of principal components.

I tried it with a test data set (2 dimensions) and  I was able to 
calculate my original values (of a random point of my dataset) using the 
output of princomp:
test.data$scores[1,]%*%matrix(data=test.data$loadings,ncol=2)+test.data$center
it seemed that result is identical with
test[1,]

When I tried it with my 4 dimensional real dataset, it did not work:
pca.data$scores[1,]%*%matrix(data=pca.data$loadings,ncol=4)+pca.data$center
is not equal to
data[1,]

Do I misunderstand the procedure somewhere, or what else do I do wrong?

Thanx in advance and kind regards,
Stef