[R] Extracting factors from "factanal"

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jan 2 11:52:58 CET 2013


On 02/01/2013 10:34, PIKAL Petr wrote:
> Hi
> I am not at all an expert in factor analysis but I would say that
>
> myscores[1,1]
>
> is a value of factor1 for the first row of your data frame. How would you like the link to be performed. Easiest way seems to me cbind your data frame with myscores.
>
> m2 <- cbind(m1, myscores)
>
> However grater expert than myself shall confirm that my assumptions are correct.

If you give your observations names, the names would (AFAIK) be used for 
the scores.


> Regards
>
> Petr
>
> From: Virgile Capo-Chichi [mailto:vcapochichi at gmail.com]
> Sent: Wednesday, January 02, 2013 11:20 AM
> To: PIKAL Petr
> Cc: R help
> Subject: Re: [R] Extracting factors from "factanal"
>
> Thanks Petr, very useful. Still, I need to link the scores to individual observations in my original data frame. Is that possible? V
> 2013/1/2 PIKAL Petr <petr.pikal at precheza.cz<mailto:petr.pikal at precheza.cz>>
> Hi
>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org<mailto:r-help-bounces at r-project.org> [mailto:r-help-bounces at r-<mailto:r-help-bounces at r->
>> project.org<http://project.org>] On Behalf Of Virgile Capo-Chichi
>> Sent: Wednesday, January 02, 2013 9:33 AM
>> To: R help
>> Subject: [R] Extracting factors from "factanal"
>>
>> Dear R users
>> Happy New year to all for a start. Below is some data that I ran a
>> factor analysis on. Using $score prints the scores for each of the
>> three factors.
>> However, I would like to access those factors as variable for new
>> computations. How do I do that? In SPSS we just call fact1_1, fact2_1
>> etc..
>> Thanks for your suggestions. V
>>
>> ============
>> v1 <- c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6)
>> v2 <- c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5)
>> v3 <- c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6)
>> v4 <- c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4)
>> v5 <- c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5)
>> v6 <- c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4)
>> m1 <- cbind(v1,v2,v3,v4,v5,v6)
>> factanal(m1, factors = 3,scores = "Bartlett")$scores
> myscores <- factanal(m1, factors = 3,scores = "Bartlett")$scores
>
>> myscores[,1]
>   [1] -0.9039949 -0.8685952 -0.9082818 -1.0021975 -0.9039949 -0.7452711
>   [7] -0.7098714 -0.7495580 -0.8080740 -0.7452711  0.9272282  0.9626279
> [13]  0.9229413  0.8290256  0.9272282  0.4224366  1.4713902  1.8822320
>
> or
>
>> myscores[,"Factor1"]
>   [1] -0.9039949 -0.8685952 -0.9082818 -1.0021975 -0.9039949 -0.7452711
>   [7] -0.7098714 -0.7495580 -0.8080740 -0.7452711  0.9272282  0.9626279
> [13]  0.9229413  0.8290256  0.9272282  0.4224366  1.4713902  1.8822320
>>
>
> selects a factor score. myscore is a matrix so you cannot use $ notation. However you can convert it to data frame.
>
> Regards
> Petr
>
>
>
>>
>>        [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help at r-project.org<mailto: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.
>


-- 
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




More information about the R-help mailing list