I try to run a constrained DIF-model in package version 1.33.2, here a minimal example:
mydata <- expand.table(LSAT6)mygroup <- factor(rbinom(nrow(mydata), 1, .5))mymodel <- mirt.model("F = 1-5\n CONSTRAINB = (1-3, a1), (1-3, d)")mymgest <- multipleGroup(mydata, mymodel, mygroup, itemtype = "2PL", invariance = c("free_mean", "free_variance"))DIF(mymgest, c("a1", "d"))
The last command terminates with an error:
Error in model$x[, 1L] : incorrect number of dimensions
I inspected this error and identified that in file "DIF.R" in line 179 occurs in this case an unintended conversion:
mirt_model$x <- mirt_model$x[mirt_model$x[,"Type"] != 'CONSTRAINB', ]
Since it only remains one line in the model definition after deleting CONSTRAINB, R automatically converts the object into a vector which leads to the error in the call of "multipleGroup" in line 215.
Adding an additional (useless) line in the model definition fixes the problem, e.g.:
mymodel <- mirt.model("F = 1-5\n FREE = (1-5, a1), (1-5, d)\n CONSTRAINB = (1-3, a1), (1-3, d)")
So I assume that the reason for the error is (at least) the identified one.
Can you please fix this in an upcoming version, e.g. by changing line 179 to:
mirt_model$x <- mirt_model$x[mirt_model$x[,"Type"] != 'CONSTRAINB', , drop = F]
or give me an advice why I am not allowed to estimate DIF for the defined model?
Hi Phil,
I try to run a constrained DIF-model in package version 1.33.2, here a minimal example:
mydata <- expand.table(LSAT6)
mygroup <- factor(rbinom(nrow(mydata), 1, .5))
mymodel <- mirt.model("F = 1-5\n CONSTRAINB = (1-3, a1), (1-3, d)")
mymgest <- multipleGroup(mydata, mymodel, mygroup, itemtype = "2PL", invariance = c("free_mean", "free_variance"))
DIF(mymgest, c("a1", "d"))
The last command terminates with an error:
Error in model$x[, 1L] : incorrect number of dimensions
I inspected this error and identified that in file "DIF.R" in line 179 occurs in this case an unintended conversion:
mirt_model$x <- mirt_model$x[mirt_model$x[,"Type"] != 'CONSTRAINB', ]
Since it only remains one line in the model definition after deleting CONSTRAINB, R automatically converts the object into a vector which leads to the error in the call of "multipleGroup" in line 215.
Adding an additional (useless) line in the model definition fixes the problem, e.g.:
mymodel <- mirt.model("F = 1-5\n FREE = (1-5, a1), (1-5, d)\n CONSTRAINB = (1-3, a1), (1-3, d)")
So I assume that the reason for the error is (at least) the identified one.
Can you please fix this in an upcoming version, e.g. by changing line 179 to:
mirt_model$x <- mirt_model$x[mirt_model$x[,"Type"] != 'CONSTRAINB', , drop = F]
or give me an advice why I am not allowed to estimate DIF for the defined model?Kind regards, Stefan.