Re: [R] PCA - scores

From: William Revelle <lists_at_revelle.net>
Date: Thu, 03 Mar 2011 22:42:18 -0600

Shari,

   Josh partly answered your question, but his example did not include rotation because he took out just one factor.

Try:

require(psych)
mt.pc <- principal(mtcars,3,scores=TRUE) #this gives you the varimax rotated first 3 principal components #pc.scores <- mt.pc$scores #here are the scores

biplot(mt.pc) #show the data as well as the principal components in a biplot

Bill

At 5:15 PM -0800 3/3/11, Joshua Wiley wrote:
>Hi Shari,
>
>Yes, please look at the documentation for principal. You can access
>this (assuming you have loaded psych) by typing at the console:
>
>?principal
>
>note the logical argument "scores".
>
>Here is a small example:
>
>##############################
>require(psych)
>require(GPArotation)
>
>dat <- principal(mtcars[, c("mpg", "hp", "wt")], nfactors = 1,
> rotate = "oblimin", scores = TRUE)
>
>dat$scores
>##############################
>
>Cheerio,
>
>Josh
>
>On Thu, Mar 3, 2011 at 1:02 PM, Shari Clare <sclare_at_ualberta.ca> wrote:
>> I am running a PCA, but would like to rotate my data and limit the
>> number of factors that are analyzed. I can do this using the
>> "principal" command from the psych package [principal(my.data,
>> nfactors=3,rotate="varimax")], but the issue is that this does not
>> report scores for the Principal Components the way "princomp" does.
>>
>> My question is:
>>
>> Can you get an output of scores using "principal" OR, is there a way
>> to limit the number of factors that are included when you use
>> "princomp"?
>>
>> Thanks,
>> Shari Clare
>>
>> PhD Candidate
>> Department of Renewable Resources
>> University of Alberta
>> sclare_at_ualberta.ca
>> 780-492-2540
>>
>>
>>
>>
>>
>>
>>
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
>
>
>--
>Joshua Wiley
>Ph.D. Student, Health Psychology
>University of California, Los Angeles
>http://www.joshuawiley.com/
>
>______________________________________________
>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.



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. Received on Fri 04 Mar 2011 - 04:44:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Mar 2011 - 19:00:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive