melissagwolf / dynamic

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

Ordered items for likertHB #15

Closed rduesing closed 2 weeks ago

rduesing commented 2 weeks ago

Hello!

I tried the newly implemented option to get DFI cutoffs for ordinal data with the WLSMV estimator. But I encountered some strange warnings, which I wanted to share, because I am not entirely sure if all went correctly under the hood.

I wanted to fit a four factorial ordinal model:

sem1 <- 'F1=~ Y33 + Y40 + Y10 + Y04
F2=~ Y44 + Y24 + Y22 + Y06
F3=~ Y03 + Y43 + Y28 + Y17
F4=~ Y42 + Y14 + Y23'

I tried two methods to tell R/lavaan that my items are ordinal, either within the lavaan cfa() command:

fit1 <- lavaan::cfa(model=sem1, data=data_rd, estimator="WLSMV",
                    ordered=c("Y33","Y40","Y10","Y04",
                              "Y44","Y24","Y22","Y06",
                              "Y03","Y43","Y28", "Y17",
                              "Y42","Y14","Y23")
)

or directly change the data frame:

data_o[,c("Y33","Y40","Y10","Y04",
          "Y44","Y24","Y22","Y06",
          "Y03","Y43","Y28", "Y17",
          "Y42","Y14","Y23")] <-
  lapply(data_o[,c("Y33","Y40","Y10","Y04",
                   "Y44","Y24","Y22","Y06",
                   "Y03","Y43","Y28", "Y17",
                   "Y42","Y14","Y23")], ordered)

fit1.1 <- lavaan::cfa(model=sem1, data=data_o, estimator="WLSMV")

If I use the likertHB function, I get warnings for both approaches:

dynamic::likertHB(fit1, data = data_rd,   plot=T, estimator="WLSMV")

lavaan->lav_options_est_dwls(): estimator “DWLS” is not recommended for continuous data. Did you forget to set the ordered= argument?

and with the second approach with ordered data frame:

dynamic::likertHB(fit1.1, data = data_o,   plot=T, estimator="WLSMV")

only defined on a data frame with all numeric-alike variables

Since I apparently set the "ordered=" argument, I am puzzled about this warnings. Any help is appreciated.

Best, Rainer

dmcneish18 commented 2 weeks ago

The likertHB and likertOne functions are intended for Likert-type items that are treated as continuous. Using a model that treats items are categorical with ordered= is the reason for the errors because the input is incongruent with what the function is expecting. If your model is treating the Likert-type items as categorical (i.e., the model has ordered=), then the appropriate function would be either catHB or catOne, which are designed to handle models with thresholds.

The README has been updated to clarify the difference between the two functions.