michaelhallquist / MplusAutomation

The MplusAutomation package leverages the flexibility of the R language to automate latent variable model estimation and interpretation using Mplus, a powerful latent variable modeling program developed by Muthen and Muthen (www.statmodel.com). Specifically, MplusAutomation provides routines for creating related groups of models, running batches of models, and extracting and tabulating model parameters and fit statistics.
81 stars 46 forks source link

Multiple imputation issues #174

Open sda030 opened 1 year ago

sda030 commented 1 year ago

I thought I would never use imputation given that FIML is more convenient and offers the same features. However, in face of comlicated models (4+ latent variables, multigroup, ordinal observed), it became the only option. Here are some issues I found:

  1. The argument "DATAIMPUTATION" is missing, as has been reported but closed 7 years ago (https://github.com/michaelhallquist/MplusAutomation/issues/24). The hack works well though, so not a priority.
  2. Warning message:
    In l_getSavedata_readRawFile(curfile, outfiletext, format = "free",  :
    Unable to locate SAVEDATA files for filename: imputed_*.dat

    Mplus takes the asterisk as a placeholder for the number of the draw. A quick fix should be something like below.

    if(grepl("\\*", results$savedata_info$fileName)) {
    results$savedata_info$imputation <- TRUE
    lapply(dir(pattern = results$savedata_info$fileName), function(imp_file) {
     l_getSavedata_readRawFile(...
    }
    }

    (Sorry, I have not developed this fully, I find a PR for this package a bit intimidating)

example_imputation.zip