I am trying to simulate a response pattern from the IRT graded response model, using the mirt
package. However, when I use the simdata
function, it gives me the following error:
Error in sample.int(length(x), size, replace, prob): too few positive probabilities
The dataset I am trying to simulate is unidimensional, and each of the 40 items has 5 categories. Here is the code I wrote:
set.seed(1)
true.abilities <- matrix(c(rnorm(1000)), 1000)
set.seed(1)
a <- matrix(c(runif(40, 0.6, 1.9)), 40)
set.seed(3)
b <- matrix(c(rnorm(40*4)), 40)
b <- t(apply(b, 1, sort, decreasing=FALSE)) #sort since intercepts are ordered
Form.X <- simdata(a, b, 1000, Theta=true.abilities, itemtype='graded')
There was another similar question about this, but the answers didn't help me. I also found a code for simulating multidimensional graded response pattern, and it worked, but my code, for the unidimensional model, doesn't work.
Any ideas on how to fix this? Thank you!