Structural Equation Modeling with lavaan in R
Erin Buchanan
Professor
twofactor.model <- 'visual =~ x1 + x2 + x3
speed =~ x7 + x8 + x9'
twofactor.model1 <- 'visual =~ x1 + x2 + x3
speed =~ x7 + x8 + x9
x7 ~~ x8'
twofactor.fit <- cfa(model = twofactor.model,
data = HolzingerSwineford1939)
twofactor.fit1 <- cfa(model = twofactor.model1,
data = HolzingerSwineford1939)
anova(twofactor.fit, twofactor.fit1)
Chi Square Difference Test
Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
twofactor.fit1 7 5150.5 5202.4 14.753
twofactor.fit 8 5181.2 5229.4 47.413 32.661 1 0.00000001097 ***
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 . 0.1 ' ' 1
fitmeasures()
fitmeasures(twofactor.fit)
aic bic ntotal
5181.168 5229.361 301.000
bic2 rmsea rmsea.ci.lower
5188.132 0.128 0.094
rmsea.ci.upper rmsea.pvalue rmr
0.164 0.000 0.096
_ _ _
fitmeasures(twofactor.fit, c("aic", "ecvi"))
aic ecvi
5181.168 0.244
fitmeasures(twofactor.fit1, c("aic", "ecvi"))
aic ecvi
5150.508 0.142
Structural Equation Modeling with lavaan in R