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 (1.0.12) ended normally after 328 iterations
#> 
#>   Estimator                                        LMS
#>   Optimization method                       EMA-NLMINB
#>   Number of model parameters                        31
#>                                                       
#>   Number of observations                          2000
#>  
#> Loglikelihood and Information Criteria:
#>   Loglikelihood                              -17494.52
#>   Akaike (AIC)                                35051.04
#>   Bayesian (BIC)                              35224.67
#>  
#> 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                          351.02
#>   Difference test (D)                           702.03
#>   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   63.357    0.000
#>     x3              0.910      0.014   66.726    0.000
#>   Z =~          
#>     z1              1.000                             
#>     z2              0.812      0.012   65.237    0.000
#>     z3              0.883      0.013   67.591    0.000
#>   Y =~          
#>     y1              1.000                             
#>     y2              0.800      0.008  105.852    0.000
#>     y3              0.899      0.008  110.897    0.000
#> 
#> Regressions:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   Y ~           
#>     X               0.671      0.031   21.649    0.000
#>     Z               0.570      0.030   18.821    0.000
#>     X:Z             0.717      0.028   25.876    0.000
#> 
#> Intercepts:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .x1              1.023      0.024   42.681    0.000
#>    .x2              1.211      0.020   60.452    0.000
#>    .x3              0.917      0.022   41.343    0.000
#>    .z1              1.011      0.024   41.507    0.000
#>    .z2              1.203      0.020   58.957    0.000
#>    .z3              0.916      0.022   41.968    0.000
#>    .y1              1.038      0.033   31.463    0.000
#>    .y2              1.220      0.027   45.271    0.000
#>    .y3              0.953      0.030   31.791    0.000
#> 
#> Covariances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>   X ~~          
#>     Z               0.199      0.024    8.196    0.000
#> 
#> Variances:
#>                  Estimate  Std.Error  z.value  P(>|z|)
#>    .x1              0.157      0.009   17.895    0.000
#>    .x2              0.161      0.007   22.750    0.000
#>    .x3              0.165      0.008   20.227    0.000
#>    .z1              0.167      0.009   18.486    0.000
#>    .z2              0.159      0.007   22.440    0.000
#>    .z3              0.158      0.008   20.620    0.000
#>    .y1              0.160      0.009   17.839    0.000
#>    .y2              0.154      0.007   22.181    0.000
#>    .y3              0.165      0.008   20.459    0.000
#>     X               0.982      0.036   26.920    0.000
#>     Z               1.015      0.038   26.839    0.000
#>    .Y               0.980      0.038   26.085    0.000
#> 
# }