| fit.MIRT | R Documentation |
Fits a multidimensional extension of the 1PL, 2PL, 3PL, or 4PL item response model to binary response data. Two estimation backends are provided: full Bayesian inference via Hamiltonian Monte Carlo (Stan) and a fast stochastic-EM algorithm (iStEM) that scales to large data sets.
fit.MIRT(
data,
model = "2PL",
D = NULL,
Q.matrix = NULL,
method = c("iStEM", "stan"),
control.model = NULL,
control.method = NULL
)
data |
An |
model |
Character string specifying the model type. Accepts both
internal codes ( |
D |
Integer; number of latent dimensions ( |
Q.matrix |
An optional |
method |
Estimation method: |
control.model |
A named list of model-level hyperparameters. Supported entries:
|
control.method |
A named list of method-specific tuning parameters. Common entries (used by both Stan and iStEM):
Stan-specific entries:
iStEM-specific entries:
|
An object of class "MIRT" containing the following
components:
nparInteger; number of free parameters (= freely estimated item parameters + free correlation elements).
methodCharacter; "stan" or "iStEM".
thetaList with matrices est, se,
Rhat (N \times D); person parameter estimates.
parList with matrices est, se,
Rhat, free (I \times (D+3)); item parameter
arrays. Columns are a1..aD, b, c, d.
CorrList with matrices est, se,
Rhat (D \times D); inter-trait correlation matrix.
Q.matrixThe I \times D Q-matrix used.
stan.objThe stanfit object (Stan only;
NULL for iStEM).
MCMC.objThe list returned by rstan::extract()
(Stan only; NULL for iStEM).
logLikThe marginal log-likelihood computed via
Gauss–Hermite-type quadrature (class "logLik").
callThe matched call.
argumentsList of arguments used in fitting.
iStEMList of iStEM diagnostic quantities (iStEM only), including burn-in size, convergence flags, and theta grid length.
Let Y_{ij} \in \{0, 1\} denote the binary response of person
j = 1, \dots, N to item i = 1, \dots, I, and let
\boldsymbol{\theta}_j = (\theta_{j1}, \dots, \theta_{jD})'
denote the D-dimensional latent trait vector. The item response
function (IRF) for the four model variants is:
M1PL (Rasch / one-parameter logistic):
P(Y_{ij} = 1 \mid \boldsymbol{\theta}_j) =
\frac{1}{1 + \exp\bigl[-\bigl(\sum_{d=1}^{D} a_{id}\,\theta_{jd} - b_i\bigr)\bigr]},
\qquad a_{id} = 1
The M1PL implementation fixes the slope to 1 and is restricted to
D = 1; fixed unit slopes do not identify separate dimensions.
M2PL (two-parameter logistic):
P(Y_{ij} = 1 \mid \boldsymbol{\theta}_j) =
\frac{1}{1 + \exp\bigl[-\bigl(\sum_{d=1}^{D} a_{id}\,\theta_{jd} - b_i\bigr)\bigr]},
\qquad a_{id} > 0 \text{ if } q_{id} = 1,\; a_{id} = 0 \text{ otherwise}
The discrimination (slope) parameters a_{id} are freely estimated
subject to the Q-matrix pattern and a log-normal prior.
M3PL (three-parameter logistic):
P(Y_{ij} = 1 \mid \boldsymbol{\theta}_j) =
c_i + (1 - c_i) \times
\frac{1}{1 + \exp\bigl[-\bigl(\sum_{d=1}^{D} a_{id}\,\theta_{jd} - b_i\bigr)\bigr]}
where c_i \in [0, 1) is the lower-asymptote (pseudo-guessing) parameter.
M4PL (four-parameter logistic):
P(Y_{ij} = 1 \mid \boldsymbol{\theta}_j) =
c_i + (d_i - c_i) \times
\frac{1}{1 + \exp\bigl[-\bigl(\sum_{d=1}^{D} a_{id}\,\theta_{jd} - b_i\bigr)\bigr]}
where c_i \in [0, 1) is the lower asymptote and
d_i \in (0, 1] is the upper asymptote (1 - slippage).
In the unidimensional case (D = 1), these reduce to the standard
1PL–4PL models. For D > 1, the Q-matrix governs which dimensions
load on each item, enabling both exploratory (default triangular
identification) and confirmatory (user-specified Q-matrix) structures.
Prior distributions (Bayesian / MAP):
a_{id} (free)Log-normal: \log a_{id} \sim N(\mu_a, \sigma_a^2).
Defaults: \mu_a = 0.25, \sigma_a = 0.25.
b_iNormal: b_i \sim N(\mu_b, \sigma_b^2).
Defaults: \mu_b = 0, \sigma_b = 1.
c_iUniform: c_i \sim U(c_{\min}, c_{\max}).
Defaults: c_{\min} = 0, c_{\max} = 0.35.
d_iUniform: d_i \sim U(d_{\min}, d_{\max}).
Defaults: d_{\min} = 0.65, d_{\max} = 1.
\boldsymbol{\theta}_jMultivariate normal:
\boldsymbol{\theta}_j \sim N_D(\boldsymbol{\mu}_\theta, \boldsymbol{\Sigma}),
with \boldsymbol{\mu}_\theta = \mathbf{0} and
\boldsymbol{\Sigma} a correlation matrix.
method = "stan"):Full Bayesian inference via Hamiltonian Monte Carlo (NUTS/HMC).
The joint posterior of all parameters is explored using multiple
Markov chains. Output includes posterior means, standard deviations,
and \hat{R} convergence diagnostics for all parameters.
Marginal log-likelihood is approximated via Gauss–Hermite-type
quadrature over the latent space.
method = "iStEM"):An improved Stochastic EM (iStEM) algorithm that
alternates between (a) sampling \boldsymbol{\theta}_j from its
finite-grid full conditional as one D-dimensional block using
the person's complete response likelihood and (b) maximizing the
complete-data posterior for item parameters via L-BFGS-B.
The inter-trait correlation matrix \boldsymbol{\Sigma} is estimated
by constrained unit-diagonal normal-likelihood optimization.
Convergence is monitored using Geweke (1992) convergence diagnostics
and batch-means Monte Carlo error estimates. Standard errors are
obtained from the final Monte Carlo chain.
Reckase, M. D. (2009). Multidimensional Item Response Theory. Springer. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-0-387-89976-3")}
Birnbaum, A. (1968). Some latent trait models and their use in inferring an examinee's ability. In F. M. Lord & M. R. Novick, Statistical theories of mental test scores (pp. 397–479). Addison-Wesley.
Barton, M. A., & Lord, F. M. (1981). An upper asymptote for the three-parameter logistic item-response model. ETS Research Report Series, 1981(1), i–21.
Geweke, J. (1992). Evaluating the accuracy of sampling-based approaches to the calculation of posterior moments. In J. M. Bernardo et al. (Eds.), Bayesian Statistics 4 (pp. 169–193). Oxford University Press.
good.of.fit for goodness-of-fit evaluation,
get.fit.index.MIRT for MIRT-specific fit indices,
sim.data.MIRT for simulating data from this model,
rotate for post-hoc rotation of MIRT solutions,
logLik.MIRT for marginal log-likelihood extraction.
# Simulate data from a 2-dimensional 2PL model
sim <- sim.data.MIRT(N = 20, I = 6, D = 2, model = "m2pl")
# Fit via iStEM (fast, large-data friendly)
fit_istem <- fit.MIRT(sim$response, model = "m2pl", D = 2,
method = "iStEM",
control.method = list(
vis = FALSE, seed = 123,
M = 2, B = 2, burnin.maxitr = 2,
maxitr = 3, eps1 = 10, eps2 = 10,
estimate.se = FALSE))
# stan code, long time
# Fit via Stan (full Bayesian inference, computationally heavier)
fit_stan <- fit.MIRT(sim$response, model = "m2pl", D = 2,
method = "stan",
control.method = list(
chains = 1, iter = 200, warmup = 100,
cores = 1, seed = 123))
# Extract results
print(fit_istem$par$est) # item parameter estimates
print(fit_istem$theta$est) # person trait estimates
print(fit_istem$Corr$est) # factor correlation matrix
# Compute goodness-of-fit indices
gof <- get.fit.index(fit_istem)
summary(gof)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.