| extract.mirtCAT {mirtCAT} | R Documentation |
Extract elements from the internal person, test, and design objects
Description
This function extracts elements, as well as builds a few convenient elements,
from the three internal person, design, or test
objects that are accessible through a customNextItem function
definition (see mirtCAT for details).
Usage
extract.mirtCAT(x, what)
Arguments
x |
either the |
what |
a character vector extracting the desired element (see the Details section) |
Details
Depending on which object is supplied, the following elements can be extracted.
The 'person' argument
IDa scalar value indicating the ID of the participant (generally only needed in Monte Carlo simulations)
responsesan integer vector indicating how items that have been responded to. Each element pertains to the associated item location (e.g.,
responses[100]is associated with the 100th item), and isNAif the item has not been responded toraw_responsesof the same form as
responses, pertaining to the observed responses in a character vectoritems_in_bankan integer vector indicating items which have not been administered yet and are also valid candidates for administration
items_answeredan integer vector indicating the order in which items have been responded to
thetasthe current ability/latent trait estimates given the previously administered items
thetas_SEthe current ability/latent trait standard error estimates given the previously administered items
thetas_historyhistory of the ability/latent trait estimates
thetas_SE_historyhistory of the latent trait standard error estimates
item_timeof the same form as
items_answered, pertaining to the amount of time it took the participant to response to the itemdemographicsa data.frame containing the (optional) prior survey information from the GUI interface
clientDataa list of useful information from shiny's
session$clientData
The 'design' argument
items_not_scoredan integer vector indicating items which should be included but not scored in the test (these are experimental items)
min_itemsminimum number of items to administer
max_itemsmaximum number of items to administer
max_timemaximum amount of time alloted to the GUI
met_SEMlogical vector indicating whether the SEM criteria has been met
met_delta_thetaslogical vector indicating whether the delta_thetas criteria has been met
met_classifylogical vector indicating whether the classify criteria has been met
exposureexposure control elements of the same form as
responsescontentcontent constraint information
content_propcontent proportions
test_propertiesuser-defined
data.frameof test-based propertiesperson_propertiesuser-defined
data.frameof person-based properties
The 'test' argument
moextract the defined model from the
mirtpackage. Afterward, users can use theextract.mirtfunction to pull out a large number of internal elements for easy use
Author(s)
Phil Chalmers rphilip.chalmers@gmail.com
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. doi:10.18637/jss.v048.i06
Chalmers, R. P. (2016). Generating Adaptive and Non-Adaptive Test Interfaces for Multidimensional Item Response Theory Applications. Journal of Statistical Software, 71(5), 1-39. doi:10.18637/jss.v071.i05
See Also
mirt, mirtCAT, extract.mirt,
findNextItem
Examples
## Not run:
#example test
set.seed(1234)
nitems <- 25
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, TOL = .01)
# simple math items
questions <- answers <- character(nitems)
choices <- matrix(NA, nitems, 5)
spacing <- floor(d - min(d)) + 1 #easier items have more variation in the options
for(i in 1:nitems){
n1 <- sample(1:50, 1)
n2 <- sample(51:100, 1)
ans <- n1 + n2
questions[i] <- paste0(n1, ' + ', n2, ' = ?')
answers[i] <- as.character(ans)
ch <- ans + sample(c(-5:-1, 1:5) * spacing[i,], 5)
ch[sample(1:5, 1)] <- ans
choices[i, ] <- as.character(ch)
}
df <- data.frame(Question=questions, Option=choices,
Type = 'radio', stringsAsFactors = FALSE)
df$Answer <- answers
pat <- generate_pattern(mod, Theta = 0, df)
#------------------------------------------------
# administer items in sequence
customNextItem <- function(person, design, test){
# browser()
items_left_2_choose_from <- extract.mirtCAT(person, 'items_in_bank')
min(items_left_2_choose_from)
}
res <- mirtCAT(df, local_pattern=pat,
design = list(customNextItem=customNextItem))
summary(res)
#------------------------------------------------
# administer items in order, but stop after 10 items
customNextItem <- function(person, design, test){
items_left_2_choose_from <- extract.mirtCAT(person, 'items_in_bank')
items_answered <- extract.mirtCAT(person, 'items_answered')
total <- sum(!is.na(items_answered))
ret <- if(total < 10) min(items_left_2_choose_from)
else return(NA)
ret
}
res <- mirtCAT(df, local_pattern=pat,
design = list(customNextItem=customNextItem))
summary(res)
#------------------------------------------------
# using findNextItem() and stopping after 10 items
customNextItem <- function(person, design, test){
items_answered <- extract.mirtCAT(person, 'items_answered')
total <- sum(!is.na(items_answered))
ret <- NA
if(total < 10)
ret <- findNextItem(person=person, test=test, design=design, criteria = 'MI')
ret
}
res <- mirtCAT(df, mod, local_pattern=pat, start_item = 'MI',
design = list(customNextItem=customNextItem))
summary(res)
# equivalent to the following
res2 <- mirtCAT(df, mod, local_pattern=pat, start_item = 'MI',
criteria = 'MI', design = list(max_items = 10))
summary(res2)
## End(Not run)