lavaan.mi {lavaan.mi} | R Documentation |
Fit a lavaan Model to Multiple Imputed Data Sets
Description
This function fits a lavaan model to a list of imputed data sets.
Usage
lavaan.mi(model, data, ...)
cfa.mi(model, data, ...)
sem.mi(model, data, ...)
growth.mi(model, data, ...)
Arguments
model |
The analysis model can be specified using lavaan
|
data |
A a |
... |
additional arguments to pass to |
Value
A lavaan.mi object
Note
This functionality was originally provided via runMI()
in the
semTools
package, but there are differences. See the README file
on the GitHub page for this package (find link in DESCRIPTION).
Author(s)
Terrence D. Jorgensen (University of Amsterdam; TJorgensen314@gmail.com)
References
Enders, C. K. (2010). Applied missing data analysis. New York, NY: Guilford.
Rubin, D. B. (1987). Multiple imputation for nonresponse in surveys. New York, NY: Wiley. doi:10.1002/9780470316696
See Also
poolSat()
for a more efficient method to obtain SEM results
for multiple imputations
Examples
data(HS20imps) # import a list of 20 imputed data sets
## specify CFA model from lavaan's ?cfa help page
HS.model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
## fit model to imputed data sets
fit <- cfa.mi(HS.model, data = HS20imps)
summary(fit, fit.measures = TRUE, fmi = TRUE)
summary(fit, standardized = "std.all", rsquare = TRUE)
## You can pass other lavaanList() arguments, such as FUN=, which allows
## you to save any custom output from each imputation's fitted model.
## An example with ordered-categorical data:
data(binHS5imps) # import a list of 5 imputed data sets
## Define a function to save a list with 2 custom outputs per imputation:
## - zero-cell tables
## - the obsolete "WRMR" fit index
myCustomFunc <- function(object) {
list(wrmr = lavaan::fitMeasures(object, "wrmr"),
zeroCells = lavaan::lavInspect(object, "zero.cell.tables"))
}
## fit the model
catout <- cfa.mi(HS.model, data = binHS5imps, ordered = TRUE,
FUN = myCustomFunc)
## pooled results
summary(catout)
## extract custom output (per imputation)
sapply(catout@funList, function(x) x$wrmr) # WRMR for each imputation
catout@funList[[1]]$zeroCells # zero-cell tables for first imputation
catout@funList[[2]]$zeroCells # zero-cell tables for second imputation ...