# \donttest{
itemstats(SAT12, use_ts = FALSE)
# score the data (missing scored as 0)
head(SAT12)
dat <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
head(dat)
itemstats(dat)
# score the data, missing (value of 8) treated as NA
SAT12missing <- SAT12
SAT12missing[SAT12missing == 8] <- NA
dat <- key2binary(SAT12missing,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
head(dat)
# potentially better scoring for item 32 (based on nominal model finding)
dat <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,3))
# fit 2PL model to each item
mod <- mirt(dat)
plot(mod)
itemfit(mod)
# fit monotonic spline model to items 4 through 6 to improve fit
itemtype <- rep('2PL', 32)
itemtype[4:6] <- 'monospline'
mod_mspline <- mirt(dat, itemtype = itemtype)
anova(mod, mod_mspline)
plot(mod, which.items=4:6, type = 'trace')
plot(mod_mspline, which.items=4:6, type = 'trace')
# }
Run the code above in your browser using DataLab