I'm trying to use the mirt
package in R
to simulate responses from a multidimensional item response model, via the simdata()
function.
In the jstat article introducing the package simulated data are used to illustrate the confmirt()
function, and the code used to produce the simulated data is presented in Appendix B, as
library(mirt)
a <- matrix(c(1.5, NA, 0.5, NA, 1, NA, 1, 0.5, NA, 1.5, NA, 0.5,
NA, 1, NA, 1), ncol = 2, byrow = TRUE)
d <- matrix(c(-1, NA, NA, -1.5, NA, NA, 1.5, NA, NA, 0, NA, NA,
3, 2, -0.5, 2.5, 1, -1, 2, 0, NA, 1, NA, NA),
ncol = 3, byrow = TRUE)
sigma <- diag(2)
sigma[1, 2] <- sigma[2, 1] <- 0.4
simdata2 <- simdata(a, d, 2000, sigma)
This doesn't work, because the simdata()
function has since been updated, and now requires the item type be specified. However, when I try to amend the code by specifying the item type as dichotomous, simdata2 <- simdata(a, d, 2000, "dich", sigma)
, the function still will not run for me, and I get the error noted in the title Error in sample.int(length(x), size, replace, prob): too few positive probabilities
.
I tried to dig into this to try to understand what was going on, but was unsuccessful. If I could understand what was causing the error it would help me to avoid it when I try to create my own simulated dataset (in my initial trials, I did receive this same error). The questions asked here was similar, but I was still unable to diagnose exactly what was causing the error.
Thanks in advance.