data(HS20imps) # import a list of 20 imputed data sets
## specify CFA model from ?lavaan::cfa help page
HS.model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
fit1 <- cfa.mi(HS.model, data = HS20imps, estimator = "mlm")
## By default, pool.method = "D4".
## Must request an asymptotic chi-squared statistic
## in order to accommodate a robust correction.
lavTestLRT.mi(fit1, asymptotic = TRUE)
## or anova(fit1, asymptotic = TRUE)
## Comparison with more constrained (nested) models: parallel indicators
HS.parallel <- '
visual =~ x1 + 1*x2 + 1*x3
textual =~ x4 + 1*x5 + 1*x6
speed =~ x7 + 1*x8 + 1*x9
'
fitp <- cfa.mi(HS.parallel, data = HS20imps, estimator = "mlm")
## Even more constrained model: orthogonal factors
fit0 <- cfa.mi(HS.parallel, data = HS20imps, estimator = "mlm",
orthogonal = TRUE)
## Compare 3 models, and pass the lavTestLRT(method=) argument
# \donttest{
lavTestLRT.mi(fit1, fit0, fitp, asymptotic = TRUE,
method = "satorra.bentler.2010")
## For a single model, you can request a vector instead of an anova-class
## table in order to see naive information criteria (only using D3 or D4),
## which are calculated using the average log-likelihood across imputations.
lavTestLRT.mi(fit1, asANOVA = FALSE)
## When using a least-squares (rather than maximum-likelihood) estimator,
## only the D2 method is available. For example, ordered-categorical data:
data(binHS5imps) # import a list of 5 imputed data sets
## fit model using default DWLS estimation
fit1c <- cfa.mi(HS.model , data = binHS5imps, ordered = TRUE)
fit0c <- cfa.mi(HS.parallel, data = binHS5imps, ordered = TRUE,
orthogonal = TRUE)
## Using D2, you can either robustify the pooled naive statistic ...
lavTestLRT.mi(fit1c, fit0c, asymptotic = TRUE, pool.method = "D2")
## ... or pool the robust chi-squared statistic (NOT recommended)
lavTestLRT.mi(fit1c, fit0c, asymptotic = TRUE, pool.method = "D2",
pool.robust = TRUE)
## When calculating fit indices, you can pass lavTestLRT.mi() arguments:
fitMeasures(fit1c, output = "text",
# lavTestLRT.mi() arguments:
pool.method = "D2", pool.robust = TRUE)
# }
Run the code above in your browser using DataLab