simsem / semTools

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

Estimator ML for ordered data is not supported yet. Use WLSMV instead. #37

Closed pableres closed 5 years ago

pableres commented 6 years ago

Hello, I am runing an invariance.

my sintaxis is as follows: mi_invar <- 'ASF =~ a_3+ a_6 + a_9+ a_10 + a_12 + a_20 + a_22 + a_23 ASS =~ a_11+ a_13 + a_14+ a_16 + a_18 + a_21 + a_25 + a_26 a_3 ~~ a_12 a_6 ~~ a_10 a_20 ~~ a_23 a_13 ~~ a_18 a_14 ~~ a_25 a_16 ~~ a_21'

mi_edad <- semTools::measurementInvarianceCat(model=mi_invar,estimator="wlsmv", group = "edad", orthogonal=FALSE, data=Inv_auto_1, ordered = c("a_3", "a_6", "a_9", "a_10", "a_12", "a_20", "a_22", "a_23","a_11", "a_13", "a_14","a_16", "a_18", "a_21", "a_25", "a_26"),4)

I am getting the following trouble: Error in lav_options_set(opt) : lavaan ERROR: estimator ML for ordered data is not supported yet. Use WLSMV instead.

Wich is kind of weird because I was able to run this exactly sintaxis perhaps 3 weeks ago, without problems.

I have update lavaan and semTools (as you have previously suggest ... ) install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source") devtools::install_github("simsem/semTools/semTools")

I have go back to R 3.4.4 were this package was created, I have also updated RStudio (just in case). but something has changed. There is a difference in the code that may give you a cue I used mi_edad <- semTools::measurementInvarianceCat(mi_invar,estimator="wlsmv"

and a change is now need. To: mi_edad <- semTools::measurementInvarianceCat(model=mi_invar,estimator="wlsmv" maybe this will give a cue all lavaan() and lavOptions() arguments must named, including the "model=" argument. ¿¿any help??

TDJorgensen commented 6 years ago

In this code:

mi_edad <- semTools::measurementInvarianceCat(model=mi_invar,estimator="wlsmv", group = "edad", orthogonal=FALSE, data=Inv_auto_1, ordered = c("a_3", "a_6", "a_9", "a_10", "a_12", "a_20", "a_22", "a_23","a_11", "a_13", "a_14","a_16", "a_18", "a_21", "a_25", "a_26"),4)

I'm not sure what you are trying to do with the last argument (un-named)"4. Does the error occur when you take that out?

Naming every argument is correct (including model). These issues should have been resolved in the latest software. semTools is now on CRAN, so you can install that normally with the latest version of R.

install.packages("semTools") # version 0.5-0
install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source") # 0.6-2.1276

You can check your sessionInfo() output to make sure the loaded packages are the latest versions. If you still get an error, please send me a reproducible example with data so I can track down the problem.

pableres commented 6 years ago

Thank you so much.

I have no idea why I put that "4" there. Maybe for 4 decimals??? I cannot remember!!! but still same problema with and witout it. Lavaan version used: lavaan_0.6-2.1276 semTools_0.5-0

umhh old version of R (3.4.4) is installed now, but I was using a modern one. Let my try in a computer in the university. It has to be some update because it worked 3 weeks ago.
But here you have data as well, sintaxis descriptions are in Spanish, but I think it wont be a problem.

Invarianza autoreferida Carlos.zip

pableres commented 6 years ago

Mhhh, no is not working neither in my university. Last versions of R, Rstudio, packages... Invarainza Atoreferida.zip

TDJorgensen commented 6 years ago

Your syntax file did not import any data, so I assumed this was all I needed to do:

library(foreign)
Inv_auto <- read.spss("../Desktop/Inv_auto_1.sav", to.data.frame = TRUE,
                      use.value.labels = FALSE)
Inv_auto_1 <- Inv_auto

The first example syntax you sent me still included the meaningless 4 argument, and still did not name the model= argument, which I explained in my previous post was necessary. The function works fine after you corrected your syntax, as in the second syntax you sent me. I'm using R 3.5.0, but that shouldn't matter as long as the same versions of the packages are installed. I'm using the same versions of lavaan and semTools you are, and the syntax does not give me an error, except where it should for the partialInvariance() function, which is designed only for continuous indicators.

pableres commented 6 years ago

¿?¿?¿?I do not know. It does not run in my machine. I have also add the model:

mi_edad <- semTools::measurementInvarianceCat(model=mi_invar,estimator="wlsmv", group = "edad", orthogonal=FALSE, data=Inv_auto_1, ordered = c("a_3", "a_6", "a_9", "a_10", "a_12", "a_20", "a_22", "a_23","a_11", "a_13", "a_14","a_16", "a_18", "a_21", "a_25", "a_26")) Let me, unistall and retry. Now is something I am doing wrong.

TDJorgensen commented 6 years ago

When I said partialInvariance() only works for continuous indicators, I forgot to mention that there is a partialInvarianceCat() function for the categorical case.

Also, there is no need to specify orthogonal=FALSE or estimator="wlsmv" because those will be specified by default. It should not affect anything, just shorten your syntax.