I understand that lavaan
is designed to do SEM/CFA while the R function factanal
does EFA. EFA and CFA seem very very similar, and so I wonder why I don't seem to be able to specify what to me looks like the same model in lavaan
as I can fit in factanal
.
Have I misunderstood the statistical relationship between CFA and EFA, or am I simply misusing lavaan
syntax?
For example, using the classic Holzinger-Swineford data we can look for two factors in the first 6 observables. lavaan
throws this out with an error,
> library(lavaan)
> model <- 'f1 =~ x1 + x2 + x3 + x4 + x5 + x6
+ f2 =~ x1 + x2 + x3 + x4 + x5 + x6
+ '
> fit <- cfa(model, data = HolzingerSwineford1939)
Warning message:
In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, :
lavaan WARNING: could not compute standard errors!
lavaan NOTE: this may be a symptom that the model is not identified.
but factanal
is fine with it:
>
> factanal(~x1+x2+x3+x4+x5+x6, factors = 2, data = HolzingerSwineford1939)
Call:
factanal(x = ~x1 + x2 + x3 + x4 + x5 + x6, factors = 2, data = HolzingerSwineford1939)
Uniquenesses:
x1 x2 x3 x4 x5 x6
0.574 0.787 0.441 0.284 0.232 0.304
Loadings:
Factor1 Factor2
x1 0.293 0.584
x2 0.106 0.449
x3 0.747
x4 0.824 0.191
x5 0.873
x6 0.802 0.231
Factor1 Factor2
SS loadings 2.183 1.196
Proportion Var 0.364 0.199
Cumulative Var 0.364 0.563
Test of the hypothesis that 2 factors are sufficient.
The chi square statistic is 2.07 on 4 degrees of freedom.
The p-value is 0.722
How do I specific a model like factanal
is doing in lavaan
?
Best Answer
It is possible to do EFA in a CFA framework. This is sometimes called "E/CFA". A nice discussion of this can be found in:
Brown, T. A. (2006). Confirmatory factor analysis for applied research. New York: Guilford Press.
For this to work, you need to have an "anchor item" for each factor, for which there are no cross-loadings. Looking at the results from
factanal
, it would make sense to make itemx5
the anchor item for the first factor andx3
the anchor item for the second factor. You also need to constrain the variances of the latent factors to 1. And sincefactanal
standardizes the variables, you'll want to do the same here. At the same time, to make things more comparable, I would use an oblique rotation method for EFA (since the E/CFA model will allow the factors to be correlated). So, putting this all together, you can compare:Here are the results:
According to Brown (2006), the chi-square statistic should be the same for both approaches. For the example shown in the book, this is indeed the case (but the author uses Mplus for the EFA and E/CFA analyses). In this particular example, the values are close (2.109 and 2.07), but not identical. There seems to be some minor difference in how
lavaan
andfactanal
are working here, but ultimately the point is that one can indeed do an exploratory factor analysis using CFA software.