I was trying to compute principle components for the following simulated data:
test = data.frame(x = rnorm(3), x2 = rnorm(3), x3 = rnorm(3), x4 = rnorm(3), x5 = rnorm(3)) pr.out =prcomp (test , scale =TRUE) pr.out$rotation
PC1 PC2 PC3 x 0.4976161 0.23472585 -0.62942510 x2 0.2612125 0.77520587 0.03019296 x3 -0.5150470 -0.03722759 -0.46152143 x4 -0.4137207 0.53641384 0.40663018 x5 0.4977027 -0.23416645 0.47388004
pr.out$sdev 1.939906e+00 1.112100e+00 3.716899e-16
Which only gives 3 principal components. I had expected that since the variance - covariance matrix of the data to be 5x5, that the matrix will have 5 eigenvectors, 3 of which correspond to zero eigenvalues, since the number of eigenvectors corresponding to non-zero eigenvalues is at most $min(n-1,p)$. Based on standard deviation of the principal scores, the program seems to be dropping out two of the principal components that correspond to zero eigenvalues.
I went through the documentation but didn't find anything to indicate that it would only output at most n principle components (where n is the number of observations, 3 in this case). Is there a reason why I'm seeing this?