Closed beamgau closed 8 years ago
problem had to do with the classes of the cols in the dataframe!
i ran into the same problem again... the issue is that one needs to specify the slots for the arguments in the measurementinvariancecat() call... e.g. measurementinvariancecat(data = ..., model = ...)
Can you provide a script that reproduces the issue you are trying to describe?
sure:
library(mirt)
library(semTools)
mod = "fac =~ Comfort + Work + Future + Benefit"
Science$g = 1:2
measurementInvarianceCat(mod, Science, ordered = names(Science), group = "g")
##Error in parTable$plabel[element[1]] : invalid subscript type 'list'
measurementInvarianceCat(model = mod, data = Science, ordered = names(Science), group = "g")
## works
When you do not name your arguments, R will assume the first object is the first argument, the second object is the second argument, etc. The first arguments to measurementInvarianceCat() are not called "model" and "data" as they are in the lavaan/cfa/sem/growth functions. The (...) argument passes objects to the cfa() function to define a model template and to the lavaan() function to actually fit the models to the data. In order to be certain the arguments are passed properly, you need to name the arguments. That is why your syntax works when you name the arguments.
Your particular error is a result of measurementInvarianceCat() defining the number of groups by checking the element "data" in the list of (...) objects, which doesn't exist if you don't name it. I will change that to define the number of groups from the model template, but I would still recommend you name the arguments you want to pass to lavaan(). It is just better/safer style.
thanks for the explanation! it was hard to track down the issue :+1:
hi,
there seems to be a problem within measurementInvarianceCat(), specifically with constrainParTable... i get the following error: error in parTable$user[element[1]] <- 1 : invalid indextype 'list'
would be great if you could look into this, example below!
best, felix
library(mirt) mod = "fac =~ Comfort + Work + Future + Benefit" Science$g = 1:2 measurementInvarianceCat(mod, Science, ordered = names(Science), group = "g") traceback()