library(MplusReadR)
library(MplusAutomation)
#> Warning: package 'MplusAutomation' was built under R version 4.0.3
#> Version:  0.8
#> We work hard to write this free software. Please help us get credit by citing: 
#> 
#> Hallquist, M. N. & Wiley, J. F. (2018). MplusAutomation: An R Package for Facilitating Large-Scale Latent Variable Analyses in Mplus. Structural Equation Modeling, 25, 621-638. doi: 10.1080/10705511.2017.1402334.
#> 
#> -- see citation("MplusAutomation").

Checking Models Convergence

You can check whether each model in a list of Mplus models converged using mplus_converge(). This checks whether the model contains confidence intervals, as non-converged models will not.

# Load the data
bivariate_models <- readModels('bivariate_models', recursive = TRUE)
# Check model convergence
converged <- mplus_converge(bivariate_models)
list_number file_name dataset_title converged
1 bivariate_models.1_panaVAR_SWL.out Dejonckheere 2019 reanalysis 1_DEJON2017; FALSE
2 bivariate_models.10_panaVAR_SWL.out Dejonckheere 2019 reanalysis 10_SCHMI; TRUE
3 bivariate_models.11_panaVAR_SWL.out Dejonckheere 2019 reanalysis 11_SELS2017; TRUE
4 bivariate_models.12_panaVAR_SWL.out Dejonckheere 2019 reanalysis 12_SELS2018; TRUE
5 bivariate_models.15_panaVAR_SWL.out Dejonckheere 2019 reanalysis 15_VANDE; FALSE
6 bivariate_models.2_panaVAR_SWL.out Dejonckheere 2019 reanalysis 2_DEJON2018; TRUE
7 bivariate_models.3_panaVAR_SWL.out Dejonckheere 2019 reanalysis 3_HEINI; TRUE
8 bivariate_models.5_panaVAR_SWL.out Dejonckheere 2019 reanalysis 5_KOVAL; TRUE
9 bivariate_models.6_panaVAR_SWL.out Dejonckheere 2019 reanalysis 6_PEW1; TRUE
10 bivariate_models.7_panaVAR_SWL.out Dejonckheere 2019 reanalysis 7_PEW2; TRUE
11 bivariate_models.8_panaVAR_SWL.out Dejonckheere 2019 reanalysis 8_PEW3; TRUE

Removing Non-converged Models

Non-converged models in a list of Mplus output can be removed using mplus_remove_converge().

new_models <- mplus_remove_converge(bivariate_models)
  • Number of models before removal of non-converged models: 11
  • Number of models after removal of non-converged models: 9

Non-converged models are removed automatically when model output is compiled using mplus_compile(). If there were any non-converged models, a warning will be displayed, as shown below.

mplus_compile(bivariate_models)
#> It appears 2 models did not converge. These were removed. Run mplus_converge(Mplus_file) to check these.

You can prevent automatic removal of non-converged models using converged = FALSE. However, if the output contains any non-converged models, not removing them will prevent the compilation of the model output.