if (FALSE) {
set.seed(1)
nitems <- 100
itemnames <- paste0('Item.', 1:nitems)
a <- matrix(rlnorm(nitems, .2, .3))
d <- matrix(rnorm(nitems))
dat <- simdata(a, d, 500, itemtype = 'dich')
colnames(dat) <- itemnames
mod <- mirt(dat, 1, verbose = FALSE)
# test defined in mirtCAT help file, first example
CATdesign <- mirtCAT(mo = mod, criteria = 'MI', design_elements = TRUE,
start_item = 2)
# returns 2 in this case, since that was the starting item
findNextItem(CATdesign)
# first iteration, no answered items
CATdesign$person$items_answered
# update when next item is item 2 and answered correctly
CATdesign <- updateDesign(CATdesign, new_item = 2, new_response = 1)
CATdesign$person$items_answered # item 2 answered first
CATdesign$person$responses # in item 2 element response was = 1
CATdesign$person$thetas # current estimate
findNextItem(CATdesign)
# determine next item if item 70 were also answered correctly next
CATdesign <- updateDesign(CATdesign, new_item = 70, new_response = 1)
CATdesign$person$items_answered
CATdesign$person$responses
findNextItem(CATdesign)
# continue on, now with item 95 added next (answered incorrectly)
CATdesign <- updateDesign(CATdesign, new_item = 95, new_response = 0)
CATdesign$person$thetas
CATdesign$person$thetas_history
CATdesign$person$thetas_SE_history
findNextItem(CATdesign)
}
Run the code above in your browser using DataLab