simsem / semTools

Useful tools for structural equation modeling
74 stars 36 forks source link

nullRMSEA incorrect name inside function #36

Closed maugavilla closed 6 years ago

maugavilla commented 6 years ago

Hi

I found a bug in the nullRMSEA function. For this is that the moreFitIndices was giving me problems

The function calls lavaan::lav_partable_independence(fit), where it should be lavaan::lav_partable_independence(object). So, the moreFitIndices function works with the example code because the example code creates an lavaan object called "fit", keeps using the same object called fit instead of the given lavaan object

Sorry, I didnt make it a pull request, still havent got to learn to use github to those features

nullRMSEA function (object, scaled = FALSE, silent = FALSE) { fit <- update(object, model = lavaan::lav_partable_independence(fit)) ### chage fit for object fits <- lavaan::fitMeasures(fit, fit.measures = c("rmsea", "rmsea.scaled", "rmsea.robust")) if (scaled) { RMSEA <- fits["rmsea.robust"] if (is.na(RMSEA)) RMSEA <- fits["rmsea.scaled"] if (is.na(RMSEA)) RMSEA <- fits["rmsea"] } else RMSEA <- fits["rmsea"] if (!silent) { cat("The baseline model's RMSEA =", RMSEA, "\n\n") if (RMSEA < 0.158) { cat("CFI, TLI, and other incremental fit indices may not be very", "informative because the baseline model's RMSEA < 0.158", "(Kenny, Kaniskan, & McCoach, 2015). \n") } } invisible(RMSEA) }

TDJorgensen commented 6 years ago

Thanks for catching this! I made the change, it will be available in the next version.