library(modsem)
By default, missing values for both the LMS and QML are removed list-wise (missing="listwise"
), such that only complete observations are kept. It is also possible to set missing="impute"
to impute missing values, or to use the modsem_mimpute()
function to perform multiple imputation. For the LMS approach it is also possible to use Full Information Maximum Likelihood (FIML)
If you’re using the LMS approach, it is possible to estimate your model using Full Information Maximum Likelihood (FIML), by setting missing="fiml"
. Here is an example, where we generate some missing data using the oneInt
dataset.
set.seed(2834027) # set seed for reproducibility
<- 200L # generate 200 missing values
n.missing <- as.matrix(oneInt)
oneInt2 sample(length(oneInt2), n.missing)] <- NA
oneInt2[
<- '
m1 # Outer Model
X =~ x1 + x2 + x3
Z =~ z1 + z2 + z3
Y =~ y1 + y2 + y3
# Inner Model
Y ~ X + Z + X:Z
'
<- modsem(m1, oneInt2, method = "lms", missing = "fiml")
lms_fiml summary(lms_fiml)
If you’re using the QML approach it is not possible (yet) to use FIML, and FIML can also be very computationally intensive when using the LMS approach. Another option is to use (multiple) imputation.
If missing="impute"
is set, single imputation is performed.
<- modsem(m1, oneInt2, method = "qml", missing = "impute")
qml_impute summary(qml_impute)
A better option than single imputation, is multiple imputation, which can be performed both for the LMS and QML approaches, using the modsem_mimpute()
function.
<- modsem_mimpute(m1, oneInt2, method = "lms")
lms_mimpute summary(lms_mimpute)