Example of how to build a unidimensional CAT simulation with 1000 3PL items and 5000 participants. Sessions are terminated if the standard error of measurement is less than .25, and must contain a minimum of 10 items and a maximum of 50. Item selection is done via the maximum information criteria, while ability estimates are updated with the EAP estimator. Code is executed in parallel to save computation time.
nitems <- 1000
N <- 5000
Theta <- matrix(rnorm(N))
a <- matrix(rlnorm(nitems, .2, .3), nitems)
d <- rnorm(nitems)
pars <- data.frame(a1 = a, d = d, g = 0.2)
mirt_object <- generate.mirt_object(pars, '3PL')
responses <- generate_pattern(mirt_object, Theta = Theta)
library(parallel)
cl <- makeCluster(detectCores())
design <- list(min_SEM = .25, min_items = 10, max_items = 50)
mirtCAT_results <- mirtCAT(mo = mirt_object, local_pattern = responses,
start_item = 'MI', method = 'EAP',
criteria = 'MI', design = design, cl = cl)
plot(mirtCAT_results[[1]])
plot(mirtCAT_results[[2]])
## summarize results
library(plyr)
est.Theta1 <- laply(mirtCAT_results, function(x) x$thetas)
ave_nans <- mean(laply(mirtCAT_results, function(x) length(x$items_answered)))
(r <- cor(Theta[,1], est.Theta1))
(bias <- mean(Theta[,1] - est.Theta1))
(RMSD <- sqrt(mean((Theta[,1] - est.Theta1)^2)))