Last data update: 2014.03.03

R: Generate a mirt object from population parameters
generate.mirt_objectR Documentation

Generate a mirt object from population parameters

Description

This function generate a mirt object from known population parameters, which is then passed to mirtCAT function 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 unqiue item, while the column names correspond to the respective parameter names. If a parameter is not relavent for a particular item/row then use NA's as placeholders

itemtype

a character vector indiciating the type of item to which the parameters refer. See the itemtype arguement in mirt. Note that this input is only used to determine the relavent item class for the rows in parameters, therefore many inputs are interchangable (e.g., '2PL' generates the same model 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 centroid

latent_covariance

(optional) a covariance matrix used to define the population variance-covariance structure between the latent traits. By default the relationship is assumed to be standard normal (i.e., and 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 respond suitable for the first category is 0, second is 1, and so on up to K - 1

Author(s)

Phil Chalmers rphilip.chalmers@gmail.com

See Also

mirt, mirtCAT, generate_pattern

Examples

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

Results