Given the programming code and variable/object assignment in the function cfa_meas_inv(), the end of line 67 should return "mod_mi=mod0, mod_pi=mod2" as part of the list object, rather than "mod_mi=mod0, mod_pi=mod1" as is currently the case.
Explanation:
During the "while (free)"-loop, the objects partable1 and mimod1 get updated until hitting the final (tested) partial MI model. However, the last lavaan-object is not stored in object mod1, but in mod2 (see line 50). Thus, returning mod_pi as mod1 at the end of the function returns the full MI model (mod1 = mod_mi; see line 26) rather than the last (tested/accepted) partial MI model (mod2 = mod_pi).
Consequently, when comparing the model parameters via pars_mi and pars_pi, any model differences are evident (and the function appears functional). However, when further exploring model fit and model parameters straight from the returned lavaan-object mod_pi - e.g., with summary(mod$mod_pi, standardized = TRUE, fit.measures = TRUE - , then the reported mod_pi is incorrectlyidentical to mod_mi.
File Name: cfa_meas_inv.R
File Version: 0.157
Given the programming code and variable/object assignment in the function cfa_meas_inv(), the end of line 67 should return "mod_mi=mod0, mod_pi=mod2" as part of the list object, rather than "mod_mi=mod0, mod_pi=mod1" as is currently the case.
Explanation: During the "while (free)"-loop, the objects partable1 and mimod1 get updated until hitting the final (tested) partial MI model. However, the last lavaan-object is not stored in object mod1, but in mod2 (see line 50). Thus, returning mod_pi as mod1 at the end of the function returns the full MI model (mod1 = mod_mi; see line 26) rather than the last (tested/accepted) partial MI model (mod2 = mod_pi).
Consequently, when comparing the model parameters via pars_mi and pars_pi, any model differences are evident (and the function appears functional). However, when further exploring model fit and model parameters straight from the returned lavaan-object mod_pi - e.g., with summary(mod$mod_pi, standardized = TRUE, fit.measures = TRUE - , then the reported mod_pi is incorrectly identical to mod_mi.
mb