if (FALSE) {
### build a unidimensional test with all 3PL items
nitems <- 50
a1 <- rlnorm(nitems, .2,.2)
d <- rnorm(nitems)
g <- rbeta(nitems, 20, 80)
pars <- data.frame(a1=a1, d=d, g=g)
head(pars)
obj <- generate.mirt_object(pars, '3PL')
coef(obj, simplify = TRUE)
plot(obj, type = 'trace')
### build a two-dimensional test
## all graded items with 5 response categories
nitems <- 30
as <- matrix(rlnorm(nitems*2, .2, .2), nitems)
diffs <- t(apply(matrix(runif(nitems*4, .3, 1), nitems), 1, cumsum))
diffs <- -(diffs - rowMeans(diffs))
ds <- diffs + rnorm(nitems)
pars2 <- data.frame(as, ds)
colnames(pars2) <- c('a1', 'a2', paste0('d', 1:4))
head(pars2)
obj <- generate.mirt_object(pars2, 'graded')
coef(obj, simplify = TRUE)
### unidimensional mixed-item test
library(plyr)
pars3 <- rbind.fill(pars, pars2) #notice the NA's where parameters do not exist
obj <- generate.mirt_object(pars3, itemtype = c(rep('2PL', 50), rep('graded', 30)))
coef(obj)
itemplot(obj, 51)
itemplot(obj, 1, drop.zeros=TRUE)
}
Run the code above in your browser using DataLab