Skip to contents

This function generates a mirt object from known population parameters, which is then passed to mirtCAT for running CAT applications.

Usage

generate.mirt_object(
  parameters,
  itemtype,
  latent_means = NULL,
  latent_covariance = NULL,
  key = NULL,
  min_category = rep(0L, length(itemtype))
)

Arguments

parameters

a matrix or data.frame of parameters corresponding to the model definitions listed in mirt. Each row represents a unique item, while the column names correspond to the respective parameter names. If a parameter is not relevant for a particular item/row then use NA's as placeholders

itemtype

a character vector indicating the type of item with which the parameters refer. See the itemtype argument in mirt. Note that this input is only used to determine the relevant item class for the rows in parameters, therefore many inputs are interchangeable (e.g., '2PL' generates the same internal model object as '3PL'). If only a single value is provided then all items types will be assumed identical

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 mirt for details

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 K - 1

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

Author

Phil Chalmers rphilip.chalmers@gmail.com

Examples

if (FALSE) { # \dontrun{

### 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)

} # }