melissagwolf / dynamic

Dynamic Fit Index Cutoffs For Latent Variable Models
GNU Affero General Public License v3.0
14 stars 2 forks source link

MLR estimator not producing any results different from the ML estimator #10

Closed WillemSleegers closed 1 year ago

WillemSleegers commented 1 year ago

Hi,

I was happy to see that the cfaHb() function now has support for various estimators, so I tried it out. Specifically, I tried out the following code:

library(dynamic)

dat <- lavaan::HolzingerSwineford1939
lavmod <- "F1 =~ x1 + x2 + x3
           F2 =~ x4 + x5 + x6
           F3 =~ x7 + x8 + x9"
fit <- lavaan::cfa(lavmod, dat)
cfaHB(fit, reps = 1)
lavaan::fitmeasures(fit, c("chisq", "df", "pvalue", "srmr", "rmsea", "cfi"))

fit_r <- lavaan::cfa(lavmod, dat, estimator = "MLR")
cfaHB(fit_r, reps = 1, estimator = "MLR")
lavaan::fitmeasures(
  fit_r,
  c(
    "chisq.scaled", "df.scaled", "pvalue.scaled", "srmr", "rmsea.robust",
    "cfi.robust"
  )
)

I expected the results of the two cfaHB() calls to differ, but they seem to be identical. In fact, the cfaHB() call with estimator = "MLR" is returning the exact same fit measure values as the default one, even though it should be returning the scaled/robust versions of the fit measures (if I understand correctly).

Am I missing something or is there a bug here?

melissagwolf commented 1 year ago

You should use nnorHB not cfaHB. See the tutorial here: https://rpubs.com/dmcneish/1033222.

WillemSleegers commented 1 year ago

Why does that function have an estimator argument then?

melissagwolf commented 1 year ago

~The GitHub version is currently in beta and we're testing some things out~. cfaHB can accommodate other estimators, but nnorHB is the correct function to use if you have non-normal, continuous data. cfaHB still uses simstandard to simulate multivariate normal data (see #5), so it won't be useful if you want to use the MLR estimator. Note that for non-normal data, you will need to use a lavaan object or your dataset as the input.

WillemSleegers commented 1 year ago

Thanks for that. I think as a user I find that quite confusing (also see this tweet, which added to my confusion).

dmcneish18 commented 1 year ago

Conceptually, MLR = cML where c is correction factor for non-normality. cfaOne and cfaHB generate from normal distributions, in which case c=1 because there is no non-normality. So MLR = ML in these functions. The functions are* using MLR as indicated by that tweet, there is just no difference between MLR and ML with the type of data being generated by these functions.

If it makes it less confusing, I added a warning error message about MLR with functions that simulate from a normal distribution to inform users that MLR = ML with these functions and that the nnor group of functions may be more useful if the goal is to derive cutoffs that are sensitive to non-normality.

WillemSleegers commented 1 year ago

Thanks; I think an error is useful.

melissagwolf commented 1 year ago

Thanks for the helpful feedback as always @WillemSleegers! We've added a few clarifying messages for other estimators as well. Please continue to let us know if you run into bugs or something is unclear - we really appreciate it.