Learn R Programming

modsem (version 1.0.11)

modsem_mimpute: Estimate a modsem model using multiple imputation

Description

Estimate a modsem model using multiple imputation

Usage

modsem_mimpute(
  model.syntax,
  data,
  method = "lms",
  m = 25,
  verbose = interactive(),
  se = c("simple", "full"),
  ...
)

Arguments

model.syntax

lavaan syntax

data

A dataframe with observed variables used in the model.

method

Method to use:

"lms"

latent moderated structural equations (not passed to lavaan).

"qml"

quasi maximum likelihood estimation (not passed to lavaan).

m

Number of imputations to perform. More imputations will yield better estimates but can also be (a lot) slower.

verbose

Should progress be printed to the console?

se

How should corrected standard errors be computed? Alternatives are:

"simple"

Uncorrected standard errors are only calculated once, in the first imputation. The standard errors are thereafter corrected using the distribution of the estimated coefficients from the different imputations.

"full"

Uncorrected standard errors are calculated and aggregated for each imputation. This can give more accurate results, but can be (a lot) slower. The standard errors are thereafter corrected using the distribution of the estimated coefficients from the different imputations.

...

Arguments passed to modsem.

Details

modsem_impute is currently only available for the DA approaches (LMS and QML). It performs multiple imputation using Amelia::amelia and returns aggregated coefficients from the multiple imputations, along with corrected standard errors.

Examples

Run this code

m1 <- '
  # Outer Model
  X =~ x1 + x2 +x3
  Y =~ y1 + y2 + y3
  Z =~ z1 + z2 + z3

  # Inner model
  Y ~ X + Z + X:Z
'

oneInt2 <- oneInt

set.seed(123)
k <- 200
I <- sample(nrow(oneInt2), k, replace = TRUE)
J <- sample(ncol(oneInt2), k, replace = TRUE)
for (k_i in seq_along(I)) oneInt2[I[k_i], J[k_i]] <- NA

if (FALSE) {
est <- modsem_mimpute(m1, oneInt2, m = 25)
summary(est)
}

Run the code above in your browser using DataLab