philchalmers / mirt

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

SingleGroup one-factor model plots twice using plot(..., type = "trace", facet_items = FALSE) #197

Closed netique closed 3 years ago

netique commented 3 years ago

In previous version of mirt (e.g. 1.32.1), when I plot the tracelines for the simple IRT model (say Rasch with one group, one factor, dichotomous items, no NAs), without faceting, the result is a plot with single panel showing probabilities raising with theta (assuming the probability of endorsing correct response grows with the testee ability). In version 1.33.2, however, two panels appears in the plot, one as expected and the other reversed along x-axis.

I suspect that the issue raises from this line of code. When I do not want faceting, the drop2 argument is effectively unused. https://github.com/philchalmers/mirt/blob/197088364961b65f27a3b1ba6c0cffc5cb12184d/R/SingleGroup-methods.R#L1235

philchalmers commented 3 years ago

The change was deliberate to better manage tests with a mix of two and three or more categories per item, but I agree the situation where all items have only two categories then a further reduction should made in the output. I've reverted this effect but preserved the new behaviour; see below for examples after installing the fix. Thanks.

devtools::install_github('philchalmers/mirt')
library(mirt)
dat <- Science
dat[,1] <- ifelse(Science[,1] == 3, 1, 0)
dat[,2] <- ifelse(Science[,2] == 3, 1, 0)
dat[,3] <- ifelse(Science[,3] == 3, 1, 0)
mod <- mirt(dat, 1, "Rasch")
plot(mod, type = 'trace', facet_items = TRUE)
plot(mod, type = 'trace', facet_items = FALSE)

library(mirt)
dat <- expand.table(LSAT6)
mod <- mirt(dat, 1, "Rasch")
plot(mod, type = 'trace', facet_items = TRUE)
plot(mod, type = 'trace', facet_items = FALSE)