https://github.com/cran/mirtCAT
Tip revision: 3367c299773bc798f195a633da0b9949b76f9e03 authored by Phil Chalmers on 10 July 2020, 03:50:03 UTC
version 1.10
version 1.10
Tip revision: 3367c29
generate.mirt_object.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/generate.mirt_object.R
\name{generate.mirt_object}
\alias{generate.mirt_object}
\title{Generate a mirt object from population parameters}
\usage{
generate.mirt_object(
parameters,
itemtype,
latent_means = NULL,
latent_covariance = NULL,
key = NULL,
min_category = rep(0L, length(itemtype))
)
}
\arguments{
\item{parameters}{a matrix or data.frame of parameters corresponding to the model definitions
listed in \code{\link{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 \code{NA}'s as placeholders}
\item{itemtype}{a character vector indicating the type of item with which the parameters
refer. See the \code{itemtype} argument in \code{\link{mirt}}. Note that this input
is only used to determine the relevant item class for the rows in \code{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}
\item{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}
\item{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)}
\item{key}{scoring key required for nested-logit models. See \code{\link{mirt}} for details}
\item{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
\code{K - 1}}
}
\description{
This function generates a \code{mirt} object from known population parameters, which is
then passed to \code{\link{mirtCAT}} for running CAT applications.
}
\examples{
\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)
}
}
\references{
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory
Package for the R Environment. \emph{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. \emph{Journal of Statistical Software, 71}(5),
1-39. \doi{10.18637/jss.v071.i05}
}
\seealso{
\code{\link{mirt}}, \code{\link{mirtCAT}}, \code{\link{generate_pattern}}
}
\author{
Phil Chalmers \email{rphilip.chalmers@gmail.com}
}