Mi̇rt Manual
Mi̇rt Manual
Mi̇rt Manual
URL https://github.com/philchalmers/mirt,
https://github.com/philchalmers/mirt/wiki,
https://groups.google.com/forum/#!forum/mirt-package
1
2 R topics documented:
BugReports https://github.com/philchalmers/mirt/issues?state=open
RoxygenNote 6.0.1
NeedsCompilation yes
Author Phil Chalmers [aut, cre, cph],
Joshua Pritikin [ctb],
Alexander Robitzsch [ctb],
Mateusz Zoltak [ctb],
KwonHyun Kim [ctb],
Carl F. Falk [ctb],
Adam Meade [ctb],
Lennart Schneider [ctb],
David King [ctb],
Chen-Wei Liu [ctb],
Ogreden Oguzhan [ctb]
Date/Publication 2018-08-12 04:40:03 UTC
R topics documented:
mirt-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
anova-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
areainfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
averageMI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
bfactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Bock1997 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
boot.LR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
boot.mirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
coef-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
createGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
createItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
deAyala . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
DIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
DiscreteClass-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
draw_parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
DRF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
DTF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
empirical_ES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
empirical_plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
empirical_rxx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
estfun.AllModelClass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
expand.table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
expected.item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
expected.test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
extract.group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
extract.item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
extract.mirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
fixef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
R topics documented: 3
fscores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
imputeMissing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
itemfit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
itemGAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
iteminfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
itemplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
key2binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
lagrange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
logLik-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
LSAT6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
LSAT7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
M2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
marginal_rxx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
MDIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
mdirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
MDISC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
mirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
mirt.model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
mirtCluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
MixedClass-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
mixedmirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
MixtureClass-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
mod2values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
multipleGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
MultipleGroupClass-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
numerical_deriv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
personfit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
PLCI.mirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
plot-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
poly2dich . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
print-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
print.mirt_df . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
print.mirt_list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
print.mirt_matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
probtrace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
randef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
residuals-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
SAT12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Science . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
show-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
SIBTEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
simdata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
SingleGroupClass-class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
summary-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
testinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
thetaComb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
traditional2mirt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
vcov-method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
4 anova-method
wald . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Index 167
Description
Full information maximum likelihood estimation of multidimensional IRT models
Details
Analysis of dichotomous and polytomous response data using unidimensional and multidimensional
latent trait models under the Item Response Theory paradigm. Exploratory and confirmatory models
can be estimated with quadrature (EM) or stochastic (MHRM) methods. Confirmatory bi-factor and
two-tier analyses are available for modeling item testlets. Multiple group analysis and mixed effects
designs also are available for detecting differential item and test functioning as well as modeling
item and person covariates. Finally, latent class models such as the DINA, DINO, multidimensional
latent class, and several other discrete variable models are supported.
Users interested in the most recent version of this package can visit https://github.com/philchalmers/
mirt and follow the instructions for installing the package from source. Questions regarding the
package can be sent to the mirt-package Google Group, located at https://groups.google.com/
forum/#!forum/mirt-package. User contributed files, workshop files, and evaluated help files
are also available on the package wiki (https://github.com/philchalmers/mirt/wiki).
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Description
Compare nested models using likelihood ratio test (X2), Akaike Information Criterion (AIC), sam-
ple size adjusted AIC (AICc), Bayesian Information Criterion (BIC), Sample-Size Adjusted BIC
(SABIC), and Hannan-Quinn (HQ) Criterion.
anova-method 5
Usage
## S4 method for signature 'SingleGroupClass'
anova(object, object2, bounded = FALSE,
mix = 0.5, verbose = TRUE)
Arguments
object an object of class SingleGroupClass, MultipleGroupClass, or MixedClass
object2 a second model estimated from any of the mirt package estimation methods
bounded logical; are the two models comparing a bounded parameter (e.g., comparing a
single 2PL and 3PL model with 1 df)? If TRUE then a 50:50 mix of chi-squared
distributions is used to obtain the p-value
mix proportion of chi-squared mixtures. Default is 0.5
verbose logical; print additional information to console?
Value
a data.frame/mirt_df object
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1)
x2 <- mirt(Science, 2)
anova(x, x2)
# in isolation
anova(x)
# bounded parameter
dat <- expand.table(LSAT7)
mod <- mirt(dat, 1)
mod2 <- mirt(dat, 1, itemtype = c(rep('2PL', 4), '3PL'))
anova(mod, mod2) #unbounded test
anova(mod, mod2, bounded = TRUE) #bounded
# priors
model <- 'F = 1-5
PRIOR = (5, g, norm, -1, 1)'
mod1b <- mirt(dat, model, itemtype = c(rep('2PL', 4), '3PL'))
anova(mod1b)
## End(Not run)
Description
Compute the area within test or item information over a definite integral range.
Usage
Arguments
Value
a data.frame with the lower and upper integration range, the information area within the range
(Info), the information area over the range -10 to 10 (Total.Info), proportion of total information
given the integration range (Info.Proportion), and the number of items included (nitems)
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
averageMI 7
Examples
## End(Not run)
Description
This function computes updated parameter and standard error estimates using multiple imputation
methodology. Given a set of parameter estimates and their associated standard errors the func-
tion returns the weighted average of the overall between and within variability due to the multiple
imputations according to Rubin’s (1987) methodology.
Usage
averageMI(par, SEpar, as.data.frame = TRUE)
Arguments
par a list containing parameter estimates which were computed the imputed datasets
SEpar a list containing standard errors associated with par
as.data.frame logical; return a data.frame instead of a list? Default is TRUE
Value
returns a list or data.frame containing the updated averaged parameter estimates, standard errors,
and t-values with the associated degrees of freedom and two tailed p-values
8 bfactor
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Rubin, D.B. (1987) Multiple Imputation for Nonresponse in Surveys. Wiley & Sons, New York.
Examples
## Not run:
#simulate data
set.seed(1234)
N <- 1000
# covariates
X1 <- rnorm(N); X2 <- rnorm(N)
covdata <- data.frame(X1, X2)
Theta <- matrix(0.5 * X1 + -1 * X2 + rnorm(N, sd = 0.5))
## End(Not run)
Description
bfactor fits a confirmatory maximum likelihood two-tier/bifactor/testlet model to dichotomous
and polytomous data under the item response theory paradigm. The IRT models are fit using a
dimensional reduction EM algorithm so that regardless of the number of specific factors estimated
the model only uses the number of factors in the second-tier structure plus 1. For the bifactor model
the maximum number of dimensions is only 2 since the second-tier only consists of a ubiquitous
unidimensional factor. See mirt for appropriate methods to be used on the objects returned from
the estimation.
Usage
bfactor(data, model, model2 = paste0("G = 1-", ncol(data)), group = NULL,
quadpts = NULL, invariance = "", ...)
Arguments
data a matrix or data.frame that consists of numerically ordered data, with missing
data coded as NA
model a numeric vector specifying which factor loads on which item. For example, if
for a 4 item test with two specific factors, the first specific factor loads on the
first two items and the second specific factor on the last two, then the vector is
c(1,1,2,2). For items that should only load on the second-tier factors (have
no specific component) NA values may be used as place-holders. These numbers
will be translated into a format suitable for mirt.model(), combined with the
definition in model2, with the letter ’S’ added to the respective factor number
model2 a two-tier model specification object defined by mirt.model() or a string to be
passed to mirt.model. By default the model will fit a unidimensional model in
the second-tier, and therefore be equivalent to the bifactor model
group a factor variable indicating group membership used for multiple group analyses
quadpts number of quadrature nodes to use after accounting for the reduced number
of dimensions. Scheme is the same as the one used in mirt, however it is in
regards to the reduced dimensions (e.g., a bifactor model has 2 dimensions to be
integrated)
invariance see multipleGroup for details, however, the specific factor variances and means
will be constrained according to the dimensional reduction algorithm
... additional arguments to be passed to the estimation engine. See mirt for more
details and examples
Details
bfactor follows the item factor analysis strategy explicated by Gibbons and Hedeker (1992), Gib-
bons et al. (2007), and Cai (2010). Nested models may be compared via an approximate chi-squared
difference test or by a reduction in AIC or BIC (accessible via anova). See mirt for more details
regarding the IRT estimation approach used in this package.
The two-tier model has a specific block diagonal covariance structure between the primary and
secondary latent traits. Namely, the secondary latent traits are assumed to be orthogonal to all traits
10 bfactor
and have a fixed variance of 1, while the primary traits can be organized to vary and covary with
other primary traits in the model.
G 0
Σtwo−tier =
0 diag(S)
The bifactor model is a special case of the two-tier model when G above is a 1x1 matrix, and
therefore only 1 primary factor is being modeled. Evaluation of the numerical integrals for the
two-tier model requires only ncol(G) + 1 dimensions for integration since the S second order (or
’specific’) factors require only 1 integration grid due to the dimension reduction technique.
Note: for multiple group two-tier analyses only the second-tier means and variances should be freed
since the specific factors are not treated independently due to the dimension reduction technique.
Value
function returns an object of class SingleGroupClass (SingleGroupClass-class) or MultipleGroupClass(MultipleGroupCla
class).
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Cai, L. (2010). A two-tier full-information item factor analysis model with applications. Psychome-
trika, 75, 581-612.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Gibbons, R. D., & Hedeker, D. R. (1992). Full-information Item Bi-Factor Analysis. Psychome-
trika, 57, 423-436.
Gibbons, R. D., Darrell, R. B., Hedeker, D., Weiss, D. J., Segawa, E., Bhaumik, D. K., Kupfer, D.
J., Frank, E., Grochocinski, V. J., & Stover, A. (2007). Full-Information item bifactor analysis of
graded response data. Applied Psychological Measurement, 31, 4-19.
See Also
mirt
Examples
## Not run:
summary(mod1)
itemplot(mod1, 18, drop.zeros = TRUE) #drop the zero slopes to allow plotting
#########
# mixed itemtype example
#simulate data
a <- matrix(c(
1,0.5,NA,
1,0.5,NA,
1,0.5,NA,
1,0.5,NA,
1,0.5,NA,
1,0.5,NA,
1,0.5,NA,
1,NA,0.5,
1,NA,0.5,
1,NA,0.5,
1,NA,0.5,
1,NA,0.5,
1,NA,0.5,
1,NA,0.5),ncol=3,byrow=TRUE)
d <- matrix(c(
-1.0,NA,NA,
-1.5,NA,NA,
1.5,NA,NA,
0.0,NA,NA,
2.5,1.0,-1,
3.0,2.0,-0.5,
3.0,2.0,-0.5,
3.0,2.0,-0.5,
2.5,1.0,-1,
2.0,0.0,NA,
-1.0,NA,NA,
12 bfactor
-1.5,NA,NA,
1.5,NA,NA,
0.0,NA,NA),ncol=3,byrow=TRUE)
items <- rep('2PL', 14)
items[5:10] <- 'graded'
#########
# testlet response model
#simulate data
set.seed(1234)
a <- matrix(0, 12, 4)
a[,1] <- rlnorm(12, .2, .3)
ind <- 1
for(i in 1:3){
a[ind:(ind+3),i+1] <- a[ind:(ind+3),1]
ind <- ind+4
}
print(a)
d <- rnorm(12, 0, .5)
sigma <- diag(c(1, .5, 1, .5))
dataset <- simdata(a,d,2000,itemtype=rep('2PL', 12),sigma=sigma)
#########
# Two-tier model
#simulate data
set.seed(1234)
a <- matrix(c(
0,1,0.5,NA,NA,
0,1,0.5,NA,NA,
0,1,0.5,NA,NA,
0,1,0.5,NA,NA,
0,1,0.5,NA,NA,
Bock1997 13
0,1,NA,0.5,NA,
0,1,NA,0.5,NA,
0,1,NA,0.5,NA,
1,0,NA,0.5,NA,
1,0,NA,0.5,NA,
1,0,NA,0.5,NA,
1,0,NA,NA,0.5,
1,0,NA,NA,0.5,
1,0,NA,NA,0.5,
1,0,NA,NA,0.5,
1,0,NA,NA,0.5),ncol=5,byrow=TRUE)
d <- matrix(rnorm(16))
items <- rep('2PL', 16)
## End(Not run)
Description
Author(s)
References
Bock, R. D. (1997). The Nominal Categories Model. In van der Linden, W. J. & Hambleton, R. K.
Handbook of modern item response theory. New York: Springer.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
dat <- expand.table(Bock1997)
head(dat)
mod <- mirt(dat, 1, 'nominal')
## End(Not run)
Description
Given two fitted models, compute a parametric bootstrap test to determine whether the less restric-
tive models fits significantly better than the more restricted model. Note that this hypothesis test
also works when prior parameter distributions are included for either model. Function can be run in
parallel after using a suitable mirtCluster definition.
Usage
boot.LR(mod, mod2, R = 1000)
Arguments
mod an estimated model object
mod2 an estimated model object
R number of parametric bootstraps to use.
boot.mirt 15
Value
a p-value evaluating whether the more restrictive model fits significantly worse than the less restric-
tive model
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
#standard
dat <- expand.table(LSAT7)
mod1 <- mirt(dat, 1)
mod2 <- mirt(dat, 1, '3PL')
# standard LR test
anova(mod1, mod2)
## End(Not run)
Description
Given an internal mirt object estimate the bootstrapped standard errors. It may be beneficial to
run the computations using multi-core architecture (e.g., the parallel package). Parameters are
organized from the freely estimated values in mod2values(x) (equality constraints will also be
returned in the bootstrapped estimates).
Usage
boot.mirt(x, R = 100, technical = NULL, ...)
16 coef-method
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
#standard
mod <- mirt(Science, 1)
booted <- boot.mirt(mod, R=20)
plot(booted)
booted
## End(Not run)
Description
Return a list (or data.frame) of raw item and group level coefficients. Note that while the output
to the console is rounded to three digits, the returned list of objects is not. Hence, elements from
cfs <- coef(mod); cfs[[1]] will contain the unrounded results (useful for simulations).
coef-method 17
Usage
## S4 method for signature 'SingleGroupClass'
coef(object, CI = 0.95, printSE = FALSE,
rotate = "none", Target = NULL, IRTpars = FALSE, rawug = FALSE,
as.data.frame = FALSE, simplify = FALSE, unique = FALSE,
verbose = TRUE, ...)
Arguments
object an object of class SingleGroupClass, MultipleGroupClass, or MixedClass
CI the amount of converged used to compute confidence intervals; default is 95
percent confidence intervals
printSE logical; print the standard errors instead of the confidence intervals? When
IRTpars = TRUE then the delta method will be used to compute the associ-
ated standard errors from mirt’s default slope-intercept form
rotate see summary method for details. The default rotation is 'none'
Target a dummy variable matrix indicting a target rotation pattern
IRTpars logical; convert slope intercept parameters into traditional IRT parameters? Only
applicable to unidimensional models. If a suitable ACOV estimate was com-
puted in the fitted model, and printSE = FALSE, then suitable CIs will be
included based on the delta method (where applicable)
rawug logical; return the untransformed internal g and u parameters? If FALSE, g and
u’s are converted with the original format along with delta standard errors
as.data.frame logical; convert list output to a data.frame instead?
simplify logical; if all items have the same parameter names (indicating they are of the
same class) then they are collapsed to a matrix, and a list of length 2 is returned
containing a matrix of item parameters and group-level estimates
unique return the vector of uniquely estimated parameters
verbose logical; allow information to be printed to the console?
... additional arguments to be passed
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
summary-method
Examples
## Not run:
dat <- expand.table(LSAT7)
x <- mirt(dat, 1)
18 createGroup
coef(x)
coef(x, IRTpars = TRUE)
coef(x, simplify = TRUE)
#two factors
x2 <- mirt(Science, 2)
coef(x2)
coef(x2, rotate = 'varimax')
## End(Not run)
createGroup Create a user defined group-level object with correct generic functions
Description
Initializes the proper S4 class and methods necessary for mirt functions to use in estimation for
defining customized group-level functions. To use the defined objects pass to the mirt(..., customGroup = OBJECT)
command, and ensure that the class parameters are properly labeled.
Usage
createGroup(par, est, den, nfact, gr = NULL, hss = NULL, gen = NULL,
lbound = NULL, ubound = NULL, derivType = "Richardson")
Arguments
par a named vector of the starting values for the parameters
est a logical vector indicating which parameters should be freely estimated by de-
fault
den the probability density function given the Theta/ability values. First input con-
tains a vector of all the defined parameters and the second input must be a matrix
called Theta. Function also must return a numeric vector object corresponding
to the associated densities for each row in the Theta input
nfact number of factors required for the model. E.g., for unidimensional models with
only one dimension of integration nfact = 1
gr gradient function (vector of first derivatives) of the log-likelihood used in esti-
mation. The function must be of the form gr(x, Theta), where x is the object
defined by createGroup() and Theta is a matrix of latent trait parameters
createItem 19
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
coef(mod)
coef(modcustom)
Description
Initializes the proper S4 class and methods necessary for mirt functions to use in estimation. To use
the defined objects pass to the mirt(..., customItems = list()) command, and ensure that the
classes are properly labeled and unique in the list. Additionally, the input mirt(..., customItemsData = list())
can also be included to specify additional item-level information to better recycle custom-item defin-
tions (e.g., for supplying varying Q-matricies), where the list input must have the same length as
the number of items. For further examples regarding how this function can be used for fitting
unfolding-type models see Liu and Chalmers (2018).
Usage
createItem(name, par, est, P, gr = NULL, hss = NULL, gen = NULL,
lbound = NULL, ubound = NULL, derivType = "Richardson",
derivType.hss = "Richardson", bytecompile = TRUE)
Arguments
name a character indicating the item class name to be defined
par a named vector of the starting values for the parameters
est a logical vector indicating which parameters should be freely estimated by de-
fault
P the probability trace function for all categories (first column is category 1, sec-
ond category two, etc). First input contains a vector of all the item parameters,
the second input must be a matrix called Theta, the third input must be the
number of categories called ncat, and (optionally) a fourth argument termed
itemdata may be included containing further users specification information.
The last optional input is to be utilized within the estimation functions such as
mirt via the list input customItemsData to more naturally recycle custom-item
definitions. Therefore, these inputs must be of the form
function(par, Theta, ncat){...}
or
function(par, Theta, ncat, itemdata){...}
to be valid; however, the names of the arguements is not relavent.
Finally, this function must return a matrix object of category probabilities,
where the columns represent each respective category
gr gradient function (vector of first derivatives) of the log-likelihood used in esti-
mation. The function must be of the form gr(x, Theta), where x is the object
defined by createItem() and Theta is a matrix of latent trait parameters. Tab-
ulated (EM) or raw (MHRM) data are located in the x@dat slot, and are used to
form the complete data log-likelihood. If not specified a numeric approximation
will be used
hss Hessian function (matrix of second derivatives) of the log-likelihood used in
estimation. If not specified a numeric approximation will be used (required for
the MH-RM algorithm only). The input is identical to the gr argument
gen a function used when GenRandomPars = TRUE is passed to the estimation
function to generate random starting values. Function must be of the form
createItem 21
Details
The summary() function will not return proper standardized loadings since the function is not sure
how to handle them (no slopes could be defined at all!). Instead loadings of .001 are filled in as
place-holders.
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Liu, C.-W. and Chalmers, R. P. (2018). Fitting item response unfolding models to Likert-scale data
using mirt in R. PLoS ONE, 13, 5. doi: 10.1371/journal.pone.0196292
Examples
## Not run:
b <- par[2]
P1 <- 1 / (1 + exp(-1*a*(Theta - b)))
cbind(1-P1, P1)
}
# fit the same model, but specify gradient function explicitly (use of a browser() may be helpful)
gr <- function(x, Theta){
# browser()
a <- x@par[1]
b <- x@par[2]
P <- probtrace(x, Theta)
PQ <- apply(P, 1, prod)
r_P <- x@dat / P
grad <- numeric(2)
grad[2] <- sum(-a * PQ * (r_P[,2] - r_P[,1]))
grad[1] <- sum((Theta - b) * PQ * (r_P[,2] - r_P[,1]))
###non-linear
name <- 'nonlin'
par <- c(a1 = .5, a2 = .1, d = 0)
est <- c(TRUE, TRUE, TRUE)
deAyala 23
## End(Not run)
Description
Mathematics data from de Ayala (2009; pg. 14); 5 item dataset in table format.
24 DIF
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
de Ayala, R. J. (2009). The theory and practice of item response theory. Guilford Press.
Examples
## Not run:
dat <- expand.table(deAyala)
head(dat)
## End(Not run)
Description
This function runs the Wald and likelihood-ratio approaches for testing differential item functioning
(DIF). This is primarily a convenience wrapper to the multipleGroup function for performing
standard DIF procedures. Independent models can be estimated in parallel by defining a parallel
object with mirtCluster, which will help to decrease the runtime. For best results, the baseline
model should contain a set of ’anchor’ items and have freely estimated hyper-parameters in the
focal groups.
Usage
DIF(MGmodel, which.par, scheme = "add", items2test = 1:extract.mirt(MGmodel,
"nitems"), seq_stat = "SABIC", Wald = FALSE, p.adjust = "none",
return_models = FALSE, max_run = Inf, plotdif = FALSE, type = "trace",
verbose = TRUE, ...)
Arguments
MGmodel an object returned from multipleGroup to be used as the reference model
which.par a character vector containing the parameter names which will be inspected for
DIF
scheme type of DIF analysis to perform, either by adding or dropping constraints across
groups. These can be:
DIF 25
’add’ parameters in which.par will be constrained each item one at a time for
items that are specified in items2test. This is beneficial when examin-
ing DIF from a model with parameters freely estimated across groups, and
when inspecting differences via the Wald test
’drop’ parameters in which.par will be freely estimated for items that are spec-
ified in items2test. This is useful when supplying an overly restrictive
model and attempting to detect DIF with a slightly less restrictive model
’add_sequential’ sequentially loop over the items being tested, and at the end
of the loop treat DIF tests that satisfy the seq_stat criteria as invariant.
The loop is then re-run on the remaining invariant items to determine if
they are now displaying DIF in the less constrained model, and when no
new invariant item is found the algorithm stops and returns the items that
displayed DIF
’drop_sequential’ sequentially loop over the items being tested, and at the end
of the loop treat items that violate the seq_stat criteria as demonstrating
DIF. The loop is then re-run, leaving the items that previously demonstrated
DIF as variable across groups, and the remaining test items that previously
showed invariance are re-tested. The algorithm stops when no more items
showing DIF are found and returns the items that displayed DIF
items2test a numeric vector, or character vector containing the item names, indicating
which items will be tested for DIF. In models where anchor items are known,
omit them from this vector. For example, if items 1 and 2 are anchors in a 10
item test, then items2test = 3:10 would work for testing the remaining items
(important to remember when using sequential schemes)
seq_stat select a statistic to test for in the sequential schemes. Potential values are (in
descending order of power) 'AIC', 'AICc', 'SABIC', and 'BIC'. If a numeric
value is input that ranges between 0 and 1, the ’p’ value will be tested (e.g.,
seq_stat = .05 will test for the difference of p < .05 in the add scheme, or p
> .05 in the drop scheme), along with the specified p.adjust input
Wald logical; perform Wald tests for DIF instead of likelihood ratio test?
p.adjust string to be passed to the p.adjust function to adjust p-values. Adjustments are
located in the adj_pvals element in the returned list
return_models logical; return estimated model objects for further analysis? Default is FALSE
max_run a number indicating the maximum number of cycles to perform in sequential
searches. The default is to perform search until no further DIF is found
plotdif logical; create item plots for items that are displaying DIF according to the
seq_stat criteria? Only available for ’add’ type schemes
type the type of plot argument passed to plot(). Default is ’trace’, though another
good option is ’infotrace’. For ease of viewing, the facet_item argument to
mirt’s plot() function is set to TRUE
verbose logical print extra information to the console?
... additional arguments to be passed to multipleGroup and plot
26 DIF
Details
Generally, the precomputed baseline model should have been configured with two estimation prop-
erties: 1) a set of ’anchor’ items, where the anchor items have various parameters that have been
constrained to be equal across the groups, and 2) contain freely estimated latent mean and variance
terms in all but one group (the so-called ’reference’ group). These two properties help to fix the
metric of the groups so that item parameter estimates do not contain latent distribution characteris-
tics.
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P., Counsell, A., and Flora, D. B. (2016). It might not make a big DIF: Improved
Differential Test Functioning statistics that account for sampling variability. Educational and Psy-
chological Measurement, 76, 114-140. doi: 10.1177/0013164415584576
See Also
multipleGroup, DRF
Examples
## Not run:
#simulate data where group 2 has a smaller slopes and more extreme intercepts
set.seed(12345)
a1 <- a2 <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d1 <- d2 <- matrix(rnorm(15,0,.7),ncol=1)
a2[1:2, ] <- a1[1:2, ]/3
d1[c(1,3), ] <- d2[c(1,3), ]/4
head(data.frame(a.group1 = a1, a.group2 = a2, d.group1 = d1, d.group2 = d2))
itemtype <- rep('2PL', nrow(a1))
N <- 1000
dataset1 <- simdata(a1, d1, N, itemtype)
dataset2 <- simdata(a2, d2, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))
#### no anchors, all items tested for DIF by adding item constrains one item at a time.
# define a parallel cluster (optional) to help speed up internal functions
mirtCluster()
# Information matrix with Oakes' identity (not controlling for latent group differences)
# NOTE: Without properly equating the groups the following example code is not testing for DIF,
# but instead reflects a combination of DIF + latent-trait distribution effects
model <- multipleGroup(dat, 1, group, SE = TRUE)
DiscreteClass-class 27
#test whether adding slopes and intercepts constraints results in DIF. Plot items showing DIF
resulta1d <- DIF(model, c('a1', 'd'), plotdif = TRUE)
resulta1d
#same as above, but using Wald tests with Benjamini & Hochberg adjustment
resulta1dWald <- DIF(model, c('a1', 'd'), Wald = TRUE, p.adjust = 'fdr')
resulta1dWald
round(resulta1dWald$adj_pvals, 4)
#test whether adding only slope constraints results in DIF for all items
resulta1 <- DIF(model, 'a1')
resulta1
####
# using items 4 to 15 as anchors to test for DIF after adjusting for latent-trait differences
itemnames <- colnames(dat)
model_anchor <- multipleGroup(dat, model = 1, group = group,
invariance = c(itemnames[4:15], 'free_means', 'free_var'))
anchor <- DIF(model_anchor, c('a1', 'd'), items2test = 1:3)
anchor
### drop down approach (freely estimating parameters across groups) when
### specifying a highly constrained model with estimated latent parameters
model_constrained <- multipleGroup(dat, 1, group,
invariance = c(colnames(dat), 'free_means', 'free_var'))
dropdown <- DIF(model_constrained, 'd', scheme = 'drop')
dropdown
## End(Not run)
Description
Defines the object returned from mdirt.
28 draw_parameters
Slots
Call: function call
Data: list of data, sometimes in different forms
Options: list of estimation options
Fit: a list of fit information
Model: a list of model-based information
ParObjects: a list of the S4 objects used during estimation
OptimInfo: a list of arguments from the optimization process
Internals: a list of internal arguments for secondary computations (inspecting this object is gen-
erally not required)
vcov: a matrix represented the asymptotic covariance matrix of the parameter estimates
time: a data.frame indicating the breakdown of computation times in seconds
Methods
print signature(x = "DiscreteClass")
show signature(object = "DiscreteClass")
anova signature(object = "DiscreteClass")
coef signature(x = "DiscreteClass")
summary signature(object = "DiscreteClass")
residuals signature(object = "DiscreteClass")
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Description
Draws plausible parameters from a model using parametric sampling (if the information matrix was
computed) or via boostrap sampling. Primarily for use with the DRF function.
Usage
draw_parameters(mod, draws, method = c("parametric", "boostrap"),
redraws = 20, ...)
draw_parameters 29
Arguments
Value
returns a draws x p matrix of plausible parameters, where each row correspeonds to a single set
Examples
## Not run:
set.seed(1234)
n <- 40
N <- 500
a <- matrix(1, n)
d <- matrix(rnorm(n), n)
group <- c(rep('Group_1', N), rep('Group_2', N))
## -------------
# groups completely equal
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a, d, N, itemtype = 'dich')
dat <- rbind(dat1, dat2)
mod <- multipleGroup(dat, model, group=group, SE=TRUE,
invariance=c('free_means', 'free_var'))
## End(Not run)
30 DRF
Description
Function performs various omnibus differential item (DIF), bundle (DBF), and test (DTF) func-
tioning procedures on an object estimated with multipleGroup(). The compensatory and non-
compensatory statistics provided are described in Chalmers (accepted), which generally can be
interpreted as IRT generalizations of the SIBTEST and CSIBTEST statistics. These require the
ACOV matrix to be computed in the fitted multiple-group model (otherwise, sets of plausible draws
from the posterior are explicitly required).
Usage
DRF(mod, draws = NULL, focal_items = 1L:extract.mirt(mod, "nitems"),
param_set = NULL, CI = 0.95, npts = 1000, quadpts = NULL,
theta_lim = c(-6, 6), Theta_nodes = NULL, plot = FALSE, DIF = FALSE,
par.strip.text = list(cex = 0.7), par.settings = list(strip.background =
list(col = "#9ECAE1"), strip.border = list(col = "black")),
auto.key = list(space = "right", points = FALSE, lines = TRUE), ...)
Arguments
mod a multipleGroup object which estimated only 2 groups
draws a number indicating how many draws to take to form a suitable multiple im-
putation or bootstrap estimate of the expected test scores (100 or more). If
boot = FALSE, requires an estimated parameter information matrix. Returns
a list containing the bootstrap/imputation distribution and null hypothesis test
for the sDRF statistics
focal_items a numeric vector indicating which items to include in the DRF tests. The default
uses all of the items (note that including anchors in the focal items has no effect
because they are exactly equal across groups). Selecting fewer items will result
in tests of ’differential bundle functioning’
param_set an N x p matrix of parameter values drawn from the posterior (e.g., using the
parametric sampling approach, bootstrap, of MCMC). If supplied, then these
will be used to compute the DRF measures. Can be much more efficient to pre-
compute these values if DIF, DBF, or DTF are being evaluated within the same
model (especially when using the bootstrap method). See draw_parameters
CI range of confidence interval when using draws input
npts number of points to use for plotting. Default is 1000
quadpts number of quadrature nodes to use when constructing DRF statistics. Default is
extracted from the input model object
theta_lim lower and upper limits of the latent trait (theta) to be evaluated, and is used in
conjunction with quadpts and npts
DRF 31
Theta_nodes an optional matrix of Theta values to be evaluated in the draws for the sDRF
statistics. However, these values are not averaged across, and instead give the
bootstrap confidence intervals at the respective Theta nodes. Useful when fol-
lowing up a large sDRF or uDRF statistic, for example, to determine where the
difference between the test curves are large (while still accounting for sampling
variability). Returns a matrix with observed variability
plot logical; plot the ’sDRF’ functions for the evaluated sDBF or sDTF values across
the integration grid or, if DIF = TRUE, the selected items as a faceted plot
of individual items? If plausible parameter sets were obtained/supplied then
imputed confidence intervals will be included
DIF logical; return a list of item-level imputation properties using the DRF statis-
tics? These can generally be used as a DIF detection method and as a graphical
display for understanding DIF within each item
par.strip.text plotting argument passed to lattice
par.settings plotting argument passed to lattice
auto.key plotting argument passed to lattice
... additional arguments to be passed to lattice
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R. P. (accepted). Model-Based Measures for Detecting and Quantifying Response Bias.
Psychometrika.
See Also
multipleGroup, DIF
Examples
## Not run:
set.seed(1234)
n <- 30
N <- 500
a <- matrix(1, n)
d <- matrix(rnorm(n), n)
group <- c(rep('Group_1', N), rep('Group_2', N))
## -------------
# groups completely equal
32 DRF
DRF(mod)
DRF(mod, focal_items = 6:10) #DBF
DRF(mod, DIF=TRUE)
DRF(mod, DIF=TRUE, focal_items = 10:15)
mirtCluster()
DRF(mod, draws = 500)
DRF(mod, draws = 500, plot=TRUE)
## -------------
## random slopes and intercepts for 15 items, and latent mean difference
## (no systematic DTF should exist, but DIF will be present)
set.seed(1234)
dat1 <- simdata(a, d, N, itemtype = 'dich', mu=.50, sigma=matrix(1.5))
dat2 <- simdata(a + c(numeric(15), rnorm(n-15, 0, .25)),
d + c(numeric(15), rnorm(n-15, 0, .5)), N, itemtype = 'dich')
dat <- rbind(dat1, dat2)
mod1 <- multipleGroup(dat, 1, group=group)
plot(mod1)
DRF(mod1) #does not account for group differences! Need anchors
## -------------
## systematic differing slopes and intercepts (clear DTF)
set.seed(1234)
dat1 <- simdata(a, d, N, itemtype = 'dich', mu=.50, sigma=matrix(1.5))
dat2 <- simdata(a + c(numeric(15), rnorm(n-15, 1, .25)), d + c(numeric(15), rnorm(n-15, 1, .5)),
N, itemtype = 'dich')
dat <- rbind(dat1, dat2)
mod3 <- multipleGroup(dat, model, group=group, SE=TRUE,
invariance=c('free_means', 'free_var'))
plot(mod3) #visable DTF happening
# DIF
sDIF <- DRF(mod3, Theta_nodes=Theta_nodes, focal_items = 30, draws=200)
34 DTF
car::some(sDIF)
## ----------------------------------------------------------------
### multidimensional DTF
set.seed(1234)
n <- 50
N <- 1000
DRF(mod)
DRF(mod, draws = 500)
## End(Not run)
Description
Function performs various omnibus differential test functioning procedures on an object estimated
with multipleGroup(). If the latent means/covariances are suspected to differ then the input object
should contain a set of ’anchor’ items to ensure that only differential test features are being detected
rather than group differences. Returns signed (average area above and below) and unsigned (total
area) statistics, with descriptives such as the percent average bias between group total scores for
each statistic. If a grid of Theta values is passed, these can be evaluated as well to determine
specific DTF location effects. For best results, the baseline model should contain a set of ’anchor’
items and have freely estimated hyper-parameters in the focal groups. See DIF for details.
Usage
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P., Counsell, A., and Flora, D. B. (2016). It might not make a big DIF: Improved
Differential Test Functioning statistics that account for sampling variability. Educational and Psy-
chological Measurement, 76, 114-140. doi: 10.1177/0013164415584576
See Also
multipleGroup, DIF
Examples
## Not run:
set.seed(1234)
n <- 30
N <- 500
a <- matrix(1, n)
d <- matrix(rnorm(n), n)
group <- c(rep('Group_1', N), rep('Group_2', N))
## -------------
# groups completely equal
dat1 <- simdata(a, d, N, itemtype = '2PL')
dat2 <- simdata(a, d, N, itemtype = '2PL')
dat <- rbind(dat1, dat2)
mod <- multipleGroup(dat, model, group=group, SE=TRUE,
invariance=c('free_means', 'free_var'))
plot(mod)
DTF(mod)
mirtCluster()
DTF(mod, draws = 1000) #95% C.I. for sDTF containing 0. uDTF is very small
DTF(mod, draws = 1000, plot='sDTF') #sDTF 95% C.I.'s across Theta always include 0
## -------------
## random slopes and intercepts for 15 items, and latent mean difference
## (no systematic DTF should exist, but DIF will be present)
set.seed(1234)
dat1 <- simdata(a, d, N, itemtype = '2PL', mu=.50, sigma=matrix(1.5))
dat2 <- simdata(a + c(numeric(15), runif(n-15, -.2, .2)),
d + c(numeric(15), runif(n-15, -.5, .5)), N, itemtype = '2PL')
dat <- rbind(dat1, dat2)
mod1 <- multipleGroup(dat, 1, group=group)
plot(mod1) #does not account for group differences! Need anchors
empirical_ES 37
## -------------
## systematic differing slopes and intercepts (clear DTF)
dat1 <- simdata(a, d, N, itemtype = '2PL', mu=.50, sigma=matrix(1.5))
dat2 <- simdata(a + c(numeric(15), rnorm(n-15, 1, .25)), d + c(numeric(15), rnorm(n-15, 1, .5)),
N, itemtype = '2PL')
dat <- rbind(dat1, dat2)
mod3 <- multipleGroup(dat, model, group=group, SE=TRUE,
invariance=c('free_means', 'free_var'))
plot(mod3) #visable DTF happening
## End(Not run)
Description
Computes effect size measures of differential item functioning and differential test/bundle function-
ing based on expected scores from Meade (2010). Item parameters from both reference and focal
group are used in conjunction with focal group empirical theta estimates (and an assumed normally
distributed theta) to compute expected scores.
Usage
empirical_ES(mod, Theta.focal = NULL, focal_items = 1L:extract.mirt(mod,
"nitems"), DIF = TRUE, npts = 61, theta_lim = c(-6, 6), ref.group = 1,
plot = FALSE, par.strip.text = list(cex = 0.7),
38 empirical_ES
Arguments
mod a multipleGroup object which estimated only 2 groups
Theta.focal an optional matrix of Theta values from the focal group to be evaluated. If not
supplied the default values to fscores will be used in conjunction with the ...
arguments passed
focal_items a numeric vector indicating which items to include the tests. The default uses
all of the items. Selecting fewer items will result in tests of ’differential bundle
functioning’ when DIF = FALSE
DIF logical; return a data.frame of item-level imputation properties? If FALSE, only
DBF and DTF statistics will be reported
npts number of points to use in the integration. Default is 61
theta_lim lower and upper limits of the latent trait (theta) to be evaluated, and is used in
conjunction with npts
ref.group either 1 or 2 to indicate which group is considered the ’reference’ group. Default
is 1
plot logical; plot expected scores of items/test where expected scores are computed
using focal group thetas and both focal and reference group item parameters
par.strip.text plotting argument passed to lattice
par.settings plotting argument passed to lattice
... additional arguments to be passed to fscores and xyplot
DIF
The default DIF = TRUE produces several effect sizes indices at the item level. Signed indices
allow DIF favoring the focal group at one point on the theta distribution to cancel DIF favoring the
reference group at another point on the theta distribution. Unsigned indices take the absolute value
before summing or averaging, thus not allowing cancellation of DIF across theta.
SIDS Signed Item Difference in the Sample. The average difference in expected scores across the
focal sample using both focal and reference group item parameters.
UIDS Unsigned Item Difference in the Sample. Same as SIDS except absolute value of expected
scores is taken prior to averaging across the sample.
D-Max The maximum difference in expected scores in the sample.
ESSD Expected Score Standardized Difference. Cohen’s D for difference in expected scores.
SIDN Signed Item Difference in a Normal distribution. Identical to SIDS but averaged across a
normal distribution rather than the sample.
UIDN Unsigned Item Difference in a Normal distribution. Identical to UIDS but averaged across
a normal distribution rather than the sample.
empirical_ES 39
DBF/DTF
DIF = FALSE produces a series of test/bundle-level indices that are based on item-level indices.
STDS Signed Test Differences in the Sample. The sum of the SIDS across items.
UTDS Unsigned Test Differences in the Sample. The sum of the UIDS across items.
Stark’s DTFR Stark’s version of STDS using a normal distribution rather than sample estimated
thetas.
UDTFR Unsigned Expected Test Scores Differences in the Sample. The difference in observed
summed scale scores expected, on average, across a hypothetical focal group with a normally
distributed theta, had DF been uniform in nature for all items
UETSDS Unsigned Expected Test Score Differences in the Sample. The hypothetical difference
expected scale scores that would have been present if scale-level DF had been uniform across
respondents (i.e., always favoring the focal group).
UETSDN Identical to UETSDS but computed using a normal distribution.
Test D-Max Maximum expected test score differences in the sample.
ETSSD Expected Test Score Standardized Difference. Cohen’s D for expected test scores.
Author(s)
Adam Meade and Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Meade, A. W. (2010). A taxonomy of effect size measures for the differential functioning of items
and scales. Journal of Applied Psychology, 95, 728-743.
Examples
## Not run:
#no DIF
set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
itemtype <- rep('2PL', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('Ref', N), rep('Focal', N))
empirical_ES(mod)
40 empirical_plot
empirical_ES(mod, DIF=FALSE)
empirical_ES(mod, DIF=FALSE, focal_items = 10:15)
empirical_ES(mod, plot=TRUE)
empirical_ES(mod, plot=TRUE, DIF=FALSE)
###---------------------------------------------
# DIF
set.seed(12345)
a1 <- a2 <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d1 <- d2 <- matrix(rnorm(15,0,.7),ncol=1)
a2[10:15,] <- a2[10:15,] + rnorm(6, 0, .3)
d2[10:15,] <- d2[10:15,] + rnorm(6, 0, .3)
itemtype <- rep('dich', nrow(a1))
N <- 1000
dataset1 <- simdata(a1, d1, N, itemtype)
dataset2 <- simdata(a2, d2, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('Ref', N), rep('Focal', N))
empirical_ES(mod)
empirical_ES(mod, DIF = FALSE)
empirical_ES(mod, plot=TRUE)
empirical_ES(mod, plot=TRUE, DIF=FALSE)
## End(Not run)
Description
Given a dataset containing item responses this function will construct empirical graphics using
the observed responses to each item conditioned on the total score. When individual item plots are
requested then the total score will be formed without the item of interest (i.e., the total score without
that item).
Usage
empirical_plot(data, which.items = NULL, smooth = FALSE, formula = resp ~
s(TS, k = 5), main = NULL, par.strip.text = list(cex = 0.7),
boxplot = FALSE, par.settings = list(strip.background = list(col =
"#9ECAE1"), strip.border = list(col = "black")), auto.key = list(space =
"right", points = FALSE, lines = TRUE), ...)
empirical_plot 41
Arguments
data a data.frame or matrix of item responses (see mirt for typical input)
which.items a numeric vector indicating which items to plot in a faceted image plot. If NULL
then a empirical test plot will be constructed instead
smooth logical; include a GAM smoother instead of the raw proportions? Default is
FALSE
formula formula used for the GAM smoother
main the main title for the plot. If NULL an internal default will be used
par.strip.text plotting argument passed to lattice
boxplot logical; use a boxplot to display the marginal total score differences instead of
scatter plots of proportions? Default is FALSE
par.settings plotting argument passed to lattice
auto.key plotting argument passed to lattice
... additional arguments to be passed to lattice and coef()
Details
Note that these types of plots should only be used for unidimensional tests with monotonically
increasing item response functions. If monotonicity should be true for all items, however, then these
plots may serve as a visual diagnostic tool so long as the majority of items are indeed monotonic.
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
itemplot, itemGAM
Examples
## Not run:
SAT12[SAT12 == 8] <- NA
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
#test plot
empirical_plot(data)
#items 1, 2 and 5
empirical_plot(data, c(1, 2, 5))
empirical_plot(data, c(1, 2, 5), smooth = TRUE)
empirical_plot(data, c(1, 2, 5), boxplot = TRUE)
42 empirical_rxx
## End(Not run)
Description
Given secondary latent trait estimates and their associated standard errors returned from fscores,
compute the empirical reliability.
Usage
empirical_rxx(Theta_SE)
Arguments
Theta_SE a matrix of latent trait estimates returned from fscores with the options full.scores = TRUE
and full.scores.SE = TRUE
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
fscores, marginal_rxx
Examples
## Not run:
## End(Not run)
Description
A function for extracting the empirical estimating functions of a fitted mirt, multipleGroup or
bfactor model. This is the derivative of the log-likelihood with respect to the parameter vector,
evaluated at the observed (case-wise) data. In other words, this function returns the case-wise
scores, evaluated at the fitted model parameters. Currently, models fitted via the EM or BL method
are supported. For the computations, the internal Theta grid of the model is being used which was
already used during the estimation of the model itself along with its matching normalized density.
Usage
estfun.AllModelClass(object)
Arguments
object a fitted model object of class SingleGroupClass or MultipleGroupClass
Value
An n x k matrix corresponding to n observations and k parameters
Author(s)
Lennart Schneider <lennart.sch@web.de>
See Also
mirt, multipleGroup, bfactor
Examples
## Not run:
mod1 <- mirt(expand.table(LSAT7), 1, SE = TRUE, SE.type = "crossprod")
(sc1 <- estfun.AllModelClass(mod1))
colSums(sc1)
vc1 <- vcov(mod1)
all.equal(crossprod(sc1), chol2inv(chol(vc1)), check.attributes = FALSE)
44 expand.table
## End(Not run)
Description
The expand.table function expands a summary table of unique response patterns to a full sized
data-set. The response frequencies must be on the rightmost column of the input data.
Usage
Arguments
tabdata An object of class data.frame or matrix with the unique response patterns and
the number of frequencies in the rightmost column
sample logical; randomly switch the rows in the expanded table? This does not change
the expanded data, only the row locations
Value
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
expected.item 45
Examples
data(LSAT7)
head(LSAT7)
LSAT7full <- expand.table(LSAT7)
head(LSAT7full)
Description
Given an internal mirt object extracted from an estimated model compute the expected value for an
item given the ability parameter(s).
Usage
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.item, expected.test
46 expected.test
Examples
Description
Given an estimated model compute the expected test score. Returns the expected values in the same
form as the data used to estimate the model.
Usage
Arguments
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
expected.item
extract.group 47
Examples
## Not run:
dat <- expand.table(deAyala)
model <- 'F = 1-5
CONSTRAIN = (1-5, a1)'
mod <- mirt(dat, model)
## End(Not run)
Description
Extract a single group from an object defined by multipleGroup.
Usage
extract.group(x, group)
Arguments
x mirt model of class ’MultipleGroupClass’
group a number signifying which group should be extracted
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.item, extract.mirt
48 extract.item
Examples
## Not run:
set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
itemtype <- rep('2PL', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))
models <- 'F1 = 1-15'
## End(Not run)
Description
Extract the internal mirt objects from any estimated model.
Usage
extract.item(x, item, group = NULL, drop.zeros = FALSE)
Arguments
x mirt model of class ’SingleGroupClass’ or ’MultipleGroupClass’
item a number or character signifying which item to extract
group a number signifying which group the item should be extracted from (applies to
’MultipleGroupClass’ only)
drop.zeros logical; drop slope values that are numerically close to zero to reduce dimen-
sionality? Useful in objects returned from bfactor or other confirmatory mod-
els that contain several zero slopes
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
extract.mirt 49
See Also
extract.group, extract.mirt
Examples
## Not run:
mod <- mirt(Science, 1)
extr.1 <- extract.item(mod, 1)
## End(Not run)
Description
A generic function to extract the internal objects from estimated models.
Usage
extract.mirt(x, what)
Arguments
x mirt model of class ’SingleGroupClass’, ’MultipleGroupClass’, ’MixedClass’
or ’DiscreteGroupClass’
what a string indicating what to extract
Details
Objects which can be extracted from mirt objects include:
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.group, extract.item, mod2values
Examples
## Not run:
mod <- mirt(Science, 1)
extract.mirt(mod, 'logLik')
extract.mirt(mod, 'F')
## End(Not run)
Description
Create expected values for fixed effects parameters in latent regression models.
Usage
fixef(x)
Arguments
x an estimated model object from the mixedmirt or mirt function
52 fixef
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P. (2015). Extended Mixed-Effects Item Response Models with the MH-RM Algo-
rithm. Journal of Educational Measurement, 52, 200-222. doi: 10.1111/jedm.12072
See Also
mirt, mixedmirt
Examples
## Not run:
#simulate data
set.seed(1234)
N <- 1000
# covariates
X1 <- rnorm(N); X2 <- rnorm(N)
covdata <- data.frame(X1, X2)
Theta <- matrix(0.5 * X1 + -1 * X2 + rnorm(N, sd = 0.5))
# with mixedmirt()
mod1b <- mixedmirt(dat, covdata, 1, lr.fixed = ~ X1 + X2, fixed = ~ 0 + items)
fe2 <- fixef(mod1b)
head(fe2)
## End(Not run)
fscores 53
fscores Compute factor score estimates (a.k.a, ability estimates, latent trait
estimates, etc)
Description
Computes MAP, EAP, ML (Embretson & Reise, 2000), EAP for sum-scores (Thissen et al., 1995),
or WLE (Warm, 1989) factor scores with a multivariate normal prior distribution using equally
spaced quadrature. EAP scores for models with more than three factors are generally not rec-
ommended since the integration grid becomes very large, resulting in slower estimation and less
precision if the quadpts are too low. Therefore, MAP scores should be used instead of EAP scores
for higher dimensional models. Multiple imputation variants are possible for each estimator if a
parameter information matrix was computed, which are useful if the sample size/number of items
were small. As well, if the model contained latent regression predictors this information will be
used in computing MAP and EAP estimates (for these models, full.scores=TRUE will always be
used). Finally, plausible value imputation is also available, and will also account for latent regres-
sion predictor effects.
Usage
fscores(object, method = "EAP", full.scores = TRUE, rotate = "oblimin",
Target = NULL, response.pattern = NULL, append_response.pattern = TRUE,
na.rm = FALSE, plausible.draws = 0, plausible.type = "normal",
quadpts = NULL, returnER = FALSE, return.acov = FALSE, mean = NULL,
cov = NULL, verbose = TRUE, full.scores.SE = FALSE, theta_lim = c(-6,
6), MI = 0, use_dentype_estimate = FALSE, QMC = FALSE,
custom_den = NULL, custom_theta = NULL, min_expected = 1,
converge_info = FALSE, max_theta = 20, start = NULL, ...)
Arguments
object a computed model object of class SingleGroupClass, MultipleGroupClass,
or DiscreteClass
method type of factor score estimation method. Can be:
• "EAP" for the expected a-posteriori (default)
• "MAP" for the maximum a-posteriori (i.e, Bayes modal)
• "ML" for maximum likelihood
• "WLE" for weighted likelihood estimation
• "EAPsum" for the expected a-posteriori for each sum score
• "plausible" for a single plausible value imputation for each case. This is
equivalent to setting plausible.draws = 1
• "classify" for the posteriori classification probabilities (only applicable
when the input model was of class MixtureClass)
full.scores if FALSE then a summary table with factor scores for each unique pattern is
displayed. Otherwise, a matrix of factor scores for each response pattern in the
data is returned (default)
54 fscores
rotate prior rotation to be used when estimating the factor scores. See summary-method
for details. If the object is not an exploratory model then this argument is ig-
nored
Target target rotation; see summary-method for details
response.pattern
an optional argument used to calculate the factor scores and standard errors for
a given response vector or matrix/data.frame
append_response.pattern
logical; should the inputs from response.pattern also be appended to the fac-
tor score output?
na.rm logical; remove rows with any missing values? This is generally not required
due to the nature of computing factors scores, however for the "EAPsum" method
this may be necessary to ensure that the sum-scores correspond to the same com-
posite score
plausible.draws
number of plausible values to draw for future researchers to perform secondary
analyses of the latent trait scores. Typically used in conjunction with latent
regression predictors (see mirt for details), but can also be generated when no
predictor variables were modeled. If plausible.draws is greater than 0 a list
of plausible values will be returned
plausible.type type of plausible values to obtain. Can be either 'normal' (default) to use a
normal approximation based on the ACOV matrix, or 'MH' to obtain Metropolis-
Hastings samples from the posterior (silently passes object to mirt, therefore
arguments like technical can be supplied to increase the number of burn-in
draws and discarded samples)
quadpts number of quadratures to use per dimension. If not specified, a suitable one will
be created which decreases as the number of dimensions increases (and therefore
for estimates such as EAP, will be less accurate). This is determined from the
switch statement quadpts <- switch(as.character(nfact), '1'=61, '2'=31, '3'=15, '4'=9, '5
returnER logical; return empirical reliability (also known as marginal reliability) estimates
as a numeric values?
return.acov logical; return a list containing covariance matrices instead of factors scores?
impute = TRUE not supported with this option
mean a vector for custom latent variable means. If NULL, the default for ’group’
values from the computed mirt object will be used
cov a custom matrix of the latent variable covariance matrix. If NULL, the default
for ’group’ values from the computed mirt object will be used
verbose logical; print verbose output messages?
full.scores.SE logical; when full.scores == TRUE, also return the standard errors associated
with each respondent? Default is FALSE
theta_lim lower and upper range to evaluate latent trait integral for each dimension. If
omitted, a range will be generated automatically based on the number of dimen-
sions
MI a number indicating how many multiple imputation draws to perform. Default
is 0, indicating that no MI draws will be performed
fscores 55
use_dentype_estimate
logical; if the density of the latent trait was estimated in the model (e.g., via
Davidian curves or empirical histograms), should this information be used to
compute the latent trait estimates? Only applicable for EAP-based estimates
(EAP, EAPsum, and plausible)
QMC logical; use quasi-Monte Carlo integration? If quadpts is omitted the default
number of nodes is 5000
custom_den a function used to define the integration density (if required). The NULL default
assumes that the multivariate normal distribution with the ’GroupPars’ hyper-
parameters are used. At the minimum must be of the form:
function(Theta, ...)
where Theta is a matrix of latent trait values (will be a grid of values if method == 'EAPsum'
or method == 'EAP', otherwise Theta will have only 1 row). Additional ar-
guments may included and are caught through the fscores(...) input. The
function must return a numeric vector of density weights (one for each row in
Theta)
custom_theta a matrix of custom integration nodes to use instead of the default, where each
column corresponds to the respective dimension in the model
min_expected when computing goodness of fit tests when method = 'EAPsum', this value is
used to collapse across the conditioned total scores until the expected values are
greater than this value. Note that this only affect the goodness of fit tests and not
the returned EAP for sum scores table
converge_info logical; include a column in the return objects containing a logical for each
response pattern indicating whether a maximum value was found (not relevant
non-iterative methods, such as EAP and EAPsum). Value is a reflection of the
code element from nlm (e.g., 1 indicates convergence)
max_theta the maximum/minimum value any given factor score estimate will achieve using
any modal estimator method (e.g., MAP, WLE, ML)
start a matrix of starting values to use for iterative estimation methods. Default
will start at a vector of 0’s for each response pattern, or will start at the EAP
estimates (unidimensional models only). Must be in the form that matches
full.scores = FALSE (mostly used in the mirtCAT package)
... additional arguments to be passed to nlm
Details
The function will return either a table with the computed scores and standard errors, the original data
matrix with scores appended to the rightmost column, or the scores only. By default the latent means
and covariances are determined from the estimated object, though these can be overwritten. Iterative
estimation methods can be estimated in parallel to decrease estimation times if a mirtCluster
object is available.
If the input object is a discrete latent class object estimated from mdirt then the returned results
will be with respect to the posterior classification for each individual. The method inputs for
'DiscreteClass' objects may only be 'EAP', for posterior classification of each response pat-
tern, or 'EAPsum' for posterior classification based on the raw sum-score. For more information on
these algorithms refer to the mirtCAT package and the associated JSS paper (Chalmers, 2016).
56 fscores
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. 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 Multidimen-
sional Item Response Theory Applications. Journal of Statistical Software, 71(5), 1-39. doi: 10.18637/
jss.v071.i05
Embretson, S. E. & Reise, S. P. (2000). Item Response Theory for Psychologists. Erlbaum.
Thissen, D., Pommerich, M., Billeaud, K., & Williams, V. S. L. (1995). Item Response Theory
for Scores on Tests Including Polytomous Items with Ordered Responses. Applied Psychological
Measurement, 19, 39-49.
Warm, T. A. (1989). Weighted likelihood estimation of ability in item response theory. Psychome-
trika, 54, 427-450.
See Also
averageMI
Examples
## Not run:
fullscores <- fscores(mod)
fullscores_with_SE <- fscores(mod, full.scores.SE=TRUE)
head(fullscores)
head(fullscores_with_SE)
#use custom latent variable properties (diffuse prior for MAP is very close to ML)
fscores(mod, method='MAP', cov = matrix(1000), full.scores = FALSE)
fscores(mod, method='ML', full.scores = FALSE)
imputeMissing 57
#multiple imputation using 30 draws for EAP scores. Requires information matrix
mod <- mirt(Science, 1, SE=TRUE)
fs <- fscores(mod, MI = 30)
head(fs)
## End(Not run)
Description
Given an estimated model from any of mirt’s model fitting functions and an estimate of the latent
trait, impute plausible missing data values. Returns the original data in a data.frame without any
NA values. If a list of Theta values is supplied then a list of complete datasets is returned instead.
Usage
imputeMissing(x, Theta, warn = TRUE, ...)
Arguments
x an estimated model x from the mirt package
Theta a matrix containing the estimates of the latent trait scores (e.g., via fscores)
warn logical; print warning messages?
... additional arguments to pass
58 itemfit
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
dat <- expand.table(LSAT7)
(original <- mirt(dat, 1))
NAperson <- sample(1:nrow(dat), 20, replace = TRUE)
NAitem <- sample(1:ncol(dat), 20, replace = TRUE)
for(i in 1:20)
dat[NAperson[i], NAitem[i]] <- NA
(mod <- mirt(dat, 1))
scores <- fscores(mod, method = 'MAP')
#re-estimate imputed dataset (good to do this multiple times and average over)
fulldata <- imputeMissing(mod, scores)
(fullmod <- mirt(fulldata, 1))
#with multipleGroup
set.seed(1)
group <- sample(c('group1', 'group2'), 1000, TRUE)
mod2 <- multipleGroup(dat, 1, group, TOL=1e-2)
fs <- fscores(mod2)
fulldata2 <- imputeMissing(mod2, fs)
## End(Not run)
Description
Computes item-fit statistics for a variety of unidimensional and multidimensional models. Poorly
fitting items should be inspected with the empirical plots/tables for unidimensional models, other-
wise itemGAM can be used to diagnose where the functional form of the IRT model was misspecified,
or models can be refit using more flexible semi-parametric response models (e.g., itemtype = 'spline').
If the latent trait density was approximated (e.g., Davidian curves, Empirical histograms, etc) then
passing use_dentype_estimate = TRUE will use the internally saved quadrature and density com-
ponents (where applicable). Currently, only S-X2 statistic supported for mixture IRT models.
itemfit 59
Usage
itemfit(x, fit_stats = "S_X2", which.items = 1:extract.mirt(x, "nitems"),
na.rm = FALSE, group.bins = 10, group.size = NA, group.fun = mean,
mincell = 1, mincell.X2 = 2, S_X2.tables = FALSE, pv_draws = 30,
boot = 1000, boot_dfapprox = 200, ETrange = c(-2, 2), ETpoints = 11,
empirical.plot = NULL, empirical.CI = 0.95, empirical.table = NULL,
method = "EAP", Theta = NULL, impute = 0, par.strip.text = list(cex =
0.7), par.settings = list(strip.background = list(col = "#9ECAE1"),
strip.border = list(col = "black")), ...)
Arguments
x a computed model object of class SingleGroupClass, MultipleGroupClass,
or DiscreteClass
fit_stats a character vector indicating which fit statistics should be computed. Supported
inputs are:
• 'S_X2' : Orlando and Thissen (2000, 2003) and Kang and Chen’s (2007)
signed chi-squared test (default)
• 'Zh' : Drasgow, Levine, & Williams (1985) Zh
• 'X2' : Bock’s (1972) chi-squared method. The default inputs compute
Yen’s (1981) Q1 variant of the X2 statistic (i.e., uses a fixed group.bins = 10).
However, Bock’s group-size variable median-based method can be com-
puted by passing group.fun = median and modifying the group.size
input to the desired number of bins
• 'G2' : McKinley & Mills (1985) G2 statistic (similar method to Q1, but
with the likelihood-ratio test).
• 'PV_Q1' : Chalmers and Ng’s (2017) plausible-value variant of the Q1
statistic.
• 'PV_Q1*' : Chalmers and Ng’s (2017) plausible-value variant of the Q1
statistic that uses parametric bootstrapping to obtain a suitable empirical
distribution.
• 'X2*' : Stone’s (2000) fit statistics that require parametric bootstrapping
• 'X2*_df' : Stone’s (2000) fit statistics that require parametric bootstrap-
ping to obtain scaled versions of the X2* and degrees of freedom
• 'infit' : (Unidimensional Rasch model only) compute the infit and outfit
statistics. Ignored if models are not from the Rasch family
Note that ’infit’, ’S_X2’, and ’Zh’ cannot be computed when there are missing
response data (i.e., will require multiple-imputation techniques).
which.items an integer vector indicating which items to test for fit. Default tests all possible
items
na.rm logical; remove rows with any missing values? This is required for methods
such as S-X2 because they require the "EAPsum" method from fscores
group.bins the number of bins to use for X2 and G2. For example, setting group.bins = 10
will will compute Yen’s (1981) Q1 statistic when 'X2' is requested
60 itemfit
group.size approximate size of each group to be used in calculating the χ2 statistic. The
default NA disables this command and instead uses the group.bins input to try
and construct equally sized bins
group.fun function used when 'X2' or 'G2' are computed. Determines the central ten-
dency measure within each partitioned group. E.g., setting group.fun = median
will obtain the median of each respective ability estimate in each subgroup (this
is what was used by Bock, 1972)
mincell the minimum expected cell size to be used in the S-X2 computations. Tables will
be collapsed across items first if polytomous, and then across scores if necessary
mincell.X2 the minimum expected cell size to be used in the X2 computations. Tables will
be collapsed if polytomous, however if this condition can not be met then the
group block will be omitted in the computations
S_X2.tables logical; return the tables in a list format used to compute the S-X2 stats?
pv_draws number of plausible-value draws to obtain for PV_Q1 and PV_Q1*
boot number of parametric bootstrap samples to create for PV_Q1* and X2*
boot_dfapprox number of parametric bootstrap samples to create for the X2*_df statistic to
approximate the scaling factor for X2* as well as the scaled degrees of freedom
estimates
ETrange rangone of integration nodes for Stone’s X2* statistic
ETpoints number of integration nodes to use for Stone’s X2* statistic
empirical.plot a single numeric value or character of the item name indicating which item to
plot (via itemplot) and overlay with the empirical θ groupings (see empirical.CI).
Useful for plotting the expected bins based on the 'X2' or 'G2' method
empirical.CI a numeric value indicating the width of the empirical confidence interval ranging
between 0 and 1 (default of 0 plots not interval). For example, a 95 interval
would be plotted when empirical.CI = .95. Only applicable to dichotomous
items
empirical.table
a single numeric value or character of the item name indicating which item table
of expected values should be returned. Useful for visualizing the expected bins
based on the 'X2' or 'G2' method
method type of factor score estimation method. See fscores for more detail
Theta a matrix of factor scores for each person used for statistics that require empirical
estimates. If supplied, arguments typically passed to fscores() will be ignored
and these values will be used instead. Also required when estimating statistics
with missing data via imputation
impute a number indicating how many imputations to perform (passed to imputeMissing)
when there are missing data present. Will return a data.frame object with the
mean estimates of the stats and their imputed standard deviations
par.strip.text plotting argument passed to lattice
par.settings plotting argument passed to lattice
... additional arguments to be passed to fscores() and lattice
itemfit 61
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Bock, R. D. (1972). Estimating item parameters and latent ability when responses are scored in two
or more nominal categories. Psychometrika, 37, 29-51.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P. & Ng, V. (2017). Plausible-Value Imputation Statistics for Detecting Item Misfit.
Applied Psychological Measurement, 41, 372-387. doi: 10.1177/0146621617692079
Drasgow, F., Levine, M. V., & Williams, E. A. (1985). Appropriateness measurement with poly-
chotomous item response models and standardized indices. British Journal of Mathematical and
Statistical Psychology, 38, 67-86.
Kang, T. & Chen, Troy, T. (2007). An investigation of the performance of the generalized S-X2
item-fit index for polytomous IRT models. ACT
McKinley, R., & Mills, C. (1985). A comparison of several goodness-of-fit statistics. Applied
Psychological Measurement, 9, 49-57.
Orlando, M. & Thissen, D. (2000). Likelihood-based item fit indices for dichotomous item response
theory models. Applied Psychological Measurement, 24, 50-64.
Reise, S. P. (1990). A comparison of item- and person-fit methods of assessing model-data fit in
IRT. Applied Psychological Measurement, 14, 127-137.
Stone, C. A. (2000). Monte Carlo Based Null Distribution for an Alternative Goodness-of-Fit Test
Statistics in IRT Models. Journal of Educational Measurement, 37, 58-75.
Wright B. D. & Masters, G. N. (1982). Rating scale analysis. MESA Press.
Yen, W. M. (1981). Using simulation results to choose a latent trait model. Applied Psychological
Measurement, 5, 245-262.
See Also
personfit, itemGAM
Examples
## Not run:
x <- mirt(data, 1)
raschfit <- mirt(data, 1, itemtype='Rasch')
fit <- itemfit(x)
fit
itemfit(x)
itemfit(x, 'X2') # just X2
itemfit(x, c('S_X2', 'X2')) #both S_X2 and X2
itemfit(x, group.bins=15, empirical.plot = 1) #empirical item plot with 15 points
itemfit(x, group.bins=15, empirical.plot = 21)
# PV and X2* statistics (parametric bootstrap stats not run to save time)
itemfit(x, 'PV_Q1')
#empirical tables
itemfit(x, empirical.table=1)
itemfit(x, empirical.table=21)
#------------------------------------------------------------
itemfit(mod, empirical.plot = 1)
#observed and expected total score patterns for item 1 (post collapsing)
tables$O[[1]]
tables$E[[1]]
# fit stats with missing data (run in parallel using all cores)
data[sample(1:prod(dim(data)), 500)] <- NA
raschfit <- mirt(data, 1, itemtype='Rasch')
#alternative route: use only valid data by removing rows with missing terms
itemfit(raschfit, c('S_X2', 'infit'), na.rm = TRUE)
# note that X2, G2, PV-Q1, and X2* do not require complete datasets
itemfit(raschfit, c('X2', 'G2'))
itemfit(raschfit, empirical.plot=1)
itemfit(raschfit, empirical.table=1)
## End(Not run)
Description
This function uses a generalized additive model (GAM) to estimate response curves for items that
do not seem to fit well in a given model. Using a stable axillary model, traceline functions for poorly
fitting dichotomous or polytomous items can be inspected using point estimates (or plausible values)
of the latent trait. Plots of the tracelines and their associated standard errors are available to help
interpret the misfit. This function may also be useful when adding new items to an existing, well
established set of items, especially when the parametric form of the items under investigation are
unknown.
64 itemGAM
Usage
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
itemfit
itemGAM 65
Examples
## Not run:
set.seed(10)
N <- 1000
J <- 30
a <- matrix(1, J)
d <- matrix(rnorm(J))
Theta <- matrix(rnorm(N, 0, 1.5))
dat <- simdata(a, d, N, itemtype = '2PL', Theta=Theta)
ps2 <- exp(2 * Theta^2 + Theta + .5 * Theta^3) / (1 + exp(2 * Theta^2 + Theta + .5 * Theta^3))
item2 <- sapply(ps2, function(x) sample(c(0,1), size = 1, prob = c(1-x, x)))
# same as above, but with plausible values to obtain the standard errors
set.seed(4321)
ThetaPV <- fscores(mod, plausible.draws=10)
IG0 <- itemGAM(dat[,1], ThetaPV) #good item
IG1 <- itemGAM(baditems[,1], ThetaPV)
IG2 <- itemGAM(baditems[,2], ThetaPV)
66 iteminfo
plot(IG0)
plot(IG1)
plot(IG2)
# splines approach
Theta <- fscores(mod)
IG <- itemGAM(SAT12[,32], Theta)
plot(IG)
set.seed(1423)
ThetaPV <- fscores(mod, plausible.draws=10)
IG2 <- itemGAM(SAT12[,32], ThetaPV)
plot(IG2)
## End(Not run)
Description
Given an internal mirt item object extracted by using extract.item, compute the item information.
Usage
iteminfo(x, Theta, degrees = NULL, total.info = TRUE,
multidim_matrix = FALSE)
Arguments
x an extracted internal mirt object containing item information (see extract.item)
Theta a vector (unidimensional) or matrix (multidimensional) of latent trait values
degrees a vector of angles in degrees that are between 0 and 90. Only applicable when
the input object is multidimensional
total.info logical; return the total information curve for the item? If FALSE, information
curves for each category are returned as a matrix
multidim_matrix
logical; compute the information matrix for each row in Theta? If Theta con-
tains more than 1 row then a list of matrices will be returned, otherwise if Theta
has exactly one row then a matrix will be returned
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.item
Examples
## Not run:
# multidimensional
mod <- mirt(dat, 2, TOL=1e-2)
ii <- extract.item(mod, 1)
Theta <- as.matrix(expand.grid(-4:4, -4:4))
# information matrices
iteminfo(ii, Theta, multidim_matrix = TRUE)
iteminfo(ii, Theta[1, , drop=FALSE], multidim_matrix = TRUE)
## End(Not run)
Description
itemplot displays various item based IRT plots, with special options for plotting items that contain
several 0 slope parameters. Supports up to three dimensional models.
Usage
itemplot(object, item, type = "trace", degrees = 45, CE = FALSE,
CEalpha = 0.05, CEdraws = 1000, drop.zeros = FALSE, theta_lim = c(-6,
6), shiny = FALSE, rot = list(xaxis = -70, yaxis = 30, zaxis = 10),
par.strip.text = list(cex = 0.7), npts = 200,
par.settings = list(strip.background = list(col = "#9ECAE1"), strip.border =
list(col = "black")), auto.key = list(space = "right", points = FALSE, lines
= TRUE), ...)
itemplot 69
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
70 key2binary
Examples
## Not run:
data(LSAT7)
fulldata <- expand.table(LSAT7)
mod1 <- mirt(fulldata,1,SE=TRUE)
mod2 <- mirt(fulldata,1, itemtype = 'Rasch')
mod3 <- mirt(fulldata,2)
itemplot(mod1, 2)
itemplot(mod1, 2, CE = TRUE)
itemplot(mod1, 2, type = 'info')
itemplot(mod1, 2, type = 'info', CE = TRUE)
#multidimensional
itemplot(mod3, 4, type = 'info')
itemplot(mod3, 4, type = 'infocontour')
itemplot(mod3, 4, type = 'tracecontour')
#polytomous items
pmod <- mirt(Science, 1, SE=TRUE)
itemplot(pmod, 3)
itemplot(pmod, 3, CE = TRUE)
itemplot(pmod, 3, type = 'score')
itemplot(pmod, 3, type = 'infotrace')
## End(Not run)
Description
The key2binary function will convert response pattern data to a dichotomous format, given a re-
sponse key.
Usage
key2binary(fulldata, key, score_missing = FALSE)
Arguments
fulldata an object of class data.frame, matrix, or table with the response patterns
key a vector or matrix consisting of the ’correct’ response to the items. Each value/row
corresponds to each column in fulldata. If the input is a matrix, multiple scor-
ing keys can be supplied for each item. NA values are used to indicate no scoring
key (or in the case of a matrix input, no additional scoring keys)
score_missing logical; should missing data elements be returned as incorrect (i.e., 0)? If FALSE,
all missing data terms will be kept as missing
Value
Returns a numeric matrix with all the response patterns in dichotomous format
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
data(SAT12)
head(SAT12)
key <- c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5)
"B","A","D","C","E",
"D","D","D","C","E",
"B","C","A","D","A"), ncol=5, byrow=TRUE))
Description
Lagrange (i.e., score) test to test whether parameters should be freed from a more constrained
baseline model.
Usage
lagrange(mod, parnum, SE.type = "Oakes", type = "Richardson", ...)
Arguments
mod an estimated model
parnum a vector, or list of vectors, containing one or more parameter locations/sets of
locations to be tested. See objects returned from mod2values for the locations
SE.type type of information matrix estimator to use. See mirt for further details
type type of numerical algorithm passed to numerical_deriv to obtain the gradient
terms
... additional arguments to pass to mirt
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
logLik-method 73
See Also
wald
Examples
## Not run:
dat <- expand.table(LSAT7)
mod <- mirt(dat, 1, 'Rasch')
(values <- mod2values(mod))
# test slopes first two slopes and last three slopes jointly
lagrange(mod, list(parnum[1:2], parnum[3:5]))
## End(Not run)
Description
Extract the observed-data log-likelihood.
Usage
## S4 method for signature 'SingleGroupClass'
logLik(object)
74 LSAT6
Arguments
object an object of class SingleGroupClass, MultipleGroupClass, or MixedClass
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1)
logLik(x)
## End(Not run)
Description
Data from Thissen (1982); contains 5 dichotomously scored items obtained from the Law School
Admissions Test, section 6.
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Thissen, D. (1982). Marginal maximum likelihood estimation for the one-parameter logistic model.
Psychometrika, 47, 175-186.
Examples
## Not run:
dat <- expand.table(LSAT6)
head(dat)
model <- 'F = 1-5
CONSTRAIN = (1-5, a1)'
(mod <- mirt(dat, model))
M2(mod)
itemfit(mod)
LSAT7 75
coef(mod, simplify=TRUE)
## End(Not run)
Description
Data from Bock & Lieberman (1970); contains 5 dichotomously scored items obtained from the
Law School Admissions Test, section 7.
Author(s)
References
Bock, R. D., & Lieberman, M. (1970). Fitting a response model for n dichotomously scored items.
Psychometrika, 35(2), 179-197.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
dat <- expand.table(LSAT7)
head(dat)
(mod <- mirt(dat, 1))
coef(mod)
## End(Not run)
76 M2
Description
Computes the M2 (Maydeu-Olivares & Joe, 2006) statistic when all data are dichotomous, the
collapsed M2* statistic (collapsing over univariate and bivariate response categories; see Cai and
Hansen, 2013), and the hybrid C2 statistic which only collapses only the bivariate moments (Cai
and Monro, 2014). The C2 variant is mainly useful when polytomous response models do not
have sufficient degrees of freedom to compute M2*. This function also computes associated fit
indices that are based on fitting the null model. Supports single and multiple-group models. If the
latent trait density was approximated (e.g., Davidian curves, Empirical histograms, etc) then passing
use_dentype_estimate = TRUE will use the internally saved quadrature and density components
(where applicable).
Usage
M2(obj, type = "M2*", calcNull = TRUE, na.rm = FALSE, quadpts = NULL,
theta_lim = c(-6, 6), impute = 0, CI = 0.9, residmat = FALSE,
QMC = FALSE, suppress = 1, ...)
Arguments
obj an estimated model object from the mirt package
type type of fit statistic to compute. Options are "M2", "M2*" for the univariate
and bivariate collapsed version of the M2 statistic ("M2" currently limited to
dichotomous response data only), and "C2" for a hybrid between M2 and M2*
where only the bivariate moments are collapsed
calcNull logical; calculate statistics for the null model as well? Allows for statistics such
as the limited information TLI and CFI. Only valid when items all have a suitable
null model (e.g., those created via createItem will not)
na.rm logical; remove rows with any missing values? The M2 family of statistics
requires a complete dataset in order to be well defined
quadpts number of quadrature points to use during estimation. If NULL, a suitable value
will be chosen based on the rubric found in fscores
theta_lim lower and upper range to evaluate latent trait integral for each dimension
impute a number indicating how many imputations to perform (passed to imputeMissing)
when there are missing data present. This requires a precomputed Theta input.
Will return a data.frame object with the mean estimates of the stats and their
imputed standard deviations
CI numeric value from 0 to 1 indicating the range of the confidence interval for
RMSEA. Default returns the 90% interval
residmat logical; return the residual matrix used to compute the SRMSR statistic? Only
the lower triangle of the residual correlation matrix will be returned (the upper
triangle is filled with NA’s)
M2 77
QMC logical; use quasi-Monte Carlo integration? Useful for higher dimensional mod-
els. If quadpts not specified, 5000 nodes are used by default
suppress a numeric value indicating which parameter residual dependency combinations
to flag as being too high. Absolute values for the standardized residuals greater
than this value will be returned, while all values less than this value will be set
to NA. Must be used in conjunction with the argument residmat = TRUE
... additional arguments to pass
Value
Returns a data.frame object with the M2-type statistic, along with the degrees of freedom, p-value,
RMSEA (with 90% confidence interval), SRMSR for each group (if all items were ordinal), and
optionally the TLI and CFI model fit statistics if calcNull = TRUE.
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Cai, L. & Hansen, M. (2013). Limited-information goodness-of-fit testing of hierarchical item
factor models. British Journal of Mathematical and Statistical Psychology, 66, 245-276.
Cai, L. & Monro, S. (2014). A new statistic for evaluating item response theory models for ordinal
data. National Center for Research on Evaluation, Standards, & Student Testing. Technical Report.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Maydeu-Olivares, A. & Joe, H. (2006). Limited information goodness-of-fit testing in multidimen-
sional contingency tables Psychometrika, 71, 713-732.
Examples
## Not run:
dat <- as.matrix(expand.table(LSAT7))
(mod1 <- mirt(dat, 1))
M2(mod1)
M2(mod1, residmat=TRUE) #lower triangle of residual correlation matrix
# C2 statistic (useful when polytomous IRT models have too few df)
78 marginal_rxx
## End(Not run)
Description
Given an estimated model and a prior density function, compute the marginal reliability. This is
only available for unidimensional tests.
Usage
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
Examples
# marginal estimate
marginal_rxx(mod)
## Not run:
# empirical rxx the alternative way, given theta scores and SEs
fs <- fscores(mod, full.scores.SE=TRUE)
head(fs)
empirical_rxx(fs)
## End(Not run)
Description
Returns a matrix containing the MDIFF values (Reckase, 2009). Only supported for items of class
’dich’ and ’graded’.
Usage
MDIFF(x, which.items = NULL)
Arguments
x an object of class ’SingleGroupClass’
which.items a vector indicating which items to select. If NULL is used (the default) then
MDISC will be computed for all items
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Reckase, M. D. (2009). Multidimensional Item Response Theory. Springer.
80 mdirt
See Also
extract.group, MDISC
Examples
## Not run:
## End(Not run)
Description
mdirt fits a variety of item response models with discrete latent variables. These include, but
are not limited to, latent class analysis, multidimensional latent class models, multidimensional
discrete latent class models, DINA/DINO models, grade of measurement models, C-RUM, and so
on. If response models are not defined explicitly then customized models can defined using the
createItem function.
Usage
mdirt(data, model, customTheta = NULL, structure = NULL, item.Q = NULL,
nruns = 1, method = "EM", covdata = NULL, formula = NULL,
itemtype = "lca", optimizer = "nlminb", return_max = TRUE,
group = NULL, GenRandomPars = FALSE, verbose = TRUE, pars = NULL,
technical = list(), ...)
Arguments
data a matrix or data.frame that consists of numerically ordered data, with missing
data coded as NA
model number of mutually exclusive classes to fit, or alternatively a more specific
mirt.model definition (which reflects the so-called Q-matrix). Note that when
using a mirt.model, the order with which the syntax factors/attributes are de-
fined are associated with the columns in the customTheta input
customTheta input passed to technical = list(customTheta = ...), but is included
directly in this function for convenience. This input is most interesting for dis-
crete latent models because it allows customized patterns of latent classes (i.e.,
defines the possible combinations of the latent attribute profile). The default
mdirt 81
Details
Posterior classification accuracy for each response pattern may be obtained via the fscores func-
tion. The summary() function will display the category probability values given the class member-
ship, which can also be displayed graphically with plot(), while coef() displays the raw coeffi-
cient values (and their standard errors, if estimated). Finally, anova() is used to compare nested
models, while M2 and itemfit may be used for model fitting purposes.
The latent class IRT model with two latent classes has the form
exp(a1θ1 + a2θ2 )
P (x = k|θ1 , θ2 , a1, a2) = PK
j exp(a1θ1 + a2θ2 )
where the θ values generally take on discrete points (such as 0 or 1). For proper identification, the
first category slope parameters (a1 and a2) are never freely estimated. Alternatively, supplying a
different grid of θ values will allow the estimation of similar models (multidimensional discrete
models, grade of membership, etc.). See the examples below.
When the item.Q for is utilized, the above equation can be understood as
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
Examples
#LSAT6 dataset
dat <- expand.table(LSAT6)
#--------------------------
84 mdirt
#-----------------
# Multidimensional discrete latent class model
#-----------------
### DINA model example
# generate some suitable data for a two dimensional DINA application
# (first columns are intercepts)
set.seed(1)
Theta <- expand.table(matrix(c(1,0,0,0, 200,
1,1,0,0, 200,
1,0,1,0, 100,
1,1,1,1, 500), 4, 5, byrow=TRUE))
a <- matrix(c(rnorm(15, -1.5, .5), rlnorm(5, .2, .3), numeric(15), rlnorm(5, .2, .3),
numeric(15), rlnorm(5, .2, .3)), 15, 4)
coef(DINA, simplify=TRUE)
summary(DINA)
M2(DINA) # fits well (as it should)
# good fit, but over-saturated (main effects for items 11-15 can be set to 0)
M2(CRUM)
#------------------
#multidimensional latent class model
C7 = 17-32
C8 = 17-32
C9 = 17-32
C10 = 17-32
CONSTRAIN = (1-16, a1), (1-16, a2), (1-16, a3), (1-16, a4), (1-16, a5),
(17-32, a6), (17-32, a7), (17-32, a8), (17-32, a9), (17-32, a10)')
#------------------
# multiple group with constrained group probabilities
dat <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
group <- rep(c('G1', 'G2'), each = nrow(SAT12)/2)
Theta <- diag(2)
# the latent class parameters are technically located in the (nitems + 1) location
model <- mirt.model('A1 = 1-32
A2 = 1-32
CONSTRAINB = (33, c1)')
mod <- mdirt(dat, model, group = group, customTheta = Theta)
coef(mod, simplify=TRUE)
summary(mod)
## End(Not run)
Description
Returns a vector containing the MDISC values for each item in the model input object (Reckase,
2009).
Usage
MDISC(x)
Arguments
x an object of class ’SingleGroupClass’
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
mirt 87
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Reckase, M. D. (2009). Multidimensional Item Response Theory. Springer.
See Also
extract.group
Examples
## Not run:
## End(Not run)
Description
mirt fits a maximum likelihood (or maximum a posteriori) factor analysis model to any mixture
of dichotomous and polytomous data under the item response theory paradigm using either Cai’s
(2010) Metropolis-Hastings Robbins-Monro (MHRM) algorithm, with an EM algorithm approach
outlined by Bock and Aiken (1981) using rectangular or quasi-Monte Carlo integration grids, or
with the stochastic EM (i.e., the first two stages of the MH-RM algorithm). Models containing
’explanatory’ person or item level predictors can only be included by using the mixedmirt function,
though latent regression models can be fit using the formula input in this function. Tests that
form a two-tier or bi-factor structure should be estimated with the bfactor function, which uses a
dimension reduction EM algorithm for modeling item parcels. Multiple group analyses (useful for
DIF and DTF testing) are also available using the multipleGroup function.
Usage
mirt(data, model, itemtype = NULL, guess = 0, upper = 1, SE = FALSE,
covdata = NULL, formula = NULL, SE.type = "Oakes", method = "EM",
optimizer = NULL, dentype = "Gaussian", pars = NULL, constrain = NULL,
parprior = NULL, calcNull = FALSE, draws = 5000,
survey.weights = NULL, quadpts = NULL, TOL = NULL, gpcm_mats = list(),
grsm.block = NULL, rsm.block = NULL, monopoly.k = 1L, key = NULL,
large = FALSE, GenRandomPars = FALSE, accelerate = "Ramsay",
verbose = TRUE, solnp_args = list(), nloptr_args = list(),
spline_args = list(), control = list(), technical = list(), ...)
88 mirt
Arguments
data a matrix or data.frame that consists of numerically ordered data, with missing
data coded as NA (to convert from an ordered factor data.frame see data.matrix)
model a string to be passed (or an object returned from) mirt.model, declaring how the
IRT model is to be estimated (loadings, constraints, priors, etc). For exploratory
IRT models, a single numeric value indicating the number of factors to extract
is also supported
itemtype type of items to be modeled, declared as a vector for each item or a single value
which will be recycled for each item. The NULL default assumes that the items
follow a graded or 2PL structure, however they may be changed to the following:
• 'Rasch' - Rasch/partial credit model by constraining slopes to 1 and freely
estimating the variance parameters (alternatively, can be specified by ap-
plying equality constraints to the slope parameters in 'gpcm'; Rasch, 1960)
• '2PL', '3PL', '3PLu', and '4PL' - 2-4 parameter logistic model, where
3PL estimates the lower asymptote only while 3PLu estimates the upper
asymptote only (Lord and Novick, 1968; Lord, 1980)
• 'graded' - graded response model (Samejima, 1969)
• 'grsm' and 'grsmIRT' - graded ratings scale model in the slope-intercept
and classical IRT parameterization. 'grsmIRT' is restricted to unidimen-
sional models (Muraki, 1992)
• 'gpcm' and 'gpcmIRT' - generalized partial credit model in the slope-
intercept and classical parameterization. 'gpcmIRT' is restricted to uni-
dimensional models. Note that optional scoring matrices for 'gpcm' are
available with the gpcm_mats input (Muraki, 1992)
• 'rsm' - Rasch rating scale model using the 'gpcmIRT' structure (unidi-
mensional only; Andrich, 1978)
• 'nominal' - nominal response model (Bock, 1972)
• 'ideal' - dichotomous ideal point model (Maydeu-Olivares, 2006)
• 'ggum' - generalized graded unfolding model (Roberts, Donoghue, & Laugh-
lin, 2000) and its multidimensional extension
• 'sequential' - multidimensional sequential response model (Tutz, 1990)
in slope-intercept form
• 'Tutz' - same as the 'sequential' itemtype, except the slopes are fixed to
1 and the latent variance terms are freely estimated (similar to the 'Rasch'
itemtype input)
• 'PC2PL' and 'PC3PL' - 2-3 parameter partially compensatory model. Note
that constraining the slopes to be equal across items will reduce the model
to Embretson’s (a.k.a. Whitely’s) multicomponent model (1980).
• '2PLNRM', '3PLNRM', '3PLuNRM', and '4PLNRM' - 2-4 parameter nested
logistic model, where 3PLNRM estimates the lower asymptote only while
3PLuNRM estimates the upper asymptote only (Suh and Bolt, 2010)
• 'spline' - spline response model with the bs (default) or the ns function
(Winsberg, Thissen, and Wainer, 1984)
• 'monopoly' - monotonic polynomial model for unidimensional tests for
dichotomous and polytomous response data (Falk and Cai, 2016)
mirt 89
Additionally, user defined item classes can also be defined using the createItem
function
guess fixed pseudo-guessing parameters. Can be entered as a single value to assign a
global guessing parameter or may be entered as a numeric vector corresponding
to each item
upper fixed upper bound parameters for 4-PL model. Can be entered as a single value
to assign a global guessing parameter or may be entered as a numeric vector
corresponding to each item
SE logical; estimate the standard errors by computing the parameter information
matrix? See SE.type for the type of estimates available
covdata a data.frame of data used for latent regression models
formula an R formula (or list of formulas) indicating how the latent traits can be regressed
using external covariates in covdata. If a named list of formulas is supplied
(where the names correspond to the latent trait names in model) then specific
regression effects can be estimated for each factor. Supplying a single formula
will estimate the regression parameters for all latent traits by default
SE.type type of estimation method to use for calculating the parameter information ma-
trix for computing standard errors and wald tests. Can be:
• 'Richardson', 'forward', or 'central' for the numerical Richardson,
forward difference, and central difference evaluation of observed Hessian
matrix
• 'crossprod' and 'Louis' for standard error computations based on the
variance of the Fisher scores as well as Louis’ (1982) exact computation of
the observed information matrix. Note that Louis’ estimates can take a long
time to obtain for large sample sizes and long tests
• 'sandwich' for the sandwich covariance estimate based on the 'crossprod'
and 'Oakes' estimates (see Chalmers, in press, for details)
• 'sandwich.Louis' for the sandwich covariance estimate based on the 'crossprod'
and 'Louis' estimates
• 'Oakes' for Oakes’ (1999) method using a central difference approxima-
tion (see Chalmers, in press, for details)
• 'SEM' for the supplemented EM (disables the accelerate option automat-
ically; EM only)
• 'Fisher' for the expected information, 'complete' for information based
on the complete-data Hessian used in EM algorithm
• 'MHRM' and 'FMHRM' for stochastic approximations of observed informa-
tion matrix based on the Robbins-Monro filter or a fixed number of MHRM
draws without the RM filter. These are the only options supported when
method = 'MHRM'
• 'numerical' to obtain the numerical estimate from a call to optim when
method = 'BL'
Note that both the 'SEM' method becomes very sensitive if the ML solution
has has not been reached with sufficient precision, and may be further sensitive
if the history of the EM cycles is not stable/sufficient for convergence of the
respective estimates. Increasing the number of iterations (increasing NCYCLES
90 mirt
and decreasing TOL, see below) will help to improve the accuracy, and can be run
in parallel if a mirtCluster object has been defined (this will be used for Oakes’
method as well). Additionally, inspecting the symmetry of the ACOV matrix for
convergence issues by passing technical = list(symmetric = FALSE) can
be helpful to determine if a sufficient solution has been reached
method a character object specifying the estimation algorithm to be used. The default is
'EM', for the standard EM algorithm with fixed quadrature, 'QMCEM' for quasi-
Monte Carlo EM estimation, or 'MCEM' for Monte Carlo EM estimation. The
option 'MHRM' may also be passed to use the MH-RM algorithm, 'SEM' for
the Stochastic EM algorithm (first two stages of the MH-RM stage using an
optimizer other than a single Newton-Raphson iteration), and 'BL' for the Bock
and Lieberman approach (generally not recommended for longer tests).
The 'EM' is generally effective with 1-3 factors, but methods such as the 'QMCEM',
'MCEM', 'SEM', or 'MHRM' should be used when the dimensions are 3 or more.
Note that when the optimizer is stochastic the associated SE.type is automati-
cally changed to SE.type = 'MHRM' by default to avoid the use of quadrature
optimizer a character indicating which numerical optimizer to use. By default, the EM
algorithm will use the 'BFGS' when there are no upper and lower bounds box-
constraints and 'nlminb' when there are.
Other options include the Newton-Raphson ('NR'), which can be more efficient
than the 'BFGS' but not as stable for more complex IRT models (such as the
nominal or nested logit models) and the related 'NR1' which is also the Newton-
Raphson but consists of only 1 update that has been coupled with RM Hessian
(only applicable when the MH-RM algorithm is used). The MH-RM algorithm
uses the 'NR1' by default, though currently the 'BFGS', 'L-BFGS-B', and 'NR'
are also supported with this method (with fewer iterations by default) to emulate
stochastic EM updates. As well, the 'Nelder-Mead' and 'SANN' estimators are
available, but their routine use generally is not required or recommended.
Additionally, estimation subroutines from the Rsolnp and nloptr packages are
available by passing the arguments 'solnp' and 'nloptr', respectively. This
should be used in conjunction with the solnp_args and nloptr_args speci-
fied below. If equality constraints were specified in the model definition only
the parameter with the lowest parnum in the pars = 'values' data.frame
is used in the estimation vector passed to the objective function, and group
hyper-parameters are omitted. Equality an inequality functions should be of
the form function(p, optim_args), where optim_args is a list of internally
parameters that largely can be ignored when defining constraints (though use of
browser() here may be helpful)
dentype type of density form to use for the latent trait parameters. Current options in-
clude
• 'Gaussian' (default) assumes a multivariate Gaussian distribution with an
associated mean vector and variance-covariance matrix
• 'empiricalhist' or 'EH' estimates latent distribution using an empirical
histogram described by Bock and Aitkin (1981). Only applicable for uni-
dimensional models estimated with the EM algorithm. For this option, the
number of cycles, TOL, and quadpts are adjusted accommodate for less
mirt 91
quadpts number of quadrature points per dimension (must be larger than 2). By default
the number of quadrature uses the following scheme: switch(as.character(nfact), '1'=61, '2'=31
However, if the method input is set to 'QMCEM' and this argument is left blank
then the default number of quasi-Monte Carlo integration nodes will be set to
5000 in total
TOL convergence threshold for EM or MH-RM; defaults are .0001 and .001. If
SE.type = 'SEM' and this value is not specified, the default is set to 1e-5.
If dentype = 'empiricalhist' (i.e., 'EH') or 'empiricalhist_Woods' (i.e.,
'EHW') and TOL is not specified then the default 3e-5 will be used. To evaluate
the model using only the starting values pass TOL = NaN, and to evaluate the
starting values without the log-likelihood pass TOL = NA
gpcm_mats a list of matrices specifying how the scoring coefficients in the (generalized)
partial credit model should be constructed. If omitted, the standard gpcm format
will be used (i.e., seq(0, k, by = 1) for each trait). This input should be used
if traits should be scored different for each category (e.g., matrix(c(0:3, 1,0,0,0), 4, 2)
for a two-dimensional model where the first trait is scored like a gpcm, but the
second trait is only positively indicated when the first category is selected). Can
be used when itemtypes are 'gpcm' or 'Rasch', but only when the respective
element in gpcm_mats is not NULL
grsm.block an optional numeric vector indicating where the blocking should occur when
using the grsm, NA represents items that do not belong to the grsm block (other
items that may be estimated in the test data). For example, to specify two blocks
of 3 with a 2PL item for the last item: grsm.block = c(rep(1,3), rep(2,3), NA).
If NULL the all items are assumed to be within the same group and therefore
have the same number of item categories
rsm.block same as grsm.block, but for 'rsm' blocks
monopoly.k a vector of values (or a single value to repeated for each item) which indicate
the degree of the monotone polynomial fitted, where the monotone polynomial
corresponds to monopoly.k * 2 + 1 (e.g., monopoly.k = 2 fits a 5th degree
polynomial). Default is monopoly.k = 1, which fits a 3rd degree polynomial
key a numeric vector of the response scoring key. Required when using nested logit
item types, and must be the same length as the number of items used. Items that
are not nested logit will ignore this vector, so use NA in item locations that are
not applicable
large either a logical, indicating whether the internal collapsed data should be re-
turned, or a list of internally computed data tables. If TRUE is passed, a list
containing the organized tables is returned. This list object can then be passed
back into large to avoid reorganizing the data again (useful when the dataset are
very large and computing the tabulated data is computationally burdensome).
The best strategy for large data is to always pass the internal data to the estima-
tion function, shown below:
Compute organized data e.g., internaldat <- mirt(Science, 1, large = TRUE)
Pass the organized data to all estimation functions e.g., mod <- mirt(Science, 1, large = intern
GenRandomPars logical; generate random starting values prior to optimization instead of using
the fixed internal starting values?
mirt 93
accelerate a character vector indicating the type of acceleration to use. Default is 'Ramsay',
but may also be 'squarem' for the SQUAREM procedure (specifically, the
gSqS3 approach) described in Varadhan and Roldand (2008). To disable the
acceleration, pass 'none'
verbose logical; print observed- (EM) or complete-data (MHRM) log-likelihood after
each iteration cycle? Default is TRUE
solnp_args a list of arguments to be passed to the solnp::solnp() function for equality
constraints, inequality constraints, etc
nloptr_args a list of arguments to be passed to the nloptr::nloptr() function for equality
constraints, inequality constraints, etc
spline_args a named list of lists containing information to be passed to the bs (default) and
ns for each spline itemtype. Each element must refer to the name of the itemtype
with the spline, while the internal list names refer to the arguments which are
passed. For example, if item 2 were called ’read2’, and item 5 were called
’read5’, both of which were of itemtype ’spline’ but item 5 should use the ns
form, then a modified list for each input might be of the form:
spline_args = list(read2 = list(degree = 4), read5 = list(fun = 'n
This code input changes the bs() splines function to have a degree = 4 in-
put, while the second element changes to the ns() function with knots set a
c(-2, 2)
control a list passed to the respective optimizers (i.e., optim(), nlminb(), etc). Ad-
ditional arguments have been included for the 'NR' optimizer: 'tol' for the
convergence tolerance in the M-step (default is TOL/1000), while the default
number of iterations for the Newton-Raphson optimizer is 50 (modified with the
'maxit' control input)
technical a list containing lower level technical parameters for estimation. May be:
NCYCLES maximum number of EM or MH-RM cycles; defaults are 500 and
2000
MAXQUAD maximum number of quadratures, which you can increase if you
have more than 4GB or RAM on your PC; default 20000
theta_lim range of integration grid for each dimension; default is c(-6, 6)
set.seed seed number used during estimation. Default is 12345
SEtol standard error tolerance criteria for the S-EM and MHRM computation
of the information matrix. Default is 1e-3
symmetric logical; force S-EM/Oakes information matrix estimates to be sym-
metric? Default is TRUE so that computation of standard errors are more
stable. Setting this to FALSE can help to detect solutions that have not
reached the ML estimate
SEM_window ratio of values used to define the S-EM window based on the ob-
served likelihood differences across EM iterations. The default is c(0, 1 - SEtol),
which provides nearly the very full S-EM window (i.e., nearly all EM cy-
cles used). To use the a smaller SEM window change the window to to
something like c(.9, .999) to start at a point farther into the EM history
warn logical; include warning messages during estimation? Default is TRUE
message logical; include general messages during estimation? Default is TRUE
94 mirt
the iteration number of the EM cycle. Default is function(cycles) 500 + (cycles - 1)*2,
which starts the number of draws at 500 and increases by 2 after each full
EM iteration
info_if_converged logical; compute the information matrix when using the
MH-RM algorithm only if the model converged within a suitable number
of iterations? Default is TRUE
loglik_if_converged logical; compute the observed log-likelihood when using
the MH-RM algorithm only if the model converged within a suitable num-
ber of iterations? Default is TRUE
keep_vcov_PD logical; attempt to keep the variance-covariance matrix of the
latent traits positive definite during estimation in the EM algorithm? This
generally improves the convergence properties when the traits are highly
correlated. Default is TRUE
... additional arguments to be passed
Value
function returns an object of class SingleGroupClass (SingleGroupClass-class)
mirt.model Define the IRT model specification use special syntax. Useful for defining between
and within group parameter constraints, prior parameter distributions, and specifying the slope
coefficients for each factor
coef-method Extract raw coefficients from the model, along with their standard errors and confi-
dence intervals
summary-method Extract standardized loadings from model. Accepts a rotate argument for ex-
ploratory item response model
anova-method Compare nested models using likelihood ratio statistics as well as information cri-
teria such as the AIC and BIC
residuals-method Compute pairwise residuals between each item using methods such as the LD
statistic (Chen & Thissen, 1997), as well as response pattern residuals
plot-method Plot various types of test level plots including the test score and information func-
tions and more
itemplot Plot various types of item level plots, including the score, standard error, and information
functions, and more
createItem Create a customized itemtype that does not currently exist in the package
imputeMissing Impute missing data given some computed Theta matrix
fscores Find predicted scores for the latent traits using estimation methods such as EAP, MAP,
ML, WLE, and EAPsum
mirt 97
wald Compute Wald statistics follow the convergence of a model with a suitable information matrix
M2 Limited information goodness of fit test statistic based to determine how well the model fits the
data
itemfit and personfit Goodness of fit statistics at the item and person levels, such as the S-X2,
infit, outfit, and more
boot.mirt Compute estimated parameter confidence intervals via the bootstrap methods
mirtCluster Define a cluster for the package functions to use for capitalizing on multi-core ar-
chitecture to utilize available CPUs when possible. Will help to decrease estimation times for
tasks that can be run in parallel
IRT Models
The parameter labels use the follow convention, here using two factors and k as the number of
categories.
Rasch Only one intercept estimated, and the latent variance of θ is freely estimated. If the data
have more than two categories then a partial credit model is used instead (see ’gpcm’ below).
1
P (x = 1|θ, d) =
1 + exp(−(θ + d))
(u − g)
P (x = 1|θ, ψ) = g +
1 + exp(−(a1 ∗ θ1 + a2 ∗ θ2 + d))
graded The graded model consists of sequential 2PL models, and here k is the predicted category.
grsm and grsmIRT A more constrained version of the graded model where graded spacing is
equal across item blocks and only adjusted by a single ’difficulty’ parameter (c) while the
latent variance of θ is freely estimated. Again,
but now
1
P =
1 + exp(−(a1 ∗ θ1 + a2 ∗ θ2 + dk + c))
The grsmIRT model is similar to the grsm item type, but uses the IRT parameterization in-
stead (see Muraki, 1990 for this exact form). This is restricted to unidimensional models
only, whereas grsm may be used for unidimensional or multidimensional models and is more
consistent with the form of other IRT models in mirt
gpcm/nominal For the gpcm the d values are treated as fixed and ordered values from 0:(k-1) (in
the nominal model d0 is also set to 0). Additionally, for identification in the nominal model
ak0 = 0, ak(k−1) = (k − 1).
For the partial credit model (when itemtype = 'Rasch'; unidimensional only) the above
model is further constrained so that ak = (0, 1, . . . , k − 1), a1 = 1, and the latent variance of
θ1 is freely estimated. Alternatively, the partial credit model can be obtained by containing all
the slope parameters in the gpcms to be equal. More specific scoring function may be included
by passing a suitable list or matrices to the gpcm_mats input argument.
In the nominal model this parametrization helps to identify the empirical ordering of the cat-
egories by inspecting the ak values. Larger values indicate that the item category is more
positively related to the latent trait(s) being measured. For instance, if an item was truly
ordinal (such as a Likert scale), and had 4 response categories, we would expect to see
ak0 < ak1 < ak2 < ak3 following estimation. If on the other hand ak0 > ak1 then it
would appear that the second category is less related to to the trait than the first, and therefore
the second category should be understood as the ’lowest score’.
NOTE: The nominal model can become numerical unstable if poor choices for the high and
low values are chosen, resulting in ak values greater than abs(10) or more. It is recommended
to choose high and low anchors that cause the estimated parameters to fall between 0 and the
number of categories - 1 either by theoretical means or by re-estimating the model with better
values following convergence.
gpcmIRT and rsm The gpcmIRT model is the classical generalized partial credit model for unidi-
mensional response data. It will obtain the same fit as the gpcm presented above, however the
parameterization allows for the Rasch/generalized rating scale model as a special case.
E.g., for a 4 category response model,
P (x = 0|θ, ψ) = exp(1)/G
G = exp(1)+exp(1+a(θ−b1)+c)+exp(1+a(2θ−b1−b2)+2c)+a(3θ−b1−b2−b3)+3c)
Here a is the slope parameter, the b parameters are the threshold values for each adjacent cate-
gory, and c is the so-called difficulty parameter when a rating scale model is fitted (otherwise,
c = 0 and it drops out of the computations).
The gpcmIRT can be constrained to the partial credit IRT model by either constraining all the
slopes to be equal, or setting the slopes to 1 and freeing the latent variance parameter.
Finally, the rsm is a more constrained version of the (generalized) partial credit model where
the spacing is equal across item blocks and only adjusted by a single ’difficulty’ parameter (c).
Note that this is analogous to the relationship between the graded model and the grsm (with
an additional constraint regarding the fixed discrimination parameters).
sequential/Tutz The multidimensional sequential response model has the form
Y
P (x = k|θ, ψ) = (1 − F (a1 θ1 + a2 θ2 + dsk ))F (a1 θ1 + a2 θ2 + djk )
where F (·) is the cumulative logistic function. The Tutz variant of this model (Tutz, 1990) (via
itemtype = 'Tutz') assumes that the slope terms are all equal to 1 and the latent variance
terms are estimated (i.e., is a Rasch variant).
mirt 99
ideal The ideal point model has the form, with the upper bound constraint on d set to 0:
partcomp Partially compensatory models consist of the product of 2PL probability curves.
1 1
P (x = 1|θ, ψ) = g + (1 − g)( ∗ )
1 + exp(−(a1 ∗ θ1 + d1 )) 1 + exp(−(a2 ∗ θ2 + d2 ))
Note that constraining the slopes to be equal across items will reduce the model to Embretson’s
(a.k.a. Whitely’s) multicomponent model (1980).
2-4PLNRM Nested logistic curves for modeling distractor items. Requires a scoring key. The
model is broken into two components for the probability of endorsement. For successful
endorsement the probability trace is the 1-4PL model, while for unsuccessful endorsement:
which is the product of the complement of the dichotomous trace line with the nominal re-
sponse model. In the nominal model, the slope parameters defined above are constrained to
be 1’s, while the last value of the ak is freely estimated.
ggum The (multidimensional) generalized graded unfolding model is a class of ideal point models
useful for ordinal response data. The form is
q qP
PD 2 (θ 2 +
Pz D 2 2
exp z a
d=1 id jd − bid ) ψ
k=0 ik + exp (M − z) d=1 aid (θjd − bid )
P (z = k|θ, ψ) = q qP
PC PD 2 (θ 2 +
Pz D 2
w=0 exp w a
d=1 id jd − b id ) k=0 ψ ik + exp (M − w) d=1 aid (θjd − b
where θjd is the location of the jth individual on the dth dimension, bid is the difficulty location
of the ith item on the dth dimension, aid is the discrimination of the jth individual on the dth
dimension (where the discrimination values are constrained to be positive), ψik is the kth
subjective response category threshold for the ith item,
PD assumed to be symmetric about the
item and constant across dimensions, where ψik = d=1 aid tik z = 1, 2, . . . , C (where C is
the number of categories minus 1), and M = 2C + 1.
spline Spline response models attempt to model the response curves uses non-linear and potentially
non-monotonic patterns. The form is
1
P (x = 1|θ, η) =
1 + exp(−(η1 ∗ X1 + η2 ∗ X2 + · · · + ηn ∗ Xn ))
where the Xn are from the spline design matrix X organized from the grid of θ values. B-
splines with a natural or polynomial basis are supported, and the intercept input is set to
TRUE by default.
monopoly Monotone polynomial model for polytomous response data of the form
Pk
exp( 1 (m∗ (ψ) + ξc−1 )
P (x = k|θ, ψ) = PC Pk ∗
1 exp( 1 (m (ψ) + ξc−1 ))
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Andrich, D. (1978). A rating scale formulation for ordered response categories. Psychometrika, 43,
561-573.
Bock, R. D., & Aitkin, M. (1981). Marginal maximum likelihood estimation of item parameters:
Application of an EM algorithm. Psychometrika, 46(4), 443-459.
Bock, R. D., Gibbons, R., & Muraki, E. (1988). Full-Information Item Factor Analysis. Applied
Psychological Measurement, 12(3), 261-280.
Bock, R. D. & Lieberman, M. (1970). Fitting a response model for n dichotomously scored items.
Psychometrika, 35, 179-197.
Cai, L. (2010a). High-Dimensional exploratory item factor analysis by a Metropolis-Hastings
Robbins-Monro algorithm. Psychometrika, 75, 33-57.
Cai, L. (2010b). Metropolis-Hastings Robbins-Monro algorithm for confirmatory item factor anal-
ysis. Journal of Educational and Behavioral Statistics, 35, 307-335.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P. (2015). Extended Mixed-Effects Item Response Models with the MH-RM Algo-
rithm. Journal of Educational Measurement, 52, 200-222. doi: 10.1111/jedm.12072
Chalmers, R. P. (in press). Numerical Approximation of the ObservedInformation Matrix with
Oakes’ Identity. British Journal of Mathematical and Statistical Psychology DOI: 10.1111/bmsp.12127
Chalmers, R., P. & Flora, D. (2014). Maximum-likelihood Estimation of Noncompensatory IRT
Models with the MH-RM Algorithm. Applied Psychological Measurement, 38, 339-358. doi: 10.1177/
0146621614520958
Chen, W. H. & Thissen, D. (1997). Local dependence indices for item pairs using item response
theory. Journal of Educational and Behavioral Statistics, 22, 265-289.
Falk, C. F. & Cai, L. (2016). Maximum Marginal Likelihood Estimation of a Monotonic Polynomial
Generalized Partial Credit Model with Applications to Multiple Group Analysis. Psychometrika,
81, 434-460.
Lord, F. M. & Novick, M. R. (1968). Statistical theory of mental test scores. Addison-Wesley.
Ramsay, J. O. (1975). Solving implicit equations in psychometric data analysis. Psychometrika, 40,
337-360.
Rasch, G. (1960). Probabilistic models for some intelligence and attainment tests. Danish Institute
for Educational Research.
Roberts, J. S., Donoghue, J. R., & Laughlin, J. E. (2000). A General Item Response Theory Model
for Unfolding Unidimensional Polytomous Responses. Applied Psychological Measurement, 24,
3-32.
mirt 101
See Also
bfactor, multipleGroup, mixedmirt, expand.table, key2binary, mod2values, extract.item,
iteminfo, testinfo, probtrace, simdata, averageMI, fixef, extract.mirt
Examples
## Not run:
(mod2 <- mirt(data, 1, SE = TRUE)) #standard errors via the Oakes method
(mod2 <- mirt(data, 1, SE = TRUE, SE.type = 'SEM')) #standard errors with SEM method
coef(mod2)
102 mirt
(mod3 <- mirt(data, 1, SE = TRUE, SE.type = 'Richardson')) #with numerical Richardson method
residuals(mod1)
plot(mod1) #test score function
plot(mod1, type = 'trace') #trace lines
plot(mod2, type = 'info') #test information
plot(mod2, MI=200) #expected total score with 95% confidence intervals
#internally g and u pars are stored as logits, so usually a good idea to include normal prior
# to help stabilize the parameters. For a value around .182 use a mean
# of -1.5 (since 1 / (1 + exp(-(-1.5))) == .182)
model <- 'F = 1-5
PRIOR = (5, g, norm, -1.5, 3)'
mod1.3PL.norm <- mirt(data, model, itemtype = c('2PL', '2PL', '2PL', '2PL', '3PL'))
coef(mod1.3PL.norm)
#limited information fit statistics
M2(mod1.3PL.norm)
#confirmatory (as an example, model is not identified since you need 3 items per factor)
# Two ways to define a confirmatory model: with mirt.model, or with a string
anova(cmod, mod2)
#check if identified by computing information matrix
(cmod <- mirt(data, cmodel, SE = TRUE))
###########
#data from the 'ltm' package in numeric format
pmod1 <- mirt(Science, 1)
plot(pmod1)
plot(pmod1, type = 'trace')
plot(pmod1, type = 'itemscore')
summary(pmod1)
#Constrain all slopes to be equal with the constrain = list() input or mirt.model() syntax
#first obtain parameter index
values <- mirt(Science,1, pars = 'values')
values #note that slopes are numbered 1,5,9,13, or index with values$parnum[values$name == 'a1']
(pmod1_equalslopes <- mirt(Science, 1, constrain = list(c(1,5,9,13))))
coef(pmod1_equalslopes)
coef(pmod1_equalslopes)
anova(pmod1_equalslopes, pmod1) #significantly worse fit with almost all criteria
#for the nominal model the lowest and highest categories are assumed to be the
# theoretically lowest and highest categories that related to the latent trait(s)
(nomod <- mirt(Science, 1, 'nominal'))
coef(nomod) #ordering of ak values suggest that the items are indeed ordinal
anova(gpcmod, nomod)
itemplot(nomod, 3)
###########
#empirical dimensionality testing that includes 'guessing'
data(SAT12)
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
#same as above, but using the QMCEM method for generally better accuracy in mod3
mod3 <- mirt(data, 3, method = 'QMCEM', TOL = .001, optimizer = 'NR')
anova(mod2, mod3)
###########
#graded rating scale example
coef(mod2)
anova(mod2, mod1) #not sig, mod2 should be preferred
itemplot(mod2, 1)
itemplot(mod2, 5)
itemplot(mod2, 10)
###########
# 2PL nominal response model example (Suh and Bolt, 2010)
data(SAT12)
SAT12[SAT12 == 8] <- NA #set 8 as a missing value
head(SAT12)
#test information
plot(Theta, testinfo(mod2, Theta), type = 'l', main = 'Test information', ylab = 'Information')
lines(Theta, testinfo(mod0, Theta), col = 'red')
###########
# using the MH-RM algorithm
data(LSAT7)
fulldata <- expand.table(LSAT7)
(mod1 <- mirt(fulldata, 1, method = 'MHRM'))
#Confirmatory models
#simulate data
a <- matrix(c(
106 mirt
1.5,NA,
0.5,NA,
1.0,NA,
1.0,0.5,
NA,1.5,
NA,0.5,
NA,1.0,
NA,1.0),ncol=2,byrow=TRUE)
d <- matrix(c(
-1.0,NA,NA,
-1.5,NA,NA,
1.5,NA,NA,
0.0,NA,NA,
3.0,2.0,-0.5,
2.5,1.0,-1,
2.0,0.0,NA,
1.0,NA,NA),ncol=3,byrow=TRUE)
#analyses
#CIFA for 2 factor crossed structure
#####
#bifactor
model.3 <- '
G = 1-8
F1 = 1-4
F2 = 5-8'
#####
mirt 107
#polynomial/combinations
data(SAT12)
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
#####
# non-linear parameter constraints with Rsolnp package (nloptr supported as well):
108 mirt
# Find Rasch model subject to the constraint that the intercepts sum to 0
#constraint: create function for solnp to compute constraint, and declare value in eqB
eqfun <- function(p, optim_args) sum(p[1:5]) #could use browser() here, if it helps
LB <- c(rep(-15, 6), 1e-4) # more reasonable lower bound for variance term
#######
# latent regression Rasch model
#simulate data
set.seed(1234)
N <- 1000
# covariates
X1 <- rnorm(N); X2 <- rnorm(N)
covdata <- data.frame(X1, X2)
Theta <- matrix(0.5 * X1 + -1 * X2 + rnorm(N, sd = 0.5))
############
# Example using Gauss-Hermite quadrature with custom input functions
library(fastGHQuad)
data(SAT12)
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
GH <- gaussHermiteData(50)
Theta <- matrix(GH$x)
############
# Davidian curve example
## End(Not run)
Description
The mirt.model function scans/reads user input to specify the confirmatory model. Item locations
must be used in the specifications if no itemnames argument is supplied. This is called implicitly
by estimation functions when a string is passed to the model argument.
Usage
mirt.model(input = NULL, itemnames = NULL, file = "", COV = NULL,
quiet = TRUE, ...)
Arguments
input input for writing out the model syntax. Can either be a string declaration of class
character or the so-called Q-matrix or class matrix that specifies the model ei-
ther with integer or logical values. If the Q-matrix method is chosen covariances
terms can be specified with the COV input
itemnames a character vector or factor indicating the item names. If a data.frame or matrix
object is supplied the names will be extracted using colnames(itemnames).
Supplying this input allows the syntax to be specified with the raw item names
rather than item locations
file a input specifying an external file that declares the input.
COV a symmetric, logical matrix used to declare which covariance terms are esti-
mated
quiet logical argument passed to scan() to suppress console read message
... additional arguments for scan()
Details
Factors are first named and then specify which numerical items they affect (i.e., where the slope is
not equal to 0), separated either by commas or by - to indicate a range of items. Products between
factors may be specified by enclosing the left hand term within brackets. To finish the declaration
of a model simply enter a blank line with only a carriage return (i.e., the ’enter’ or ’return’ key), or
instead read in an input version of the model syntax. The associated slopes throughout the package
mirt.model 111
label these coefficients as a1, a2, ..., ak, where the associated number is assigned according
to the respective order of the defined factors.
For example, if the syntax were
"G = 1-10 F = 1-5 A = 6-10"
then the G factor would be assigned the slopes a1 for each item, F assigned the slopes a2, and A
assigned the slopes a3. The same principle applies to the bfactor function whereby the slopes are
automatically included for the specific factors after the general factor structure has been assigned.
There is an optional keyword for specifying the correlation between relationships between factors
called COV, and non-linear factor products can be included by enclosing the product combination on
the left hand side of the declaration (e.g., (F1*F1) would create a quadratic factor for F1).
The keywords CONSTRAIN, CONSTRAINB, PRIOR, FIXED, FREE, START, UBOUND, LBOUND
can be applied to specific sub-groups in multiple-group models by included square brackets before
the = sign, where groups are separated by commas. For example, to apply within-group equality
constraints to a group called "male", then specifying:
CONSTRAIN [male] = (1-5, a1)
is appropriate, while specifying the same constraints to the sub-groups "male" and "female" would
appear as
CONSTRAIN [male, female] = (1-5, a1)
For all other groups in the multi-group model, these within-group equality constraints would not
appear. Therefore, these bracketed group specifications are useful when modifying priors, starting
values, between/within group equality constraints, and so on when the specifications for each sub-
group may differ.
Finally, the keyword GROUP can be used to specify the group-level hyper-parameter terms, such as
the means and variance of the default Gaussian distribution. For example, to set the starting value
of the variance parameter (COV_11) to 1.5:
START = (GROUP, COV_11, 1.5)
COV Specify the relationship between the latent factors. Estimating a correlation between factors
is declared by joining the two factors with an asterisk (e.g., F1*F2), or with an asterisk between
three or more factors to estimate all the possible correlations (e.g., F1*F2*F3)
MEAN A comma separated list specifying which latent factor means to freely estimate. E.g.,
MEAN = F1, F2 will free the latent means for factors F1 and F2
CONSTRAIN A bracketed, comma separated list specifying equality constrains between items.
The input format is CONSTRAIN = (items, ..., parameterName(s)), (items, ..., parameterName).
For example, in a single group 10-item dichotomous tests, using the default 2PL model, the
first and last 5 item slopes (a1) can be constrained to be equal by using CONSTRAIN = (1-5, a1), (6-10, a1),
or some combination such as CONSTRAIN = (1-3,4,5,a1), (6,7,8-10,a1).
When constraining parameters to be equal across items with different parameter names, a
balanced bracketed vector must be supplied. E.g., setting the first slope for item 1 equal to the
second slope in item 3 would be CONSTRAIN = (1, 3, a1, a2)
CONSTRAINB A bracketed, comma separate list specifying equality constrains between groups.
The input format is CONSTRAINB = (items, ..., parameterName), (items, ..., parameterName).
For example, in a two group 10-item dichotomous tests, using the default 2PL model, the first 5
item slopes (a1) can be constrained to be equal across both groups by using CONSTRAINB = (1-5, a1),
or some combination such as CONSTRAINB = (1-3,4,5,a1)
112 mirt.model
PRIOR A bracketed, comma separate list specifying prior parameter distributions. The input for-
mat is PRIOR = (items, ..., parameterName, priorType, val1, val2), (items, ..., parameterName, prio
For example, in a single group 10-item dichotomous tests, using the default 2PL model, defin-
ing a normal prior of N(0,2) for the first 5 item intercepts (d) can be defined by PRIOR = (1-5, d, norm, 0, 2)
Currently supported priors are of the form: (items, norm, mean, sd) for the normal/Gaussian,
(items, lnorm, log_mean, log_sd) for log-normal, (items, beta, alpha, beta) for
beta, and (items, expbeta, alpha, beta) for the beta distribution after applying the
function plogis to the input value (note, this is specifically for applying a beta prior to the
lower-bound parameters in 3/4PL models)
LBOUND A bracketed, comma separate list specifying lower bounds for estimated parameters
(used in optimizers such as L-BFGS-B and nlminb). The input format is LBOUND = (items, ..., parameterName, val
For example, in a single group 10-item dichotomous tests, using the 3PL model and set-
ting lower bounds for the ’g’ parameters for the first 5 items to 0.2 is accomplished with
LBOUND = (1-5, g, 0.2)
UBOUND same as LBOUND, but specifying upper bounds in estimated parameters
START A bracketed, comma separate list specifying the starting values for individual parameters.
The input is of the form (items, ..., parameterName, value). For instance, setting the
10th and 12th to 15th item slope parameters (a1) to 1.0 is specified with START = (10, 12-15, a1, 1.0)
For more hands on control of the starting values pass the argument pars = 'values' through
whatever estimation function is being used
FIXED A bracketed, comma separate list specifying which parameters should be fixed at their
starting values (i.e., not freely estimated). The input is of the form (items, ..., parameterName).
For instance, fixing the 10th and 12th to 15th item slope parameters (a1) is accomplished with
FIXED = (10, 12-15, a1)
For more hands on control of the estimated values pass the argument pars = 'values'
through whatever estimation function is being used
FREE Equivalent to the FIXED input, except that parameters are freely estimated instead of fixed
at their starting value
NEXPLORE Number of exploratory factors to extract. Usually this is not required because pass-
ing a numeric value to the model argument in the estimation function will generate an ex-
ploratory factor analysis model, however if different start values, priors, lower and upper
bounds, etc, are desired then this input can be used
Value
Returns a model specification object to be used in mirt, bfactor, multipleGroup, or mixedmirt
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com> and Alexander Robitzsch
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
mirt.model 113
Examples
## Not run:
#Q-matrix specification
Q <- matrix(c(1,1,1,0,0,0,0,0,0,1,1,1), ncol=2, dimnames = list(NULL, c('Factor1', 'Factor2')))
COV <- matrix(c(FALSE, TRUE, TRUE, FALSE), 2)
model <- mirt.model(Q, COV=COV)
## constrain various items slopes and all intercepts in single group model to be equal,
# and use a log-normal prior for all the slopes
s <- 'F = 1-10
CONSTRAIN = (1-3, 5, 6, a1), (1-10, d)
PRIOR = (1-10, a1, lnorm, .2, .2)'
model <- mirt.model(s)
## constrain various items slopes and intercepts across groups for use in multipleGroup(),
# and constrain first two slopes within 'group1' to be equal
s <- 'F = 1-10
CONSTRAIN = (1-2, a1)
CONSTRAINB = (1-3, 5, 6, a1), (1-10, d)'
model <- mirt.model(s)
F2 = A1-A4,C2,C4
MEAN = F1
COV = F1*F1, F1*F2
CONSTRAIN=(A2-A4,a2),(A3,C2,d)
PRIOR = (C3,A2-A4,a2,lnorm, .2, .2),(B3,d,norm,0,.0001)"
# create a mirt model
mirtmodel <- mirt.model(mirtsyn2, itemnames=dat)
# or equivalently:
# mirtmodel <- mirt.model(mirtsyn2, itemnames=colnames(dat))
## End(Not run)
Description
This function defines a object that is placed in a relevant internal environment defined in mirt. Inter-
nal functions such as calcLogLik, fscores, etc, will utilize this object automatically to capitalize
on parallel processing architecture. The object defined is a call from parallel::makeCluster().
Note that if you are defining other parallel objects (for simulation designs, for example) it is not
recommended to define a mirtCluster.
Usage
mirtCluster(spec, ..., remove = FALSE)
Arguments
spec input that is passed to parallel::makeCluster(). If no input is given the
maximum number of available local cores will be used
... additional arguments to pass to parallel::makeCluster
remove logical; remove previously defined mirtCluster()?
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
MixedClass-class 115
Examples
## Not run:
## End(Not run)
Description
Defines the object returned from mixedmirt.
Slots
Call: function call
Data: list of data, sometimes in different forms
Options: list of estimation options
Fit: a list of fit information
Model: a list of model-based information
ParObjects: a list of the S4 objects used during estimation
OptimInfo: a list of arguments from the optimization process
Internals: a list of internal arguments for secondary computations (inspecting this object is gen-
erally not required)
vcov: a matrix represented the asymptotic covariance matrix of the parameter estimates
time: a data.frame indicating the breakdown of computation times in seconds
Methods
coef signature(object = "MixedClass")
print signature(x = "MixedClass")
residuals signature(object = "MixedClass")
show signature(object = "MixedClass")
summary signature(object = "MixedClass")
logLik signature(object = "MixedClass")
anova signature(object = "MixedClass")
116 mixedmirt
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Description
mixedmirt fits MIRT models using FIML estimation to dichotomous and polytomous IRT models
conditional on fixed and random effect of person and item level covariates. This can also be un-
derstood as ’explanatory IRT’ if only fixed effects are modeled, or multilevel/mixed IRT if random
and fixed effects are included. The method uses the MH-RM algorithm exclusively. Additionally,
computation of the log-likelihood can be sped up by using parallel estimation via mirtCluster.
Usage
mixedmirt(data, covdata = NULL, model, fixed = ~1, random = NULL,
itemtype = "Rasch", lr.fixed = ~1, lr.random = NULL,
itemdesign = NULL, constrain = NULL, pars = NULL,
return.design = FALSE, SE = TRUE, internal_constraints = TRUE,
technical = list(SEtol = 1e-04), ...)
Arguments
data a matrix or data.frame that consists of numerically ordered data, with missing
data coded as NA
covdata a data.frame that consists of the nrow(data) by K ’person level’ fixed and
random predictors
model an object returned from, or a string to be passed to, mirt.model() to declare
how the IRT model is to be estimated. See mirt.model for more details
fixed a right sided R formula for specifying the fixed effect (aka ’explanatory’) pre-
dictors from covdata and itemdesign. To estimate the intercepts for each item
the keyword items is reserved and automatically added to the itemdesign in-
put. If any polytomous items are being model the items are argument is not
valid since all intercept parameters are freely estimated and identified with the
parameterizations found in mirt, and the first column in the fixed design matrix
(commonly the intercept or a reference group) is omitted
random a right sided formula or list of formulas containing crossed random effects of
the form v1 + ... v_n | G, where G is the grouping variable and v_n are
random numeric predictors within each group. If no intercept value is specified
then by default the correlations between the v’s and G are estimated, but can be
mixedmirt 117
Details
For dichotomous response models, mixedmirt follows the general form
(u − g)
P (x = 1|θ, ψ) = g +
1 + exp(−1 ∗ [θa + Xβ + Zδ])
118 mixedmirt
where X is a design matrix with associated β fixed effect intercept coefficients, and Z is a design
matrix with associated δ random effects for the intercepts. For simplicity and easier interpreta-
tion, the unique item intercept values typically found in Xβ are extracted and reassigned within
mirt’s ’intercept’ parameters (e.g., 'd'). To observe how the design matrices are structured prior to
reassignment and estimation pass the argument return.design = TRUE.
Polytomous IRT models follow a similar format except the item intercepts are automatically esti-
mated internally, rendering the items argument in the fixed formula redundant and therefore must
be omitted from the specification. If there are a mixture of dichotomous and polytomous items the
intercepts for the dichotomous models are also estimated for consistency.
The decomposition of the θ parameters is also possible to form latent regression and multilevel IRT
models by using the lr.fixed and lr.random inputs. These effects decompose θ such that
θ = V Γ + Wζ +
where V and W are fixed and random effects design matrices for the associated coefficients.
To simulate maximum a posteriori estimates for the random effect terms use the randef function.
Value
function returns an object of class MixedClass (MixedClass-class).
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P. (2015). Extended Mixed-Effects Item Response Models with the MH-RM Algo-
rithm. Journal of Educational Measurement, 52, 200-222. doi: 10.1111/jedm.12072
See Also
mirt, randef, fixef, boot.mirt
Examples
## Not run:
#view fixed design matrix with and without unique item level intercepts
withint <- mixedmirt(data, covdata, model, fixed = ~ 0 + items + group, return.design = TRUE)
withoutint <- mixedmirt(data, covdata, model, fixed = ~ 0 + group, return.design = TRUE)
#notice that in result above, the intercepts 'items1 to items 10' were reassigned to 'd'
head(withint$X)
tail(withint$X)
head(withoutint$X) #no intercepts design here to be reassigned into item intercepts
tail(withoutint$X)
###################################################
### random effects
#make the number of groups much larger
covdata$group <- factor(rep(paste0('G',1:50), each = N/50))
#random groups
rmod1 <- mixedmirt(data, covdata, 1, fixed = ~ 0 + items, random = ~ 1|group)
summary(rmod1)
120 mixedmirt
coef(rmod1)
###################################################
##LLTM, and 2PL version of LLTM
data(SAT12)
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
model <- 'Theta = 1-32'
# Suppose that the first 16 items were suspected to be easier than the last 16 items,
# and we wish to test this item structure hypothesis (more intercept designs are possible
# by including more columns).
itemdesign <- data.frame(itemorder = factor(c(rep('easier', 16), rep('harder', 16))))
wald(twoPL)
L <- matrix(0, 1, 34)
L[1, 1] <- 1
L[1, 2] <- -1
wald(twoPL, L) #n.s., which is the correct conclusion. Rasch approach gave wrong inference
summary(LLTMwithError)
#large item level variance after itemorder is regressed; not a great predictor of item difficulty
coef(LLTMwithError)
###################################################
### Polytomous example
#graded model
mod3 <- mixedmirt(Science, covdat, model=1, fixed = ~ 0 + group,
itemtype = 'graded')
coef(mod3)
###################################################
# latent regression with Rasch and 2PL models
set.seed(1)
n <- 300
a <- matrix(1, 10)
d <- matrix(rnorm(10))
Theta <- matrix(c(rnorm(n, 0), rnorm(n, 1), rnorm(n, 2)))
covdata <- data.frame(group=rep(c('g1','g2','g3'), each=n))
dat <- simdata(a, d, N=n*3, Theta=Theta, itemtype = '2PL')
#had we known the latent abilities, we could have computed the regression coefs
summary(lm(Theta ~ covdata$group))
#but all we have is observed test data. Latent regression helps to recover these coefs
#Rasch model approach (and mirt equivalent)
rmod0 <- mirt(dat, 1, 'Rasch') # unconditional
####################################################
## Simulated Multilevel Rasch Model
set.seed(1)
N <- 2000
a <- matrix(rep(1,10),10,1)
d <- matrix(rnorm(10))
cluster = 100
random_intercept = rnorm(cluster,0,1)
Theta = numeric()
for (i in 1:cluster)
Theta <- c(Theta, rnorm(N/cluster,0,1) + random_intercept[i])
# null model
mod1 <- mixedmirt(dat, covdata, 1, fixed = ~ 0 + items, random = ~ 1|group)
summary(mod1)
# can also be fit for Rasch/non-Rasch models with the lr.random input
mod1b <- mixedmirt(dat, covdata, 1, fixed = ~ 0 + items, lr.random = ~ 1|group)
summary(mod1b)
mod3 <- mixedmirt(dat, covdata, 1, fixed = ~ 0 + items, lr.random = ~ 1|group, itemtype = '2PL')
summary(mod3)
anova(mod1b, mod3)
head(cbind(randef(mod3)$group, random_intercept))
## End(Not run)
Description
Defines the object returned from multipleGroup when estimated with mixture distributions.
Slots
Call: function call
Data: list of data, sometimes in different forms
Options: list of estimation options
Fit: a list of fit information
Model: a list of model-based information
ParObjects: a list of the S4 objects used during estimation
OptimInfo: a list of arguments from the optimization process
Internals: a list of internal arguments for secondary computations (inspecting this object is gen-
erally not required)
vcov: a matrix represented the asymptotic covariance matrix of the parameter estimates
time: a data.frame indicating the breakdown of computation times in seconds
Methods
coef signature(object = "MixtureClass")
print signature(x = "MixtureClass")
show signature(object = "MixtureClass")
anova signature(object = "MixtureClass")
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
124 mod2values
Description
Given an estimated model from any of mirt’s model fitting functions this function will convert the
model parameters into the design data frame of starting values and other parameter characteristics
(similar to using the pars = 'values' for obtaining starting values).
Usage
mod2values(x)
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.mirt
Examples
## Not run:
dat <- expand.table(LSAT7)
mod <- mirt(dat, 1)
values <- mod2values(mod)
values
#use the converted values as starting values in a new model, and reduce TOL
mod2 <- mirt(dat, 1, pars = values, TOL=1e-5)
## End(Not run)
multipleGroup 125
Description
multipleGroup performs a full-information maximum-likelihood multiple group analysis for any
combination of dichotomous and polytomous data under the item response theory paradigm us-
ing either Cai’s (2010) Metropolis-Hastings Robbins-Monro (MHRM) algorithm or with an EM
algorithm approach. This function may be used for detecting differential item functioning (DIF),
thought the DIF function may provide a more convenient approach. If the grouping variable is not
specified then the dentype input can be modified to fit mixture models to estimate any latent group
components.
Usage
multipleGroup(data, model, group, invariance = "", method = "EM",
rotate = "oblimin", dentype = "Gaussian", ...)
Arguments
data a matrix or data.frame that consists of numerically ordered data, with missing
data coded as NA
model string to be passed to, or a model object returned from, mirt.model declaring
how the global model is to be estimated (useful to apply constraints here)
group a character vector indicating group membership
invariance a character vector containing the following possible options:
’free_means’ for freely estimating all latent means (reference group constrained
to 0)
’free_var’ for freely estimating all latent variances (reference group con-
strained to 1’s)
’slopes’ to constrain all the slopes to be equal across all groups
’intercepts’ to constrain all the intercepts to be equal across all groups, note
for nominal models this also includes the category specific slope parameters
Additionally, specifying specific item name bundles (from colnames(data))
will constrain all freely estimated parameters in each item to be equal across
groups. This is useful for selecting ’anchor’ items for vertical and horizontal
scaling, and for detecting differential item functioning (DIF) across groups
method a character object that is either 'EM', 'QMCEM', or 'MHRM' (default is 'EM'). See
mirt for details
rotate rotation if models are exploratory (see mirt for details)
dentype type of density form to use for the latent trait parameters. Current options in-
clude all of the methods described in mirt, as well as
126 multipleGroup
Details
By default the estimation in multipleGroup assumes that the models are maximally independent,
and therefore could initially be performed by sub-setting the data and running identical models with
mirt and aggregating the results (e.g., log-likelihood). However, constrains may be automatically
imposed across groups by invoking various invariance keywords. Users may also supply a list of
parameter equality constraints to by constrain argument, of define equality constraints using the
mirt.model syntax (recommended).
Value
function returns an object of class MultipleGroupClass (MultipleGroupClass-class).
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
mirt, DIF, extract.group, DRF
Examples
## Not run:
#single factor
set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
itemtype <- rep('2PL', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
dataset2 <- simdata(a, d, N, itemtype, mu = .1, sigma = matrix(1.5))
dat <- rbind(dataset1, dataset2)
group <- c(rep('D1', N), rep('D2', N))
models <- 'F1 = 1-15'
multipleGroup 127
summary(mod_scalar2)
coef(mod_scalar2, simplify=TRUE)
residuals(mod_scalar2)
plot(mod_configural)
plot(mod_configural, type = 'info')
plot(mod_configural, type = 'trace')
plot(mod_configural, type = 'trace', which.items = 1:4)
itemplot(mod_configural, 2)
itemplot(mod_configural, 2, type = 'RE')
############
# vertical scaling (i.e., equating when groups answer items others do not)
dat2 <- dat
dat2[group == 'D1', 1:2] <- dat2[group != 'D1', 14:15] <- NA
128 multipleGroup
head(dat2)
tail(dat2)
# items with missing responses need to be constrained across groups for identification
nms <- colnames(dat2)
mod <- multipleGroup(dat2, 1, group, invariance = nms[c(1:2, 14:15)])
# this will throw an error without proper constraints (SEs cannot be computed either)
# mod <- multipleGroup(dat2, 1, group)
# model still does not have anchors, therefore need to add a few (here use items 3-5)
mod_anchor <- multipleGroup(dat2, 1, group,
invariance = c(nms[c(1:5, 14:15)], 'free_means', 'free_var'))
coef(mod_anchor, simplify=TRUE)
#############
#DIF test for each item (using all other items as anchors)
itemnames <- colnames(dat)
refmodel <- multipleGroup(dat, models, group = group, SE=TRUE,
invariance=c('free_means', 'free_var', itemnames))
#loop over items (in practice, run in parallel to increase speed). May be better to use ?DIF
estmodels <- vector('list', ncol(dat))
for(i in 1:ncol(dat))
estmodels[[i]] <- multipleGroup(dat, models, group = group, verbose = FALSE, calcNull=FALSE,
invariance=c('free_means', 'free_var', itemnames[-i]))
#############
#multiple factors
#group models
model <- '
F1 = 1-5
F2 = 6-10
F3 = 11-15'
#EM approach (not as accurate with 3 factors, but generally good for quick model comparisons)
mod_configural <- multipleGroup(dat, model, group = group) #completely separate analyses
mod_metric <- multipleGroup(dat, model, group = group, invariance=c('slopes')) #equal slopes
mod_fullconstrain <- multipleGroup(dat, model, group = group, #equal means, slopes, intercepts
invariance=c('slopes', 'intercepts'))
anova(mod_metric, mod_configural)
anova(mod_fullconstrain, mod_metric)
#same as above, but with MHRM (generally more accurate with 3+ factors, but slower)
mod_configural <- multipleGroup(dat, model, group = group, method = 'MHRM')
mod_metric <- multipleGroup(dat, model, group = group, invariance=c('slopes'), method = 'MHRM')
mod_fullconstrain <- multipleGroup(dat, model, group = group, method = 'MHRM',
invariance=c('slopes', 'intercepts'))
anova(mod_metric, mod_configural)
anova(mod_fullconstrain, mod_metric)
############
#polytomous item example
set.seed(12345)
a <- matrix(abs(rnorm(15,1,.3)), ncol=1)
d <- matrix(rnorm(15,0,.7),ncol=1)
d <- cbind(d, d-1, d-2)
itemtype <- rep('graded', nrow(a))
N <- 1000
dataset1 <- simdata(a, d, N, itemtype)
130 multipleGroup
# constrain slopes within each group to be equal (but not across groups)
model2 <- 'F1 = 1-15
CONSTRAIN = (1-15, a1)'
mod_configural2 <- multipleGroup(dat, model2, group = group)
plot(mod_configural2, type = 'SE')
plot(mod_configural2, type = 'RE')
itemplot(mod_configural2, 10)
############
## empirical histogram example (normal and bimodal groups)
set.seed(1234)
a <- matrix(rlnorm(50, .2, .2))
d <- matrix(rnorm(50))
ThetaNormal <- matrix(rnorm(2000))
ThetaBimodal <- scale(matrix(c(rnorm(1000, -2), rnorm(1000,2)))) #bimodal
Theta <- rbind(ThetaNormal, ThetaBimodal)
dat <- simdata(a, d, 4000, itemtype = '2PL', Theta=Theta)
group <- rep(c('G1', 'G2'), each=2000)
#--------------------------------
# Mixture model (no prior group variable specified)
set.seed(12345)
nitems <- 20
a1 <- matrix(.75, ncol=1, nrow=nitems)
a2 <- matrix(1.25, ncol=1, nrow=nitems)
d1 <- matrix(rnorm(nitems,0,1),ncol=1)
d2 <- matrix(rnorm(nitems,0,1),ncol=1)
MultipleGroupClass-class 131
## End(Not run)
MultipleGroupClass-class
Class "MultipleGroupClass"
Description
Slots
Call: function call
Data: list of data, sometimes in different forms
Options: list of estimation options
Fit: a list of fit information
Model: a list of model-based information
ParObjects: a list of the S4 objects used during estimation
OptimInfo: a list of arguments from the optimization process
Internals: a list of internal arguments for secondary computations (inspecting this object is gen-
erally not required)
vcov: a matrix represented the asymptotic covariance matrix of the parameter estimates
time: a data.frame indicating the breakdown of computation times in seconds
Methods
coef signature(object = "MultipleGroupClass")
print signature(x = "MultipleGroupClass")
show signature(object = "MultipleGroupClass")
anova signature(object = "MultipleGroupClass")
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Description
Compute numerical derivatives using forward/backward difference, central difference, or Richard-
son extrapolation.
Usage
numerical_deriv(f, par, ..., delta = 1e-05, gradient = TRUE,
type = "Richardson")
personfit 133
Arguments
Author(s)
Examples
## Not run:
f <- function(x) 3*x[1]^3 - 4*x[2]^2
par <- c(3,8)
# grad = 9 * x^2 , -8 * y
(actual <- c(9 * par[1]^2, -8 * par[2]))
numerical_deriv(f, par, type = 'forward')
numerical_deriv(f, par, type = 'central')
numerical_deriv(f, par, type = 'Richardson') # default
# Hessian = h11 -> 18 * x, h22 -> -8, h12 -> h21 -> 0
(actual <- matrix(c(18 * par[1], 0, 0, -8), 2, 2))
numerical_deriv(f, par, type = 'forward', gradient = FALSE)
numerical_deriv(f, par, type = 'central', gradient = FALSE)
numerical_deriv(f, par, type = 'Richardson', gradient = FALSE) # default
## End(Not run)
Description
personfit calculates the Zh values from Drasgow, Levine and Williams (1985) for unidimensional
and multidimensional models. For Rasch models infit and outfit statistics are also produced. The
returned object is a data.frame consisting either of the tabulated data or full data with the statistics
appended to the rightmost columns.
Usage
personfit(x, method = "EAP", Theta = NULL, stats.only = TRUE, ...)
Arguments
x a computed model object of class SingleGroupClass or MultipleGroupClass
method type of factor score estimation method. See fscores for more detail
Theta a matrix of factor scores used for statistics that require empirical estimates. If
supplied, arguments typically passed to fscores() will be ignored and these
values will be used instead
stats.only logical; return only the person fit statistics without their associated response
pattern?
... additional arguments to be passed to fscores()
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Drasgow, F., Levine, M. V., & Williams, E. A. (1985). Appropriateness measurement with poly-
chotomous item response models and standardized indices. British Journal of Mathematical and
Statistical Psychology, 38, 67-86.
Reise, S. P. (1990). A comparison of item- and person-fit methods of assessing model-data fit in
IRT. Applied Psychological Measurement, 14, 127-137.
Wright B. D. & Masters, G. N. (1982). Rating scale analysis. MESA Press.
See Also
itemfit
Examples
## Not run:
a <- matrix(rlnorm(20),ncol=1)
d <- matrix(rnorm(20),ncol=1)
items <- rep('2PL', 20)
data <- simdata(a,d, 2000, items)
x <- mirt(data, 1)
fit <- personfit(x)
head(fit)
## End(Not run)
Description
Computes profiled-likelihood based confidence intervals. Supports the inclusion of equality con-
straints. Object returns the confidence intervals and whether the respective interval could be found.
Usage
Arguments
mod a converged mirt model
parnum a numeric vector indicating which parameters to estimate. Use mod2values to
determine parameter numbers. If NULL, all possible parameters are used
alpha two-tailed alpha critical level
search_bound logical; use a fixed grid of values around the ML estimate to determine more
suitable optimization bounds? Using this has much better behaviour than setting
fixed upper/lower bound values and searching from more extreme ends
step magnitude of steps used when search_bound is TRUE. Smaller values create
more points to search a suitable bound for (up to the lower bound value visible
with mod2values). When upper/lower bounds are detected this value will be
adjusted accordingly
lower logical; search for the lower CI?
upper logical; search for the upper CI?
inf2val a numeric used to change parameter bounds which are infinity to a finite number.
Decreasing this too much may not allow a suitable bound to be located. Default
is 30
NealeMiller logical; use the Neale and Miller 1997 approximation? Default is FALSE
... additional arguments to pass to the estimation functions
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chalmers, R. P., Pek, J., & Liu, Y. (2017). Profile-likelihood Confidence Intervals in Item Response
Theory Models. Multivariate Behavioral Research, 52, 533-550. doi: 10.1080/00273171.2017.1329082
Neale, M. C. & Miller, M. B. (1997). The use of likelihood-based confidence intervals in genetic
models. Behavior Genetics, 27, 113-120.
See Also
boot.mirt
Examples
## Not run:
mirtCluster() #use all available cores to estimate CI's in parallel
dat <- expand.table(LSAT7)
mod <- mirt(dat, 1)
result
## End(Not run)
Description
Plot various test implied response functions from models estimated in the mirt package.
Usage
## S4 method for signature 'SingleGroupClass,missing'
plot(x, y, type = "score", npts = 200,
degrees = 45, theta_lim = c(-6, 6), which.items = 1:extract.mirt(x,
"nitems"), MI = 0, CI = 0.95, rot = list(xaxis = -70, yaxis = 30, zaxis
= 10), facet_items = TRUE, main = NULL, drape = TRUE, colorkey = TRUE,
ehist.cut = 1e-10, add.ylab2 = TRUE, par.strip.text = list(cex = 0.7),
par.settings = list(strip.background = list(col = "#9ECAE1"), strip.border =
list(col = "black")), auto.key = list(space = "right", points = FALSE, lines
= TRUE), profile = FALSE, ...)
Arguments
x an object of class SingleGroupClass, MultipleGroupClass, or DiscreteClass
y an arbitrary missing argument required for R CMD check
type type of plot to view. Can be
’info’ test information function
’rxx’ for the reliability function
138 plot-method
profile logical; provide a profile plot of response probabilities (objects returned from
mdirt only)
... additional arguments to be passed to lattice
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1, SE=TRUE)
plot(x)
plot(x, type = 'info')
plot(x, type = 'infotrace')
plot(x, type = 'infotrace', facet_items = FALSE)
plot(x, type = 'infoSE')
plot(x, type = 'rxx')
set.seed(1234)
group <- sample(c('g1','g2'), nrow(Science), TRUE)
x2 <- multipleGroup(Science, 1, group)
plot(x2)
plot(x2, type = 'trace')
plot(x2, type = 'trace', which.items = 1:2)
plot(x2, type = 'itemscore', which.items = 1:2)
plot(x2, type = 'trace', which.items = 1, facet_items = FALSE) #facet by group
plot(x2, type = 'info')
x3 <- mirt(Science, 2)
plot(x3, type = 'info')
plot(x3, type = 'SE', theta_lim = c(-3,3))
## End(Not run)
140 poly2dich
Description
Transforms a matrix of items into a new matrix where the select polytomous items have been con-
verted into comparable dichotomous items with the same information.
Usage
poly2dich(data, which.items = 1:ncol(data))
Arguments
data an object of class data.frame or matrix
which.items a vector indicating which items should be transformed into the dichotomous
form. Default uses all input items
Value
Returns an integer matrix
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
data(Science)
head(Science)
newScience <- poly2dich(Science)
head(newScience)
## End(Not run)
print-method 141
Description
Print model object summaries to the console.
Usage
## S4 method for signature 'SingleGroupClass'
print(x)
Arguments
x an object of class SingleGroupClass, MultipleGroupClass, or MixedClass
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1)
print(x)
## End(Not run)
Description
Provides a nicer output for most printed data.frame objects defined by functions in mirt.
Usage
## S3 method for class 'mirt_df'
print(x, digits = 3, ...)
Arguments
x object of class 'mirt_df'
digits number of digits to round
... additional arguments passed to print(...)
142 print.mirt_matrix
Description
Provides a nicer output for most printed list objects defined by functions in mirt.
Usage
Arguments
Description
Provides a nicer output for most printed matrix objects defined by functions in mirt.
Usage
Arguments
Description
Given an internal mirt object extracted from an estimated model compute the probability trace lines
for all categories.
Usage
probtrace(x, Theta)
Arguments
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
extract.item
Examples
Description
Stochastically compute random effects for MixedClass objects with Metropolis-Hastings samplers
and averaging over the draws. Returns a list of the estimated effects.
Usage
randef(x, ndraws = 1000, thin = 10, return.draws = FALSE)
Arguments
x an estimated model object from the mixedmirt function
ndraws total number of draws to perform. Default is 1000
thin amount of thinning to apply. Default is to use every 10th draw
return.draws logical; return a list containing the thinned draws of the posterior?
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29.
Chalmers, R. P. (2015). Extended Mixed-Effects Item Response Models with the MH-RM Algo-
rithm. Journal of Educational Measurement, 52, 200-222. doi: 10.1111/jedm.12072 doi: 10.18637/
jss.v048.i06
Examples
## Not run:
#make an arbitrary groups
covdat <- data.frame(group = rep(paste0('group', 1:49), each=nrow(Science)/49))
## End(Not run)
residuals-method 145
Description
Return model implied residuals for linear dependencies between items or at the person level. If the
latent trait density was approximated (e.g., Davidian curves, Empirical histograms, etc) then passing
use_dentype_estimate = TRUE will use the internally saved quadrature and density components
(where applicable).
Usage
## S4 method for signature 'SingleGroupClass'
residuals(object, type = "LD", df.p = FALSE,
full.scores = FALSE, QMC = FALSE, printvalue = NULL, tables = FALSE,
verbose = TRUE, Theta = NULL, suppress = 1, theta_lim = c(-6, 6),
quadpts = NULL, ...)
Arguments
object an object of class SingleGroupClass or MultipleGroupClass. Bifactor mod-
els are automatically detected and utilized for better accuracy
type type of residuals to be displayed. Can be either 'LD' or 'LDG2' for a local
dependence matrix based on the X2 or G2 statistics (Chen & Thissen, 1997),
'Q3' for the statistic proposed by Yen (1984), or 'exp' for the expected values
for the frequencies of every response pattern. For the ’LD’ and ’LDG2’ types,
the upper diagonal elements represent the standardized residuals in the form of
signed Cramers V coefficients
df.p logical; print the degrees of freedom and p-values?
full.scores logical; compute relevant statistics for each subject in the original data?
QMC logical; use quasi-Monte Carlo integration? If quadpts is omitted the default
number of nodes is 5000
printvalue a numeric value to be specified when using the res='exp' option. Only prints
patterns that have standardized residuals greater than abs(printvalue). The
default (NULL) prints all response patterns
tables logical; for LD type, return the observed, expected, and standardized residual
tables for each item combination?
verbose logical; allow information to be printed to the console?
Theta a matrix of factor scores used for statistics that require empirical estimates (i.e.,
Q3). If supplied, arguments typically passed to fscores() will be ignored and
these values will be used instead
suppress a numeric value indicating which parameter local dependency combinations to
flag as being too high. Absolute values for the standardized estimates greater
than this value will be returned, while all values less than this value will be set
to NA
146 SAT12
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chen, W. H. & Thissen, D. (1997). Local dependence indices for item pairs using item response
theory. Journal of Educational and Behavioral Statistics, 22, 265-289.
Yen, W. (1984). Effects of local item dependence on the fit and equating performance of the three
parameter logistic model. Applied Psychological Measurement, 8, 125-145.
Examples
## Not run:
x <- mirt(Science, 1)
residuals(x)
residuals(x, tables = TRUE)
residuals(x, type = 'exp')
residuals(x, suppress = .15)
residuals(x, df.p = TRUE)
## End(Not run)
Description
Data obtained from the TESTFACT (Woods et al., 2003) manual, with 32 response pattern scored
items for a grade 12 science assessment test (SAT) measuring topics of chemistry, biology, and
physics. The scoring key for these data is [1, 4, 5, 2, 3, 1, 2, 1, 3, 1, 2, 4, 2, 1, 5, 3, 4, 4, 1, 4, 3, 3, 4,
1, 3, 5, 1, 3, 1, 5, 4, 5], respectively. However, careful analysis using the nominal response model
suggests that the scoring key for item 32 may be incorrect, and should be changed from 5 to 3.
Science 147
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Wood, R., Wilson, D. T., Gibbons, R. D., Schilling, S. G., Muraki, E., & Bock, R. D. (2003).
TESTFACT 4 for Windows: Test Scoring, Item Statistics, and Full-information Item Factor Analy-
sis [Computer software]. Lincolnwood, IL: Scientific Software International.
Examples
## Not run:
#score the data (missing scored as 0)
head(SAT12)
data <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
head(data)
## End(Not run)
Description
A 4-item data set borrowed from ltm package in R, first example of the grm() function. See more
complete documentation therein.
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
mod <- mirt(Science, 1)
plot(mod, type = 'trace')
## End(Not run)
Description
Usage
Arguments
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1)
show(x)
## End(Not run)
SIBTEST 149
Description
Classical test theory approach to detecting unidirectional and bidirectional (with one crossing lo-
cation) DIF. This family of statistics is intended for unidimensional tests, and applies a regression-
corrected matched-total score approach to quantify the response bias between two groups. Can be
used for DIF, DBF, and DTF testing.
Usage
SIBTEST(dat, group, suspect_set, match_set, focal_name = unique(group)[2],
guess_correction = 0, Jmin = 5, na.rm = FALSE, pk_focal = FALSE,
correction = TRUE, details = FALSE)
Arguments
dat integer-based dataset to be tested, containing dichotomous or polytomous re-
sponses
group a vector indicating group membership with the same length as the number of
rows in dat
suspect_set an integer vector indicating which items to inspect with SIBTEST. Including
only one value will perform a DIF test, while including more than one will
perform a simultaneous bundle test (DBF); including all non-matched items will
perform DTF. If missing, a simultaneous test using all the items not listed in
match_set will be used (i.e., DTF)
match_set an integer vector indicating which items to use as the items which are matched
(i.e., contain no DIF). These are analogous to ’anchor’ items in the likelihood
method to locate DIF. If missing, all items other than the items found in the
suspect_set will be used
focal_name name of the focal group; e.g., 'focal'. If not specified then one will be selected
automatically using unique(group)[2]
guess_correction
a vector of numbers from 0 to 1 indicating how much to correct the items for
guessing. It’s length should be the same as ncol(dat)
Jmin the minimum number of observations required when splitting the data into focal
and reference groups conditioned on the matched set
na.rm logical; remove rows in dat with any missing values? If TRUE, rows with missing
data will be removed, as well as the corresponding elements in the group input
pk_focal logical; using the group weights from the focal group instead of the total sample?
Default is FALSE as per Shealy and Stout’s recommendation
correction logical; apply the composite correction for the difference between focal compos-
ite scores using the true-score regression technique? Default is TRUE, reflecting
Shealy and Stout’s linear extrapolation method
details logical; return a data.frame containing the details required to compute SIBTEST?
150 SIBTEST
Details
SIBTEST is similar to the Mantel-Haenszel approach for detecting DIF but uses a regression cor-
rection based on the KR-20/coefficient alpha reliability index to correct the observed differences
when the latent trait distributions are not equal. Function supports the standard SIBTEST for
dichotomous and polytomous data (compensatory) and supports crossing DIF testing (i.e., non-
compensatory/non-uniform) using the asymptotic sampling distribution version of the Crossing-
SIBTEST (CSIBTEST) statistic described by Chalmers (2018). For convenience, the beta coeffi-
cient for CSIBTEST is always reported as an absolute value.
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R. P. (2018). Improving the Crossing-SIBTEST statistic for detecting non-uniform DIF.
Psychometrika, 83, 2, 376-386.
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Chang, H. H., Mazzeo, J. & Roussos, L. (1996). DIF for Polytomously Scored Items: An Adapta-
tion of the SIBTEST Procedure. Journal of Educational Measurement, 33, 333-353.
Li, H.-H. & Stout, W. (1996). A new procedure for detection of crossing DIF. Psychometrika, 61,
647-677.
Shealy, R. & Stout, W. (1993). A model-based standardization approach that separates true bias/DIF
from group ability differences and detect test bias/DTF as well as item bias/DIF. Psychometrika, 58,
159-194.
Examples
## Not run:
set.seed(1234)
n <- 30
N <- 500
a <- matrix(1, n)
d <- matrix(rnorm(n), n)
group <- c(rep('reference', N), rep('focal', N*2))
## -------------
# groups completely equal
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a, d, N*2, itemtype = 'dich')
dat <- rbind(dat1, dat2)
#DTF
SIBTEST(dat, group, suspect_set = 11:30)
SIBTEST(dat, group, match_set = 1:10) #equivalent
## -------------
## systematic differing slopes and intercepts (clear DTF)
dat1 <- simdata(a, d, N, itemtype = 'dich')
dat2 <- simdata(a + c(numeric(15), rnorm(n-15, 1, .25)), d + c(numeric(15), rnorm(n-15, 1, 1)),
N*2, itemtype = 'dich')
dat <- rbind(dat1, dat2)
SIBTEST(dat, group, 6:30)
SIBTEST(dat, group, 11:30)
## End(Not run)
Description
Simulates response patterns for compensatory and noncompensatory MIRT models from multivari-
ate normally distributed factor (θ) scores, or from a user input matrix of θ’s.
152 simdata
Usage
simdata(a, d, N, itemtype, sigma = NULL, mu = NULL, guess = 0,
upper = 1, nominal = NULL, t = NULL, Theta = NULL,
gpcm_mats = list(), returnList = FALSE, model = NULL, equal.K = TRUE,
which.items = NULL, mins = 0, lca_cats = NULL, prob.list = NULL)
Arguments
a a matrix/vector of slope parameters. If slopes are to be constrained to zero then
use NA or simply set them equal to 0
d a matrix/vector of intercepts. The matrix should have as many columns as the
item with the largest number of categories, and filled empty locations with NA.
When a vector is used the test is assumed to consist only of dichotomous items
(because only one intercept per item is provided). When itemtype = 'lca'
intercepts will not be used
N sample size
itemtype a character vector of length nrow(a) (or 1, if all the item types are the same)
specifying the type of items to simulate. Inputs can either be the same as the
inputs found in the itemtype argument in mirt or the internal classes defined
by the package. Typical itemtype inputs that are passed to mirt are used then
these will be converted into the respective internal classes automatically.
If the internal class of the object is specified instead, the inputs can be 'dich', 'graded', 'gpcm', 'seq
or 'lca', for dichotomous, graded, generalized partial credit, sequential, nom-
inal, nested logit, partially compensatory, generalized graded unfolding model,
and latent class analysis model. Note that for the gpcm, nominal, and nested
logit models there should be as many parameters as desired categories, however
to parametrized them for meaningful interpretation the first category intercept
should equal 0 for these models (second column for 'nestlogit', since first
column is for the correct item traceline). For nested logit models the ’correct’
category is always the lowest category (i.e., == 1). It may be helpful to use
mod2values on data-sets that have already been estimated to understand the
itemtypes more intimately
sigma a covariance matrix of the underlying distribution. Default is the identity matrix.
Used when Theta is not supplied
mu a mean vector of the underlying distribution. Default is a vector of zeros. Used
when Theta is not supplied
guess a vector of guessing parameters for each item; only applicable for dichotomous
items. Must be either a scalar value that will affect all of the dichotomous items,
or a vector with as many values as to be simulated items
upper same as guess, but for upper bound parameters
nominal a matrix of specific item category slopes for nominal models. Should be the
dimensions as the intercept specification with one less column, with NA in lo-
cations where not applicable. Note that during estimation the first slope will
be constrained to 0 and the last will be constrained to the number of categories
minus 1, so it is best to set these as the values for the first and last categories as
well
simdata 153
t matrix of t-values for the ’ggum’ itemtype, where each row corresponds to a
given item. Also determines the number of categories, where NA can be used for
non-applicable categories
Theta a user specified matrix of the underlying ability parameters, where nrow(Theta) == N
and ncol(Theta) == ncol(a). When this is supplied the N input is not required
gpcm_mats a list of matrices specifying the scoring scheme for generalized partial credit
models (see mirt for details)
returnList logical; return a list containing the data, item objects defined by mirt containing
the population parameters and item structure, and the latent trait matrix Theta?
Default is FALSE
model a single group object, typically returned by functions such as mirt or bfactor.
Supplying this will render all other parameter elements (excluding the Theta, N,
mu, and sigma inputs) redundant (unless explicitly provided)
equal.K logical; when a model input is supplied, should the generated data contain the
same number of categories as the original data indicated by extract.mirt(model, 'K')?
Default is TRUE, which will redrawn data until this condition is satisfied
which.items an integer vector used to indicate which items to simulate when a model input
is included. Default simulates all items
mins an integer vector (or single value to be used for each item) indicating what the
lowest category should be. If model is supplied then this will be extracted from
slot(mod, 'Data')$mins, otherwise the default is 0
lca_cats a vector indicating how many categories each lca item should have. If not sup-
plied then it is assumed that 2 categories should be generated for each item
prob.list an optional list containing matrix/data.frames of probabilities values for each
category to be simulated. This is useful when creating customized probability
functions to be sampled from
Details
Returns a data matrix simulated from the parameters, or a list containing the data, item objects, and
Theta matrix.
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Reckase, M. D. (2009). Multidimensional Item Response Theory. New York: Springer.
154 simdata
Examples
set.seed(1234)
a <- matrix(c(
.7471, .0250, .1428,
.4595, .0097, .0692,
.8613, .0067, .4040,
1.0141, .0080, .0470,
.5521, .0204, .1482,
1.3547, .0064, .5362,
1.3761, .0861, .4676,
.8525, .0383, .2574,
1.0113, .0055, .2024,
.9212, .0119, .3044,
.0026, .0119, .8036,
.0008, .1905,1.1945,
.0575, .0853, .7077,
.0182, .3307,2.1414,
.0256, .0478, .8551,
.0246, .1496, .9348,
.0262, .2872,1.3561,
.0038, .2229, .8993,
.0039, .4720, .7318,
.0068, .0949, .6416,
.3073, .9704, .0031,
.1819, .4980, .0020,
.4115,1.1136, .2008,
.1536,1.7251, .0345,
.1530, .6688, .0020,
.2890,1.2419, .0220,
.1341,1.4882, .0050,
.0524, .4754, .0012,
.2139, .4612, .0063,
.1761,1.1200, .0870),30,3,byrow=TRUE)*1.702
d <- matrix(c(.1826,-.1924,-.4656,-.4336,-.4428,-.5845,-1.0403,
.6431,.0122,.0912,.8082,-.1867,.4533,-1.8398,.4139,
-.3004,-.1824,.5125,1.1342,.0230,.6172,-.1955,-.3668,
-1.7590,-.2434,.4925,-.3410,.2896,.006,.0329),ncol=1)*1.702
## Not run:
a <- matrix(rlnorm(20,.2,.3))
# for the graded model, ensure that there is enough space between the intercepts,
# otherwise closer categories will not be selected often (minimum distance of 0.3 here)
diffs <- t(apply(matrix(runif(20*4, .3, 1), 20), 1, cumsum))
diffs <- -(diffs - rowMeans(diffs))
d <- diffs + rnorm(20)
### An example of a mixed item, bifactor loadings pattern with correlated specific factors
a <- matrix(c(
.8,.4,NA,
.4,.4,NA,
.7,.4,NA,
.8,NA,.4,
.4,NA,.4,
.7,NA,.4),ncol=3,byrow=TRUE)
d <- matrix(c(
-1.0,NA,NA,
1.5,NA,NA,
0.0,NA,NA,
0.0,-1.0,1.5, #the first 0 here is the recommended constraint for nominal
0.0,1.0,-1, #the first 0 here is the recommended constraint for gpcm
2.0,0.0,NA),ncol=3,byrow=TRUE)
a <- matrix(c(
.8,.4,
.4,.4,
.7,.4,
.8,NA,
.4,NA,
.7,NA),ncol=2,byrow=TRUE)
d <- matrix(rnorm(6))
itemtype <- rep('2PL',6)
a <- matrix(rlnorm(4,0,.2))
#first column of item 4 is the intercept for the correct category of 2PL model,
# otherwise nominal model configuration
d <- matrix(c(
-1.0,NA,NA,NA,
1.5,NA,NA,NA,
0.0,NA,NA,NA,
1, 0.0,-0.5,0.5),ncol=4,byrow=TRUE)
# alternatively, define a suitable object with functions from the mirtCAT package
# help(generate.mirt_object)
library(mirtCAT)
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)
######
# prob.list example
set.seed(1)
theta <- matrix(rnorm(100))
prob.list <- list()
nitems <- 5
a <- rlnorm(nitems, .2, .2); b <- rnorm(nitems, 0, 1/2)
for(i in 1:nitems) prob.list[[i]] <- fun(a[i], b[i], theta)
str(prob.list)
## End(Not run)
SingleGroupClass-class
Class "SingleGroupClass"
Description
Defines the object returned from mirt when model is exploratory.
Slots
Call: function call
Data: list of data, sometimes in different forms
Options: list of estimation options
Fit: a list of fit information
Model: a list of model-based information
ParObjects: a list of the S4 objects used during estimation
summary-method 159
Methods
Author(s)
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Description
Transforms coefficients into a standardized factor loading’s metric. For MixedClass objects, the
fixed and random coefficients are printed. Note that while the output to the console is rounded to
three digits, the returned list of objects is not. For simulations, use output <- summary(mod, verbose = FALSE)
to suppress the console messages.
Usage
Arguments
object an object of class SingleGroupClass, MultipleGroupClass, or MixedClass
rotate a string indicating which rotation to use for exploratory models, primarily from
the GPArotation package (see documentation therein).
Rotations currently supported are: 'promax', 'oblimin', 'varimax', 'quartimin',
'targetT', 'targetQ', 'pstT', 'pstQ', 'oblimax', 'entropy', 'quartimax',
'simplimax', 'bentlerT', 'bentlerQ', 'tandemI', 'tandemII', 'geominT',
'geominQ', 'cfT', 'cfQ', 'infomaxT', 'infomaxQ', 'mccammon', 'bifactorT',
'bifactorQ'.
For models that are not exploratory this input will automatically be set to 'none'
Target a dummy variable matrix indicting a target rotation pattern. This is required for
rotations such as 'targetT', 'targetQ', 'pstT', and 'pstQ'
suppress a numeric value indicating which (possibly rotated) factor loadings should be
suppressed. Typical values are around .3 in most statistical software. Default is
0 for no suppression
verbose logical; allow information to be printed to the console?
... additional arguments to be passed
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
See Also
coef-method
Examples
## Not run:
x <- mirt(Science, 2)
summary(x)
summary(x, rotate = 'varimax')
## End(Not run)
Description
Given an estimated model compute the test information.
testinfo 161
Usage
testinfo(x, Theta, degrees = NULL, group = NULL, individual = FALSE,
which.items = 1:extract.mirt(x, "nitems"))
Arguments
x an estimated mirt object
Theta a matrix of latent trait values
degrees a vector of angles in degrees that are between 0 and 90. Only applicable when
the input object is multidimensional
group a number signifying which group the item should be extracted from (applies to
’MultipleGroupClass’ objects only)
individual logical; return a data.frame of information traceline for each item?
which.items an integer vector indicating which items to include in the expected information
function. Default uses all possible items
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
#most loss of info around -1 when removing items 1 and 2; expected given item info functions
plot(Theta, tinfo_smaller - tinfo, type = 'l')
162 thetaComb
## End(Not run)
Description
This function constructs all possible k-way combinations of an input vector. It is primarily useful
when used in conjunction with the mdirt function, though users may have other uses for it as well.
See expand.grid for more flexible combination formats.
Usage
thetaComb(theta, nfact, intercept = FALSE)
Arguments
theta the vector from which all possible combinations should be obtained
nfact the number of observations (and therefore the number of columns to return in
the matrix of combinations)
intercept logical; should a vector of 1’s be appended to the first column of the result to
include an intercept design component? Default is FALSE
Value
a matrix with all possible combinations
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
traditional2mirt Convert traditional IRT metric into slope-intercept form used in mirt
Description
This is a helper function for users who have previously available traditional/classical IRT parame-
ters and want to know the equivalent slope-intercept translation used in mirt. Note that this func-
tion assumes that the supplied models are unidimensional by definition (i.e., will have only one
slope/discrimination). If there is no supported slope-interecept transformation available then the
original vector of parameters will be returned by default.
Usage
traditional2mirt(x, cls, ncat)
Arguments
x a vector of parameters to tranform
cls the class or itemtype of the supplied model
ncat the number of categories implied by the IRT model
Details
Supported class transformations for the cls input are:
Rasch, 2PL, 3PL, 3PLu, 4PL Form must be: (discrimination, difficulty, lower-bound, upper-bound)
graded Form must be: (discrimination, difficulty 1, difficulty 2, ..., difficulty k-1)
gpcm Form must be: (discrimination, difficulty 1, difficulty 2, ..., difficulty k-1)
nominal Form must be: (discrimination 1, discrimination 2, ..., discrimination k, difficulty 1, diffi-
culty 2, ..., difficulty k)
Value
a named vector of slope-intercept parameters (if supported)
Examples
Description
Usage
Arguments
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
x <- mirt(Science, 1, SE=TRUE)
vcov(x)
## End(Not run)
wald 165
Description
Compute a Wald test given an L vector or matrix of numeric contrasts. Requires that the model infor-
mation matrix be computed (including SE = TRUE when using the EM method). Use wald(model)
to observe how the information matrix columns are named, especially if the estimated model con-
tains constrained parameters (e.g., 1PL).
Usage
wald(object, L, C = 0)
Arguments
object estimated object from mirt, bfactor, multipleGroup, mixedmirt, or mdirt
L a coefficient matrix with dimensions nconstrasts x npars. Omitting this value
will return the column names of the information matrix used to identify the
(potentially constrained) parameters
C a constant vector of population parameters to be compared along side L, where
length(C) == ncol(L). By default a vector of 0’s is constructed
Author(s)
Phil Chalmers <rphilip.chalmers@gmail.com>
References
Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Envi-
ronment. Journal of Statistical Software, 48(6), 1-29. doi: 10.18637/jss.v048.i06
Examples
## Not run:
#View parnumber index
data(LSAT7)
data <- expand.table(LSAT7)
mod <- mirt(data, 1, SE = TRUE)
coef(mod)
# see how the information matrix relates to estimated parameters, and how it lines up
# with the parameter index
(infonames <- wald(mod))
index <- mod2values(mod)
index[index$est, ]
#simultaneously test equal factor slopes for item 1 and 2, and 4 and 5
L <- matrix(0, 2, 10)
L[1,1] <- L[2, 7] <- 1
L[1,3] <- L[2, 9] <- -1
L
wald(mod, L)
## End(Not run)
Index
167
168 INDEX
empirical_ES, 37 mirt-package, 4
empirical_plot, 40 mirt.model, 9, 80, 82, 88, 91, 95, 96, 110,
empirical_rxx, 42, 78 116, 125, 126
estfun.AllModelClass, 43 mirtCluster, 14, 24, 55, 82, 90, 94, 97, 114,
expand.grid, 162 116
expand.table, 44, 101 MixedClass-class, 115, 118
expected.item, 45, 46 mixedmirt, 51, 52, 87, 95, 101, 112, 115, 116,
expected.test, 45, 46 144
extract.group, 47, 49, 51, 78, 80, 87, 126 MixtureClass-class, 123
extract.item, 45, 47, 48, 51, 67, 101, 143 mod2values, 51, 72, 101, 124, 136, 152
extract.mirt, 47, 49, 49, 101, 124 multipleGroup, 9, 24–26, 31, 36, 43, 47, 87,
101, 112, 123, 125, 131
fixef, 51, 101, 118 MultipleGroupClass-class, 10, 126, 131
fscores, 38, 42, 53, 57, 59, 60, 64, 76, 82, 95,
96, 134 nlm, 55
ns, 88, 93
imputeMissing, 57, 60, 76, 96 numerical_deriv, 21, 72, 132
integrate, 6
itemfit, 58, 64, 82, 97, 134 optim, 89
itemGAM, 41, 58, 61, 63
iteminfo, 66, 69, 101 p.adjust, 25
itemplot, 41, 68, 96 personfit, 61, 97, 133
PLCI.mirt, 135
key2binary, 70, 101 plogis, 91, 112
plot,DiscreteClass,missing-method
lagrange, 72 (plot-method), 137
lattice, 31, 38, 41, 60, 64, 69, 138 plot,MixtureClass,missing-method
logLik,DiscreteClass-method (plot-method), 137
(logLik-method), 73 plot,MultipleGroupClass-method
logLik,MixedClass-method (plot-method), 137
(logLik-method), 73 plot,SingleGroupClass,missing-method
logLik,MixtureClass-method (plot-method), 137
(logLik-method), 73 plot,SingleGroupClass-method
logLik,MultipleGroupClass-method (plot-method), 137
(logLik-method), 73 plot-method, 96, 137
logLik,SingleGroupClass-method plot.itemGAM (itemGAM), 63
(logLik-method), 73 poly2dich, 140
logLik-method, 73 print,DiscreteClass-method
LSAT6, 74 (print-method), 141
LSAT7, 75 print,MixedClass-method (print-method),
141
M2, 76, 82, 97 print,MixtureClass-method
marginal_rxx, 42, 78 (print-method), 141
MDIFF, 79 print,MultipleGroupClass-method
mdirt, 27, 55, 80, 139, 162 (print-method), 141
MDISC, 80, 86 print,SingleGroupClass-method
mirt, 9, 10, 16, 20, 41, 43, 51, 52, 54, 72, 81, (print-method), 141
87, 112, 116–118, 125, 126, 152, print-method, 141
153, 158 print.mirt_df, 141
170 INDEX
SAT12, 146
Science, 147
show,DiscreteClass-method
(show-method), 148
show,MixedClass-method (show-method),
148
show,MixtureClass-method (show-method),
148
show,MultipleGroupClass-method
(show-method), 148
show,SingleGroupClass-method
(show-method), 148
show-method, 148
SIBTEST, 149
simdata, 101, 151
SingleGroupClass-class, 10, 95, 158
summary,DiscreteClass-method
(summary-method), 159
summary,MixedClass-method
(summary-method), 159
summary,MixtureClass-method
(summary-method), 159
summary,MultipleGroupClass-method
(summary-method), 159
summary,SingleGroupClass-method
(summary-method), 159
summary-method, 96, 159
vcov,DiscreteClass-method
(vcov-method), 164