Title: | Computerized Adaptive Testing with Multidimensional Item Response Theory |
---|---|
Description: | Provides tools to generate HTML interfaces for adaptive and non-adaptive tests using the shiny package (Chalmers (2016) <doi:10.18637/jss.v071.i05>). Suitable for applying unidimensional and multidimensional computerized adaptive tests (CAT) using item response theory methodology and for creating simple questionnaires forms to collect response data directly in R. Additionally, optimal test designs (e.g., "shadow testing") are supported for tests that contain a large number of item selection constraints. Finally, package contains tools useful for performing Monte Carlo simulations for studying test item banks. |
Authors: | Phil Chalmers [aut, cre] , Magnus Nordmo [ctb] |
Maintainer: | Phil Chalmers <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.14 |
Built: | 2024-11-10 06:19:50 UTC |
Source: | CRAN |
Computerized Adaptive Testing with Multidimensional Item Response Theory
Provides tools to generate an HTML interface for creating adaptive and non-adaptive educational and psychological tests using the shiny package. Suitable for applying unidimensional and multidimensional computerized adaptive tests using item response theory methodology and for creating simple questionnaires forms to collect response data directly in R.
Users interested in the most recent version of this package can visit https://github.com/philchalmers/mirtCAT and follow the instructions for installing the package from source (additional details about installing from Github can be found at https://github.com/philchalmers/mirt). Questions regarding the package can be sent to the mirt-package Google Group, located at https://groups.google.com/forum/#!forum/mirt-package.
Phil Chalmers [email protected]
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
A function that returns a named vector of evaluated criteria for each respective item in the test bank. The names are associated with the item number in the bank. Note that criteria values are returned such that the maximum value always represents the most optimal item (e.g., maximum information). In cases where the minimum value is typically selected (e.g., minimum variance) all values are multiplied by -1 to turn it into a maximization problem.
computeCriteria( x, criteria, person = NULL, test = NULL, design = NULL, subset = NULL, info_mats = FALSE )
computeCriteria( x, criteria, person = NULL, test = NULL, design = NULL, subset = NULL, info_mats = FALSE )
x |
an object of class 'mirtCAT_design' returned from the |
criteria |
item selection criteria (see |
person |
(required when |
test |
(required when |
design |
(required when |
subset |
an integer vector indicating which items should be included in the optimal search;
the default |
info_mats |
logical; if more than one trait is present in the test, should the respective information matricies be returned instead of the scalar summary statistics (e.g., D-rule). When TRUE will return a list of matricies associated with each respective item |
a vector of criteria values for each respective item
Phil Chalmers [email protected]
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
mirtCAT
, updateDesign
, extract.mirtCAT
,
findNextItem
## Not run: # test defined in mirtCAT help file, first example CATdesign <- mirtCAT(df, mod, design_elements = TRUE) computeCriteria(CATdesign, criteria = 'MI') computeCriteria(CATdesign, criteria = 'MEI') ## End(Not run)
## Not run: # test defined in mirtCAT help file, first example CATdesign <- mirtCAT(df, mod, design_elements = TRUE) computeCriteria(CATdesign, criteria = 'MI') computeCriteria(CATdesign, criteria = 'MEI') ## End(Not run)
This is used in mirtCAT
to create a random session name so that
shiny
knows which environment to select objects from when multiple CAT
sessions have been initialized.
createSessionName(n = 30, datetime = TRUE)
createSessionName(n = 30, datetime = TRUE)
n |
number of upper/lower characters to sample |
datetime |
logical; include the current date/time the function was called in the string as well? This further helps with the uniqueness of the generated string |
a list containing the internal environmental components for mirtCAT
This function returns the GUI setup results by calling shinyApp
.
Primarily, this is only useful when hosting the application publicly, such as
through https://www.shinyapps.io/. The function mirtCAT_preamble
must be
run before this function is called. The object is executed by calling runApp
.
createShinyGUI(ui = NULL, host_server = TRUE)
createShinyGUI(ui = NULL, host_server = TRUE)
ui |
a shiny UI function used to define the interface. If |
host_server |
logical; is |
Phil Chalmers [email protected]
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
mirtCAT
, mirtCAT_preamble
, getPerson
## Not run: mirtCAT_preamble(df=df) runApp(createShinyGUI(host_server = FALSE), port = 8000) # run locally person <- getPerson() summary(person) runApp(createShinyGUI(), port = 8000) # for remote server hosting ## End(Not run)
## Not run: mirtCAT_preamble(df=df) runApp(createShinyGUI(host_server = FALSE), port = 8000) # run locally person <- getPerson() summary(person) runApp(createShinyGUI(), port = 8000) # for remote server hosting ## End(Not run)
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).
extract.mirtCAT(x, what)
extract.mirtCAT(x, what)
x |
either the |
what |
a character vector extracting the desired element (see the Details section) |
Depending on which object is supplied, the following elements can be extracted.
ID
a scalar value indicating the ID of the participant (generally only needed in Monte Carlo simulations)
responses
an 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 is NA
if the item has not been responded to
raw_responses
of the same form as responses
, pertaining to the observed responses
in a character vector
items_in_bank
an integer vector indicating items which have not been administered yet and are also valid candidates for administration
items_answered
an integer vector indicating the order in which items have been responded to
thetas
the current ability/latent trait estimates given the previously administered items
thetas_SE
the current ability/latent trait standard error estimates given the previously administered items
thetas_history
history of the ability/latent trait estimates
thetas_SE_history
history of the latent trait standard error estimates
item_time
of the same form as items_answered
, pertaining to the amount of time it took the
participant to response to the item
demographics
a data.frame containing the (optional) prior survey information from the GUI interface
clientData
a list of useful information from shiny's session$clientData
items_not_scored
an integer vector indicating items which should be included but not scored in the test (these are experimental items)
min_items
minimum number of items to administer
max_items
maximum number of items to administer
max_time
maximum amount of time alloted to the GUI
met_SEM
logical vector indicating whether the SEM criteria has been met
met_delta_thetas
logical vector indicating whether the delta_thetas criteria has been met
met_classify
logical vector indicating whether the classify criteria has been met
exposure
exposure control elements of the same form as responses
content
content constraint information
content_prop
content proportions
test_properties
user-defined data.frame
of test-based properties
person_properties
user-defined data.frame
of person-based properties
mo
extract the defined model from the mirt
package. Afterward, users can use the
extract.mirt
function to pull out a large number of internal elements for easy use
Phil Chalmers [email protected]
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
mirt
, mirtCAT
, extract.mirt
,
findNextItem
## 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)
## 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)
A function that returns the next item in the computerized adaptive, optimal assembly, or shadow test.
For direction manipulation of the internal objects this function should be used in conjunction
with the updateDesign
and customNextItem
.
Finally, the raw input forms can be used when a customNextItem
function has been
defined in mirtCAT
.
findNextItem( x, person = NULL, test = NULL, design = NULL, criteria = NULL, objective = NULL, subset = NULL, all_index = FALSE, ... )
findNextItem( x, person = NULL, test = NULL, design = NULL, criteria = NULL, objective = NULL, subset = NULL, all_index = FALSE, ... )
x |
an object of class 'mirtCAT_design' returned from the |
person |
(required when |
test |
(required when |
design |
(required when |
criteria |
item selection criteria (see |
objective |
a vector of values used as the optimization criteria to be passed to
|
subset |
an integer vector indicating which items should be included in the optimal search;
the default |
all_index |
logical; return all items instead of just the most optimal?
When |
... |
additional arguments to be passed to |
When a numeric objective
is supplied the next item in the computerized adaptive test is found via
an integer solver through searching for a maximum. The raw input forms can be used
when a customNextItem
function has been defined in mirtCAT
, and requires
the definition of a constr_fun
(see the associated element in mirtCAT
for details,
as well as the examples below). Can be used to for 'Optimal Test Assembly',
as well as 'Shadow Testing' designs (van der Linden, 2005),
by using the lp
function. When objective
is not supplied the result follows the
typical maximum criteria of more standard adaptive tests.
typically returns an integer value indicating the index of the next item to be selected or a
value of NA
to indicate that the test should be terminated. However, see the arguments for
further returned object descriptions
Phil Chalmers [email protected]
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
van der Linden, W. J. (2005). Linear models for optimal test design. Springer.
mirtCAT
, updateDesign
, extract.mirtCAT
## Not run: # test defined in mirtCAT help file, first example # equivalent to criteria = 'MI' customNextItem <- function(design, person, test){ item <- findNextItem(person=person, design=design, test=test, criteria = 'MI') item } 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) # 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) response <- generate_pattern(mod, 1) result <- mirtCAT(mo=mod, local_pattern = response, design = list(customNextItem=customNextItem)) ----------------------------------------------------------- # direct manipulation of internal objects CATdesign <- mirtCAT(df=df, mo=mod, criteria = 'MI', design_elements = TRUE) # returns number 1 in this case, since that's the starting item findNextItem(CATdesign) # determine next item if item 1 and item 10 were answered correctly CATdesign <- updateDesign(CATdesign, new_item = 1, new_response = 1) extract.mirtCAT(CATdesign$person, 'thetas') # updated thetas CATdesign <- updateDesign(CATdesign, new_item = 10, new_response = 1) extract.mirtCAT(CATdesign$person, 'thetas') # updated thetas again findNextItem(CATdesign) findNextItem(CATdesign, all_index = TRUE) # all items rank in terms of most optimal #------------------------------------------------------------- ## Integer programming example (e.g., shadow testing) # find maximum information subject to constraints # sum(xi) <= 5 ### 5 or fewer items # x1 + x2 <= 1 ### items 1 and 2 can't be together # x4 == 0 ### item 4 not included # x5 + x6 == 1 ### item 5 or 6 must be included, but not both # constraint function constr_fun <- function(design, person, test){ # left hand side constrains # - 1 row per constraint, and ncol must equal number of items mo <- extract.mirtCAT(test, 'mo') nitems <- extract.mirt(mo, 'nitems') lhs <- matrix(0, 4, nitems) lhs[1,] <- 1 lhs[2,c(1,2)] <- 1 lhs[3, 4] <- 1 lhs[4, c(5,6)] <- 1 # relationship direction dirs <- c("<=", "<=", '==', '==') #right hand side rhs <- c(5, 1, 0, 1) #all together constraints <- data.frame(lhs, dirs, rhs) constraints } CATdesign <- mirtCAT(df=df, mo=mod, design_elements = TRUE, design = list(constr_fun=constr_fun)) # MI criteria value associated with each respective item objective <- computeCriteria(CATdesign, criteria = 'MI') # most optimal item, given constraints findNextItem(CATdesign, objective=objective) # all the items which solve the problem findNextItem(CATdesign, objective=objective, all_index = TRUE) ## within a customNextItem() definition the above code would look like # customNextItem <- function(design, person, test){ # objective <- computeCriteria(person=person, design=design, test=test, # criteria = 'MI') # item <- findNextItem(person=person, design=design, test=test, # objective=objective) # item # } ## End(Not run)
## Not run: # test defined in mirtCAT help file, first example # equivalent to criteria = 'MI' customNextItem <- function(design, person, test){ item <- findNextItem(person=person, design=design, test=test, criteria = 'MI') item } 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) # 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) response <- generate_pattern(mod, 1) result <- mirtCAT(mo=mod, local_pattern = response, design = list(customNextItem=customNextItem)) ----------------------------------------------------------- # direct manipulation of internal objects CATdesign <- mirtCAT(df=df, mo=mod, criteria = 'MI', design_elements = TRUE) # returns number 1 in this case, since that's the starting item findNextItem(CATdesign) # determine next item if item 1 and item 10 were answered correctly CATdesign <- updateDesign(CATdesign, new_item = 1, new_response = 1) extract.mirtCAT(CATdesign$person, 'thetas') # updated thetas CATdesign <- updateDesign(CATdesign, new_item = 10, new_response = 1) extract.mirtCAT(CATdesign$person, 'thetas') # updated thetas again findNextItem(CATdesign) findNextItem(CATdesign, all_index = TRUE) # all items rank in terms of most optimal #------------------------------------------------------------- ## Integer programming example (e.g., shadow testing) # find maximum information subject to constraints # sum(xi) <= 5 ### 5 or fewer items # x1 + x2 <= 1 ### items 1 and 2 can't be together # x4 == 0 ### item 4 not included # x5 + x6 == 1 ### item 5 or 6 must be included, but not both # constraint function constr_fun <- function(design, person, test){ # left hand side constrains # - 1 row per constraint, and ncol must equal number of items mo <- extract.mirtCAT(test, 'mo') nitems <- extract.mirt(mo, 'nitems') lhs <- matrix(0, 4, nitems) lhs[1,] <- 1 lhs[2,c(1,2)] <- 1 lhs[3, 4] <- 1 lhs[4, c(5,6)] <- 1 # relationship direction dirs <- c("<=", "<=", '==', '==') #right hand side rhs <- c(5, 1, 0, 1) #all together constraints <- data.frame(lhs, dirs, rhs) constraints } CATdesign <- mirtCAT(df=df, mo=mod, design_elements = TRUE, design = list(constr_fun=constr_fun)) # MI criteria value associated with each respective item objective <- computeCriteria(CATdesign, criteria = 'MI') # most optimal item, given constraints findNextItem(CATdesign, objective=objective) # all the items which solve the problem findNextItem(CATdesign, objective=objective, all_index = TRUE) ## within a customNextItem() definition the above code would look like # customNextItem <- function(design, person, test){ # objective <- computeCriteria(person=person, design=design, test=test, # criteria = 'MI') # item <- findNextItem(person=person, design=design, test=test, # objective=objective) # item # } ## End(Not run)
Generate a CAT pattern given various inputs. Returns a character vector or numeric matrix
(depending on whether a df
input was supplied) with columns equal to the test size and
rows equal to the number of rows in Theta
. For simulation studies, supplying a
Theta
input with more than 1 row will generate a matrix of responses for
running independent CAT session when passed to mirtCAT(..., local_pattern)
. When
the returned object is an integer vector then the Theta
values will be stored
as an attribute 'Theta'
to be automatically used in Monte Carlo simulations.
generate_pattern(mo, Theta, df = NULL)
generate_pattern(mo, Theta, df = NULL)
mo |
single group object defined by the |
Theta |
a numeric vector indicating the latent theta values for a single person |
df |
(optional) data.frame object containing questions, options, and scoring
keys. See |
Phil Chalmers [email protected]
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
## Not run: # return real response vector given choices and (optional) answers pat <- generate_pattern(mod, Theta = 0, df=df) # mirtCAT(df, mo=mod, local_pattern = pat) # generate single pattern observed in dataset used to define mod pat2 <- generate_pattern(mod, Theta = 0) # mirtCAT(mo=mod, local_pattern = pat2) # generate multiple patterns to be analyzed independently pat3 <- generate_pattern(mod, Theta = matrix(c(0, 2, -2), 3)) # mirtCAT(mo=mod, local_pattern = pat3) ## End(Not run)
## Not run: # return real response vector given choices and (optional) answers pat <- generate_pattern(mod, Theta = 0, df=df) # mirtCAT(df, mo=mod, local_pattern = pat) # generate single pattern observed in dataset used to define mod pat2 <- generate_pattern(mod, Theta = 0) # mirtCAT(mo=mod, local_pattern = pat2) # generate multiple patterns to be analyzed independently pat3 <- generate_pattern(mod, Theta = matrix(c(0, 2, -2), 3)) # mirtCAT(mo=mod, local_pattern = pat3) ## End(Not run)
This function generates a mirt
object from known population parameters, which is
then passed to mirtCAT
for running CAT applications.
generate.mirt_object( parameters, itemtype, latent_means = NULL, latent_covariance = NULL, key = NULL, min_category = rep(0L, length(itemtype)) )
generate.mirt_object( parameters, itemtype, latent_means = NULL, latent_covariance = NULL, key = NULL, min_category = rep(0L, length(itemtype)) )
parameters |
a matrix or data.frame of parameters corresponding to the model definitions
listed in |
itemtype |
a character vector indicating the type of item with which the parameters
refer. See the |
latent_means |
(optional) a numeric vector used to define the population latent mean structure. By default the mean structure is centered at a 0 vector |
latent_covariance |
(optional) a matrix used to define the population variance-covariance structure between the latent traits. By default the relationship is assumed to be orthogonal standard normal (i.e., an identity matrix) |
key |
scoring key required for nested-logit models. See |
min_category |
the value representing the lowest category index. By default this is 0,
therefore the response suitable for the first category is 0, second is 1, and so on up to
|
Phil Chalmers [email protected]
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
mirt
, mirtCAT
, generate_pattern
## Not run: ### 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) ## End(Not run)
## Not run: ### 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) ## End(Not run)
This function is used to access the internal state of the mirtCAT GUI session.
It is only useful when designing a customized GUI using the shinyGUI$ui
input to mirtCAT
.
get_mirtCAT_env(sessionName)
get_mirtCAT_env(sessionName)
sessionName |
the name of the session defined in |
a list containing the internal environmental components for mirtCAT
This function returns a suitable person object identical to the result returned by mirtCAT
,
and is only required when the GUI is launched by the createShinyGUI
method.
getPerson()
getPerson()
Phil Chalmers [email protected]
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
mirtCAT
, mirtCAT_preamble
, createShinyGUI
## Not run: mirtCAT_preamble(df=df) runApp(createShinyGUI(), port = 8000) person <- getPerson() summary(person) ## End(Not run)
## Not run: mirtCAT_preamble(df=df) runApp(createShinyGUI(), port = 8000) person <- getPerson() summary(person) ## End(Not run)
Provides tools to generate an HTML interface for creating adaptive and
non-adaptive educational and psychological tests using the shiny
package.
Suitable for applying unidimensional and multidimensional computerized adaptive tests
using item response theory methodology. Test scoring is performed using the mirt
package.
However, if no scoring is required (i.e., a standard survey) then defining a mirt
object may be omitted.
mirtCAT( df = NULL, mo = NULL, method = "MAP", criteria = "seq", start_item = 1, local_pattern = NULL, AnswerFuns = list(), design_elements = FALSE, cl = NULL, progress = FALSE, primeCluster = TRUE, customTypes = list(), design = list(), shinyGUI = list(), preCAT = list(), ... ) ## S3 method for class 'mirtCAT' print(x, ...) ## S3 method for class 'mirtCAT' summary(object, sort = TRUE, ...) ## S3 method for class 'mirtCAT' plot( x, pick_theta = NULL, true_thetas = TRUE, SE = 1, main = NULL, par.strip.text = list(cex = 0.7), par.settings = list(strip.background = list(col = "#9ECAE1"), strip.border = list(col = "black")), scales = list(x = list(rot = 90)), ... )
mirtCAT( df = NULL, mo = NULL, method = "MAP", criteria = "seq", start_item = 1, local_pattern = NULL, AnswerFuns = list(), design_elements = FALSE, cl = NULL, progress = FALSE, primeCluster = TRUE, customTypes = list(), design = list(), shinyGUI = list(), preCAT = list(), ... ) ## S3 method for class 'mirtCAT' print(x, ...) ## S3 method for class 'mirtCAT' summary(object, sort = TRUE, ...) ## S3 method for class 'mirtCAT' plot( x, pick_theta = NULL, true_thetas = TRUE, SE = 1, main = NULL, par.strip.text = list(cex = 0.7), par.settings = list(strip.background = list(col = "#9ECAE1"), strip.border = list(col = "black")), scales = list(x = list(rot = 90)), ... )
df |
a
|
mo |
single group object defined by the |
method |
argument passed to |
criteria |
adaptive criteria used, default is to administer each item sequentially
using Possible inputs for unidimensional adaptive tests include: Possible inputs for multidimensional adaptive tests include: Applicable to both unidimensional and multidimensional tests are the
Non-adaptive methods applicable even when no |
start_item |
two possible inputs to determine the starting item are available.
Passing a number will indicate the specific item to be used as the start item;
default is 1, which selects the first item in the defined test/survey.
If a character string is passed then the item will be selected from one of
the item selections criteria available (see the |
local_pattern |
a character/numeric matrix of response patterns
used to run the CAT application without generating the GUI interface.
This option requires complete response pattern(s) to be supplied. |
AnswerFuns |
a list with the length equal to the number of items in the item bank consisting
of user-defined functions. These functions are used to determine whether a given
response obtained from the GUI is 'correct' or 'incorrect' by returning a logical scalar value,
while For example, the following provides a customized response function for the first item. AnswerFuns <- as.list(rep(NA, nrow(df))) AnswerFuns[[1]] <- function(input) input == '10' || to.lower(input) == 'ten' |
design_elements |
logical; return an object containing the test, person, and design
elements? Primarily this is to be used with the |
cl |
an object definition to be passed to the parallel package
(see |
progress |
logical; print a progress bar to the console
with the |
primeCluster |
logical; when a |
customTypes |
an optional list input containing functions for Designing Original Graphical Stimuli (DOGS).
DOGS elements in the input list must contain a unique name, and the item with which it is associated must be
declared in the a myDOGS <- function(inputId, df_row) ... and must return, at the very minimum, an associated The following is a simple example of DOGS for a true-false question and how it is passed: good_dogs <- function(inputId, df_row){ return(list(h2('This statement is false'), radioButtons(inputId = inputId, label='', choices = c('True', 'False'), selected = '') )) } df <- data.frame(Question = '', ..., Type = 'Doug') results <- mirtCAT(df=df, customTypes = list(Doug = good_dogs)) IMPORTANT: When using the custom inputs the select defined |
design |
a list of design based control parameters for adaptive and non-adaptive tests. These can be
|
shinyGUI |
a list of GUI based parameters to be over-written. These can be
|
preCAT |
a list object which can be used to specify a pre-CAT block in which
different test properties may be applied prior to beginning the CAT session. If the
list is empty, no preCAT block will be used. All of the following elements are required
to use the
|
... |
additional arguments to be passed to |
x |
object of class |
object |
object of class |
sort |
logical; sort the response patterns based on the order they were administered? If FALSE, the raw response patterns containing NAs will be returned for items that were not administered |
pick_theta |
a number indicating which theta to plot (only applicable for multidimensional
tests). The default is to facet each theta on one plot, but to plot only the first factor pass
|
true_thetas |
logical; include a horizontal line indicating where the population-level theta values are? Only applicable to Monte Carlo simulations because this value would not be known otherwise |
SE |
size of the standard errors to plot. The default is 1, and therefore plots the
standard error. To obtain the 95% interval use |
main |
title of the plot. Will default to |
par.strip.text |
plotting argument passed to |
par.settings |
plotting argument passed to |
scales |
plotting argument passed to |
All tests will stop once the 'min_SEM'
criteria has been reached or classification
above or below the specified cutoffs can be made. If all questions should
be answered, users should specify an extremely small 'min_SEM'
or, equivalently,
a large 'min_items'
criteria to the design
list input.
Returns a list object of class 'Person'
containing the following elements:
raw_responses
A character vector indicating the raws responses to the respective items, where NA indicates the item was not answered
scored_responses
An integer vector of scored responses if the item_answers
input
was used for each respective item
items_answered
An integer vector indicating the order in which the items were answered
thetas
A numeric vector indicating the final theta estimates
SE_thetas
A numeric vector indicating the standard errors of the final theta estimates
thetas_history
A matrix indicating the progression of updating the theta values during the test
thetas_SE_history
A matrix indicating the standard errors for theta after each successive item was answered
item_time
A numeric vector indicating how long the respondent took to answer each question (in seconds)
demographics
A data.frame object containing the information collected on the first page of the shiny GUI. This is used to store the demographic information for each participant
classification
A character vector indicating whether the traits could be classified as 'above' or 'below' the desired cutoffs
To access examples, vignettes, and exercise files that have been generated with knitr
please
visit https://github.com/philchalmers/mirtCAT/wiki.
design
object directly through customNextItem()
(advanced)In addition to providing a completely defined item-selection map via the customNextItem()
function,
users may also wish to control some of the more fine-grained elements of the design
object to adjust
the general control parameters of the CAT (e.g., modifying the maximum number of items to administer, stopping
the CAT if something peculiar has been detected in the response patterns, etc). Note that
this feature is rarely required for most applications, though more advanced users may wish to
modify these various low-level elements of the design
object directly to change the flow of the CAT
to suit their specific needs.
While the person
object is defined as a Reference Class
(see setRefClass
)
the design object is generally considered a fixed S4 class, meaning that, unlike the person
object,
it's elements are not mutable. Therefore, in order to make changes directly to the
design
object the users should follow these steps:
Within the defined customNextItem
function, the design
object slots are first modified (e.g.,
design@max_items <- 20L
).
Along with the desired next item scalar value from customNextItem()
, the scalar object should also
contain an attribute with the name 'design'
which holds the newly defined design
object
(e.g., attr(ret, 'design') <- design; return(ret)
).
Following the above process the work-flow in mirtCAT
will use the new design
object in place of the
old one, even in Monte Carlo simulations.
Phil Chalmers [email protected]
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
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
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
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
generate_pattern
, generate.mirt_object
,
extract.mirtCAT
, findNextItem
, computeCriteria
## Not run: ### unidimensional scored example with generated items # create mo from estimated parameters set.seed(1234) nitems <- 50 itemnames <- paste0('Item.', 1:nitems) a <- matrix(rlnorm(nitems, .2, .3)) d <- matrix(rnorm(nitems)) dat <- simdata(a, d, 1000, itemtype = 'dich') mod <- mirt(dat, 1) coef(mod, simplify=TRUE) # alternatively, define mo from population values (not run) pars <- data.frame(a1=a, d=d) mod2 <- generate.mirt_object(pars, itemtype='2PL') coef(mod2, simplify=TRUE) # 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) head(df) (res <- mirtCAT(df)) #collect response only (no scoring or estimating thetas) summary(res) # include scoring by providing Answer key df$Answer <- answers (res_seq <- mirtCAT(df, mod)) #sequential scoring (res_random <- mirtCAT(df, mod, criteria = 'random')) #random (res_MI <- mirtCAT(df, mod, criteria = 'MI', start_item = 'MI')) #adaptive, MI starting item summary(res_seq) summary(res_random) summary(res_MI) #----------------------------------------- # HTML tags for better customization, coerced to characters for compatibility # help(tags, package='shiny') options <- matrix(c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"), nrow = 3, ncol = 5, byrow = TRUE) shinyStems <- list(HTML('Building CATs with mirtCAT is difficult.'), div(HTML('mirtCAT requires a'), br(), HTML('substantial amount of coding.')), div(strong('I would use'), HTML('mirtCAT in my research.'))) questions <- sapply(shinyStems, as.character) df <- data.frame(Question=questions, Option = options, Type = "radio", stringsAsFactors=FALSE) res <- mirtCAT(df) res #----------------------------------------- # run locally, random response pattern given Theta set.seed(1) pat <- generate_pattern(mod, Theta = 0, df=df) head(pat) # seq scoring with character pattern for the entire test (adjust min_items) res <- mirtCAT(df, mod, local_pattern=pat, design = list(min_items = 50)) summary(res) # same as above, but using special input vector that doesn't require df input set.seed(1) pat2 <- generate_pattern(mod, Theta = 0) head(pat2) print(mirtCAT(mo=mod, local_pattern=pat2)) # run CAT, and save results to object called person (start at 10th item) person <- mirtCAT(df, mod, item_answers = answers, criteria = 'MI', start_item = 10, local_pattern = pat) print(person) summary(person) # plot the session plot(person) #standard errors plot(person, SE=1.96) #95 percent confidence intervals #----------------------------------------- ### save response object to temp directory in case session ends early wdf <- paste0(getwd(), '/temp_file.rds') res <- mirtCAT(df, mod, shinyGUI = list(temp_file = wdf)) # resume test this way if test was stopped early (and temp files were saved) res <- mirtCAT(df, mod, shinyGUI = list(temp_file = wdf)) print(res) ## End(Not run)
## Not run: ### unidimensional scored example with generated items # create mo from estimated parameters set.seed(1234) nitems <- 50 itemnames <- paste0('Item.', 1:nitems) a <- matrix(rlnorm(nitems, .2, .3)) d <- matrix(rnorm(nitems)) dat <- simdata(a, d, 1000, itemtype = 'dich') mod <- mirt(dat, 1) coef(mod, simplify=TRUE) # alternatively, define mo from population values (not run) pars <- data.frame(a1=a, d=d) mod2 <- generate.mirt_object(pars, itemtype='2PL') coef(mod2, simplify=TRUE) # 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) head(df) (res <- mirtCAT(df)) #collect response only (no scoring or estimating thetas) summary(res) # include scoring by providing Answer key df$Answer <- answers (res_seq <- mirtCAT(df, mod)) #sequential scoring (res_random <- mirtCAT(df, mod, criteria = 'random')) #random (res_MI <- mirtCAT(df, mod, criteria = 'MI', start_item = 'MI')) #adaptive, MI starting item summary(res_seq) summary(res_random) summary(res_MI) #----------------------------------------- # HTML tags for better customization, coerced to characters for compatibility # help(tags, package='shiny') options <- matrix(c("Strongly Disagree", "Disagree", "Neutral", "Agree", "Strongly Agree"), nrow = 3, ncol = 5, byrow = TRUE) shinyStems <- list(HTML('Building CATs with mirtCAT is difficult.'), div(HTML('mirtCAT requires a'), br(), HTML('substantial amount of coding.')), div(strong('I would use'), HTML('mirtCAT in my research.'))) questions <- sapply(shinyStems, as.character) df <- data.frame(Question=questions, Option = options, Type = "radio", stringsAsFactors=FALSE) res <- mirtCAT(df) res #----------------------------------------- # run locally, random response pattern given Theta set.seed(1) pat <- generate_pattern(mod, Theta = 0, df=df) head(pat) # seq scoring with character pattern for the entire test (adjust min_items) res <- mirtCAT(df, mod, local_pattern=pat, design = list(min_items = 50)) summary(res) # same as above, but using special input vector that doesn't require df input set.seed(1) pat2 <- generate_pattern(mod, Theta = 0) head(pat2) print(mirtCAT(mo=mod, local_pattern=pat2)) # run CAT, and save results to object called person (start at 10th item) person <- mirtCAT(df, mod, item_answers = answers, criteria = 'MI', start_item = 10, local_pattern = pat) print(person) summary(person) # plot the session plot(person) #standard errors plot(person, SE=1.96) #95 percent confidence intervals #----------------------------------------- ### save response object to temp directory in case session ends early wdf <- paste0(getwd(), '/temp_file.rds') res <- mirtCAT(df, mod, shinyGUI = list(temp_file = wdf)) # resume test this way if test was stopped early (and temp files were saved) res <- mirtCAT(df, mod, shinyGUI = list(temp_file = wdf)) print(res) ## End(Not run)
This is largely an internal function called by mirtCAT
, however it is made
public for better use with external web-hosting interfaces (like shinyapps.io).
For more information see https://shiny.rstudio.com/articles/persistent-data-storage.html for
further information about saving output remotely when using shiny
.
mirtCAT_preamble(..., final_fun = NULL)
mirtCAT_preamble(..., final_fun = NULL)
... |
arguments passed to |
final_fun |
a function called just before the shiny GUI has been terminated, primarily for
saving results externally with packages such as |
Phil Chalmers [email protected]
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
mirtCAT
, createShinyGUI
, getPerson
## Not run: mirtCAT_preamble(df = df) ## End(Not run)
## Not run: mirtCAT_preamble(df = df) ## End(Not run)
A function that will update the object returned from findNextItem
. This can
be used to run the CAT session manually in a set-by-step manner.
updateDesign(x, new_item, new_response, updateTheta = TRUE)
updateDesign(x, new_item, new_response, updateTheta = TRUE)
x |
an object of class 'mirtCAT_design' returned from the |
new_item |
a numeric vector indicating which items to select |
new_response |
a numeric vector indicating the responses the the selected items |
updateTheta |
logical; update the internal ability terms after the new item response has been added to the internal objects? |
returns an object of class 'mirtCAT_design' with updated elements.
Phil Chalmers [email protected]
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
## Not run: 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) ## End(Not run)
## Not run: 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) ## End(Not run)