[R] pca analysis: extract rotated scores?

He Zhang hzshasha at googlemail.com
Wed Dec 1 13:45:34 CET 2010


Hi,

I am also doing PCA.
Is the following right for extracting the scores?

library(psych)
pca<-principal(data,nfactors=,rotate="varimax",scores=T)
pca$loadings
pca$score

Best regards,
He

On Tue, Nov 30, 2010 at 10:22 AM, Liviu Andronic <landronimirc at gmail.com> wrote:
> Dear all
> I'm unable to find an example of extracting the rotated scores of a
> principal components analysis. I can do this easily for the un-rotated
> version.
>
> data(mtcars)
> .PC <- princomp(~am+carb+cyl+disp+drat+gear+hp+mpg, cor=TRUE, data=mtcars)
> unclass(loadings(.PC))  # component loadings
> summary(.PC) # proportions of variance
> mtcars$PC1 <- .PC$scores[,1] # extract un-rotated scores of 1st
> principal component
> mtcars$PC2 <- .PC$scores[,2] # extract un-rotated scores of 2nd
> principal component
> head(mtcars[, c('PC1', 'PC2')])
>
> However, I no longer understand how to do so if I want to use
> ?principal in 'psych' and any of the GPArotation methods. For example,
> require(psych)
> r <- cor(mtcars[,c("am","carb","cyl","disp","drat","gear","hp","mpg")])
> pca <- principal(r, nfactors = 8, residuals = T, rotate="none") # or
> 'varimax' or any other GPArotation supported rotation
> pca
>
> I've turned the 'pca' object and ?principal help page upside down and
> I still cannot find anything that would resemble a 'scores' value. I'm
> pretty sure it's one matrix computation away, but I cannot find which
> one.
>
> Ideas? Thank you
> Liviu
>
>
>
> --
> Do you know how to read?
> http://www.alienetworks.com/srtest.cfm
> http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
> Do you know how to write?
> http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list