I have generated 100 2D correlated MVN variables in R, on which I run
prcomp. When I plot the projected points along the first principal component (in the original coordinates) with the original data overlaid, I have a bunch of points along a line (as expected) yet they do not seem to correspond to the original points in the scatterplot (I was expecting each point along the line to be the projection of some original point)
Here is my code:
require(MASS) x <- mvrnorm(100, mu = c(0,0), Sigma = matrix(c(1,-.85,-.85,5), 2, 2), empirical = FALSE) pcX <- prcomp(x, retx = TRUE, scale = FALSE) transformed <- pcX$x[,1] %*% t( pcX$rotation[,1] ) plot(transformed, col = "red") points(x, col = "green")
Is there some scaling going on which is preventing me from recovering the original data, or is my understanding of PCA (or R) lacking?