Re: [R] PCA - scores

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Sat, 05 Mar 2011 18:50:18 +0100

On 04.03.2011 17:52, Shari Clare wrote:
> Hi Bill and Josh:
>
> When I run any "principal" code with scores=TRUE, I get the following
> Error:
>
> Error in principal (my.data,3,scores=TRUE) : unused argument
> (scores=TRUE)
>
> Thoughts?

Your psych version (and probably also your R version) is outdated? Please upgrade both R and your packages.

Best,
Uwe Ligges

>
> Thanks,
> Shari
>
>
>
>
>
>
> On 3-Mar-11, at 9:42 PM, William Revelle wrote:
>
>> 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.
>>
>
>
> [[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.



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 Sat 05 Mar 2011 - 17:53:26 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 Sat 05 Mar 2011 - 18:10:19 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