Skip to contents

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


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

# \dontrun{
est <- modsem_mimpute(m1, oneInt2, m = 25)
summary(est)
#> 
#> modsem (version 1.0.11):
#> 
#>   Estimator                                         LMS
#>   Optimization method                        EMA-NLMINB
#>   Number of observations                           2000
#>   Number of iterations                              334
#>   Loglikelihood                               -14660.68
#>   Akaike (AIC)                                 29383.37
#>   Bayesian (BIC)                               29556.99
#>  
#> Numerical Integration:
#>   Points of integration (per dim)                    24
#>   Dimensions                                          1
#>   Total points of integration                        24
#>  
#> Fit Measures for Baseline Model (H0):
#>   Loglikelihood                               -17845.54
#>   Akaike (AIC)                                 35751.07
#>   Bayesian (BIC)                                35919.1
#>   Chi-square                                      18.20
#>   Degrees of Freedom (Chi-square)                    24
#>   P-value (Chi-square)                            0.793
#>   RMSEA                                           0.000
#>  
#> Comparative Fit to H0 (LRT test):
#>   Loglikelihood change                          3184.85
#>   Difference test (D)                           6369.71
#>   Degrees of freedom (D)                              1
#>   P-value (D)                                     0.000
#>  
#> R-Squared Interaction Model (H1):
#>   Y                                               0.598
#> R-Squared Baseline Model (H0):
#>   Y                                               0.396
#> R-Squared Change (H1 - H0):
#>   Y                                               0.202
#> 
#> Parameter Estimates:
#>   Coefficients                           unstandardized
#>   Information                    Rubin-corrected (m=25)
#>   Standard errors                              standard
#>  
#> Latent Variables:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   X =~          
#>     x1              1.000                             
#>     x2              0.804      0.013    64.03    0.000
#>     x3              0.910      0.014    67.13    0.000
#>   Z =~          
#>     z1              1.000                             
#>     z2              0.812      0.012    65.39    0.000
#>     z3              0.882      0.013    67.78    0.000
#>   Y =~          
#>     y1              1.000                             
#>     y2              0.800      0.007   106.99    0.000
#>     y3              0.899      0.008   112.02    0.000
#> 
#> Regressions:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   Y ~           
#>     X               0.671      0.031    21.70    0.000
#>     Z               0.570      0.030    18.87    0.000
#>     X:Z             0.717      0.028    25.91    0.000
#> 
#> Intercepts:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .x1              1.023      0.024    43.03    0.000
#>    .x2              1.212      0.020    60.72    0.000
#>    .x3              0.917      0.022    41.38    0.000
#>    .z1              1.011      0.024    41.61    0.000
#>    .z2              1.203      0.020    59.01    0.000
#>    .z3              0.916      0.022    42.17    0.000
#>    .y1              1.038      0.033    31.57    0.000
#>    .y2              1.220      0.027    45.38    0.000
#>    .y3              0.953      0.030    31.90    0.000
#> 
#> Covariances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   X ~~          
#>     Z               0.199      0.024     8.18    0.000
#> 
#> Variances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .x1              0.157      0.009    17.98    0.000
#>    .x2              0.161      0.007    23.05    0.000
#>    .x3              0.165      0.008    21.10    0.000
#>    .z1              0.167      0.009    18.41    0.000
#>    .z2              0.159      0.007    22.66    0.000
#>    .z3              0.158      0.008    20.89    0.000
#>    .y1              0.160      0.009    18.14    0.000
#>    .y2              0.154      0.007    22.64    0.000
#>    .y3              0.165      0.008    20.62    0.000
#>     X               0.982      0.036    27.07    0.000
#>     Z               1.015      0.038    26.98    0.000
#>    .Y               0.980      0.037    25.90    0.000
#> 
# }