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
?