[R] Factor Analysis Output from R and SAS
John Fox
jfox at mcmaster.ca
Tue Mar 31 14:17:27 CEST 2009
Dear TY,
Considering that you used different methods -- maximum-likelihood factor
analysis in R and principal components analysis in SAS -- the results are
quite similar (although the three rotated factors/components come out in
different orders).
I hope this helps,
John
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On
> Behalf Of Tae-Young Heo
> Sent: March-31-09 7:07 AM
> To: r-help at r-project.org
> Subject: [R] Factor Analysis Output from R and SAS
>
> Dear Users,
>
> I ran factor analysis using R and SAS. However, I had different outputs
from
> R and SAS.
> Why they provide different outputs? Especially, the factor loadings are
> different.
> I did real dataset(n=264), however, I had an extremely different from R
and
> SAS.
> Why this things happened? Which software is correct on?
>
> Thanks in advance,
>
> - TY
>
> #R code with example data
>
> # A little demonstration, v2 is just v1 with noise,
> # and same for v4 vs. v3 and v6 vs. v5
> # Last four cases are there to add noise
> # and introduce a positive manifold (g factor)
> 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)
> cor(m1)
> # v1 v2 v3 v4 v5 v6
> #v1 1.0000000 0.9393083 0.5128866 0.4320310 0.4664948 0.4086076
> #v2 0.9393083 1.0000000 0.4124441 0.4084281 0.4363925 0.4326113
> #v3 0.5128866 0.4124441 1.0000000 0.8770750 0.5128866 0.4320310
> #v4 0.4320310 0.4084281 0.8770750 1.0000000 0.4320310 0.4323259
> #v5 0.4664948 0.4363925 0.5128866 0.4320310 1.0000000 0.9473451
> #v6 0.4086076 0.4326113 0.4320310 0.4323259 0.9473451 1.0000000
>
> factanal(m1, factors=3) # varimax is the default
>
>
> # Output from R
>
> #Call:
> #factanal(x = m1, factors = 3)
>
> #Uniquenesses:
> # v1 v2 v3 v4 v5 v6
> #0.005 0.101 0.005 0.224 0.084 0.005
>
> #Loadings:
> # Factor1 Factor2 Factor3
> #v1 0.944 0.182 0.267
> #v2 0.905 0.235 0.159
> #v3 0.236 0.210 0.946
> #v4 0.180 0.242 0.828
> #v5 0.242 0.881 0.286
> #v6 0.193 0.959 0.196
>
> # Factor1 Factor2 Factor3
> #SS loadings 1.893 1.886 1.797
> #Proportion Var 0.316 0.314 0.300
> #Cumulative Var 0.316 0.630 0.929
>
> #The degrees of freedom for the model is 0 and the fit was 0.4755
>
> /* SAS code with example data*/
>
> data fact;
> input v1-v6;
> datalines;
> 1 1 3 3 1 1
> 1 2 3 3 1 1
> 1 1 3 4 1 1
> 1 1 3 3 1 2
> 1 1 3 3 1 1
> 1 1 1 1 3 3
> 1 2 1 1 3 3
> 1 1 1 2 3 3
> 1 2 1 1 3 4
> 1 1 1 1 3 3
> 3 3 1 1 1 1
> 3 4 1 1 1 1
> 3 3 1 2 1 1
> 3 3 1 1 1 2
> 3 3 1 1 1 1
> 4 4 5 5 6 6
> 5 6 4 6 4 5
> 6 5 6 4 5 4
> ;
> run;
>
> proc factor data=fact rotate=varimax method=p nfactors=3;
> var v1-v6;
> run;
>
> /* Output from SAS*/
>
> The FACTOR
> Procedure
> Initial Factor Method: Principal
> Components
>
> Prior Communality Estimates:
> ONE
>
>
>
> Eigenvalues of the Correlation Matrix:
> Total = 6 Average = 1
>
> Eigenvalue Difference
> Proportion Cumulative
>
> 1 3.69603077 2.62291629
> 0.6160 0.6160
> 2 1.07311448 0.07234039
> 0.1789 0.7949
> 3 1.00077409 0.83977061
> 0.1668 0.9617
> 4 0.16100348 0.12004232
> 0.0268 0.9885
> 5 0.04096116 0.01284515
> 0.0068 0.9953
> 6 0.02811601
> 0.0047 1.0000
>
> 3 factors will be retained by the
> NFACTOR criterion.
>
>
>
> Factor Pattern
>
> Factor1
> Factor2 Factor3
>
> v1 0.79880
> 0.54995 -0.17614
> v2 0.77036
> 0.56171 -0.24862
> v3 0.79475
> -0.07685 0.54982
> v4 0.75757
> -0.08736 0.59785
> v5 0.80878
> -0.45610 -0.33437
> v6 0.77771
> -0.48331 -0.36933
>
>
> Variance Explained by Each
> Factor
>
> Factor1 Factor2
> Factor3
>
> 3.6960308 1.0731145
> 1.0007741
>
>
> Final Communality Estimates:
Total
> = 5.769919
>
> v1 v2 v3
> v4 v5 v6
> 0.97154741 0.97078498 0.93983835
> 0.93897798 0.97394719 0.97482345
>
>
>
> The FACTOR Procedure
> Rotation Method:
Varimax
>
> Orthogonal Transformation
> Matrix
>
> 1
> 2 3
>
> 1 0.58233
> 0.57714 0.57254
> 2 -0.64183
> 0.75864 -0.11193
> 3 -0.49895
> -0.30229 0.81220
>
>
> Rotated Factor Pattern
>
> Factor1
> Factor2 Factor3
>
> v1 0.20008
> 0.93148 0.25272
> v2 0.21213
> 0.94590 0.17626
> v3 0.23781
> 0.23418 0.91019
> v4 0.19893
> 0.19023 0.92909
> v5 0.93054
> 0.22185 0.24253
> v6 0.94736
> 0.19384 0.19939
>
>
> Variance Explained by Each
> Factor
>
> Factor1 Factor2
> Factor3
>
> 1.9445607 1.9401828
> 1.8851759
>
>
> Final Communality Estimates:
Total
> = 5.769919
>
> v1 v2 v3
> v4 v5 v6
>
> 0.97154741 0.97078498 0.93983835
> 0.93897798 0.97394719 0.97482345
>
> [[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.
More information about the R-help
mailing list