philchalmers / mirt

Multidimensional item response theory
https://philchalmers.github.io/mirt/
201 stars 75 forks source link

Error when using response.pattern in fscores #195

Closed alisonandrew closed 4 years ago

alisonandrew commented 4 years ago

Hi Phil, I'm getting an error that I can't understand when using the response.pattern option in fscores. I'm trying to predict ML scores for all respondents in a data frame (some who were used to estimate the MIRT model, some not). When I try to predict the scores for the whole data frame, I get this error:

Error in [<-(*tmp*, , itemloc[i] + j - 1L, value = as.integer(tabdata2[, :

subscript out of bounds

However, when I try to predict the scores for the same data frame but split it up into smaller segments, it works fine.

Here is my code:

mod_sel <- mirt(items_sel_cont,1,'graded', method='EM', technical=list(NCYCLES =2000,removeEmptyRows=TRUE))

this gives the error: theta_all <- fscores(mod_sel, method='ML',response.pattern=items_sel, append_response.pattern=FALSE)

this works fine: theta1 <- fscores(mod_sel, method='ML',response.pattern=items_sel[1:300,], append_response.pattern=FALSE) theta2 <- fscores(mod_sel, method='ML',response.pattern=items_sel[301:800,], append_response.pattern=FALSE) theta3 <- fscores(mod_sel, method='ML',response.pattern=items_sel[801:900,], append_response.pattern=FALSE) theta4 <- fscores(mod_sel, method='ML',response.pattern=items_sel[901:1075,], append_response.pattern=FALSE) theta_sel <- rbind(theta1, theta2, theta3, theta4)

Do you have any ideas how to proceed?

Thanks so much!

philchalmers commented 4 years ago

It's possible this is a bug, though I'd need more information to confirm if this crash was expected or not (in any event, a better error message should be printed). Could you provide a reproducible example of this behaviour? If your data is too sensitive to post publicly feel free to email me directly.