Maurice McHugh
2004-Feb-17 14:38 UTC
[R] Comparison of % variance explained by each PC before AND after rotation
Hello again- Thanks to Prof. Ripley for responding to my previous question. I would like to clarify my question using sample code. I will use some sample code taken from ?prcomp Again, I would like to compare the % variance explained by each PC before and after rotation. < code follows > data(USArrests) pca = prcomp(USArrests, scale = TRUE) # proportion variance explained by each PC prop = pca$sdev^2/sum(pca$sdev^2) # cumulative proportion variance explained by each PC cumProp = cumsum(prop) # following print statements also can be obtained # from print(summary(pca)) #print(prop) #print(cumProp) print(summary(pca)) # Rotate the PCA loadings through PCs 1 and 2 using VARIMAX rotation rot = varimax(pca$rotation[,1:2], normalize = TRUE, eps = 1e-5) < end code > How can I calculate the new % variance explained by each PC after rotation ?????? Many thanks once more, -- Maurice J. McHugh, Ph.D. Assistant Professor Department of Geography and Anthropology 227 Howe Russell Geoscience Complex Louisiana State University Phone: (225)578-0476 Baton Rouge, LA Fax: (225)578-4420 USA
Prof Brian Ripley
2004-Feb-17 17:00 UTC
[R] Comparison of % variance explained by each PC before AND after rotation
You are applying varimax to the rotation matrix, so each column has length one, both before and after rotation. Unlike factor analysis, there is no information in the loadings matrix about the variances. There is no such thing as `each PC after rotation': after rotation the vectors are no longer PCs. See http://www.stats.ox.ac.uk/pub/MASS3/VR3stat.pdf for how to do this in S-PLUS, and the various snags. There is no comparable code implemented in R. You need to rotate the scores also, and compute their variances directly. Once again, factor analysis and PCA are quite distinct, and you need to be very careful not to confuse them. On Tue, 17 Feb 2004, Maurice McHugh wrote:> Hello again- > > Thanks to Prof. Ripley for responding to my previous question. > > I would like to clarify my question using sample code. I will use some > sample code taken from ?prcomp > > Again, I would like to compare the % variance explained by each PC > before and after rotation. > > < code follows > > > data(USArrests) > pca = prcomp(USArrests, scale = TRUE) > > # proportion variance explained by each PC > prop = pca$sdev^2/sum(pca$sdev^2) > > # cumulative proportion variance explained by each PC > cumProp = cumsum(prop) > > # following print statements also can be obtained > # from print(summary(pca)) > #print(prop) > #print(cumProp) > > print(summary(pca)) > > # Rotate the PCA loadings through PCs 1 and 2 using VARIMAX rotation > > rot = varimax(pca$rotation[,1:2], normalize = TRUE, eps = 1e-5) > > < end code > > > How can I calculate the new % variance explained by each PC after > rotation ?????? > > Many thanks once more, > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595