Marginal Maximum Likelihood#

API:

irtlib.mml.MMLCalibrator; irtlib.mml.Priors; irtlib.mml.marginal_log_likelihood()

Sources:

Bock and Aitkin [1981]; Mislevy [1986]; Du and Varadhan [2020]; Oakes [1999]

Motivation#

Calibration has to estimate item parameters without the examinees’ abilities. Marginal maximum likelihood (MML) integrates the abilities out over a population distribution and maximizes the likelihood of the item parameters alone; Bock and Aitkin’s EM algorithm makes it feasible for any number of items, with one small problem per item in each cycle [Bock and Aitkin, 1981, pp. 444, 447].

It is irtlib’s method for every model from the 1PL to the 4PL, and takes a response matrix with missing responses (ADR-0006), as Markov Chain Monte Carlo does. Its estimates assume a normal population of abilities, where Conditional Maximum Likelihood assumes nothing about it, and its likelihood is the one that Item and Person Fit and Model Comparison take. For the 3PL and 4PL, priors on the item parameters keep the estimates stable.

Definition#

Ability is normal with mean 0 and variance 1, approximated on nodes \(X_q\) with masses \(A_q\) that sum to 1 (Quadrature and Ability Priors). Examinee \(j\)’s marginal probability is \(\tilde P_j = \sum_q L_j(X_q) A_q\), where \(L_j\) is the product of \(P_i^{u_{ij}} (1 - P_i)^{1 - u_{ij}}\) over the items \(i\) examinee \(j\) answered, and the marginal log-likelihood is \(\sum_j \log \tilde P_j\) [Bock and Aitkin, 1981, pp. 445-446, Equations 6 and 8].

Each cycle has two steps [Baker, 1987, p. 132, Equations 42-46]; [Bock and Aitkin, 1981, p. 447]:

  • the E-step computes, for each item and node, the expected number of examinees answering the item there, \(\bar N_{iq} = \sum_j L_j(X_q) A_q / \tilde P_j\) over the examinees who answered it, and the expected number answering it correctly, \(\bar r_{iq}\), the same sum weighted by \(u_{ij}\);

  • the M-step maximizes \(\sum_q [\bar r_{iq} \log P_i(X_q) + (\bar N_{iq} - \bar r_{iq}) \log Q_i(X_q)]\) in the item parameters, the grouped log-likelihood of Item Response Functions.

The prior masses enter only through the expected counts. No cycle decreases the marginal likelihood [Dempster et al., 1977, p. 7, Theorem 1], and convergence is linear, slow near the solution [Dempster et al., 1977, p. 10]; [Bock and Aitkin, 1981, p. 447].

With priors on the item parameters, the estimates are Bayes modal: they maximize the log-likelihood plus the log-prior, and the EM algorithm carries over with the derivatives of the log-prior added to the M-step [Mislevy, 1986, p. 182, Equation 14].

Implementation#

Missing responses. The sums run over the examinees who answered each item, so the expected sample size \(\bar N_{iq}\) is per item; the sources define it over complete response patterns, shared by every item.

The grid. 61 equally spaced nodes on \([-6, 6]\), with the normal density at the nodes, normalized [Bock and Aitkin, 1981, p. 449] (ADR-0007).

The M-step. It solves in the slope, the intercept and the logits of \(c\) and \(d\), by Fisher scoring with step halving, on all free parameters at once: the system is one block per item unless a parameter is shared (ADR-0007). The 1PL shares one slope, estimated, with abilities \(N(0, 1)\) [Thissen, 1982, pp. 175-176, Equation 1]; fixing the slope at 1 for every item gives the model with slopes 1 and abilities \(N(0, 1)\) (ADR-0008).

Stopping. A calibration stops when no estimated parameter changes by more than its tolerance in a cycle, an E-step and an M-step (ADR-0007).

Priors. The priors are on these parameters (ADR-0008): lognormal on the slope, whose log-density keeps the \(-\log a\) term, normal on the intercept, and normal on the logit of \(c\), which keeps \(c\) inside \((0, 1)\) [Mislevy, 1986, p. 183]. In the M-step’s scoring information, a log-prior’s negative second derivative counts only where it is positive, so the system stays positive definite. The 3PL’s likelihood is “nearly flat along one or more dimensions” [Mislevy, 1986, p. 189], which a prior on the logit of \(c\) remedies. The 4PL adds an upper asymptote \(d < 1\), for examinees of high ability who still miss an item [Barton and Lord, 1981, p. 2], estimated on its logit with a normal prior there; recovering it takes thousands of examinees [Waller and Feuerstahler, 2017, p. 19]; [Culpepper, 2016, Section 5].

Items with no finite estimate. An item answered correctly by every examinee who answered it, or by none, has no finite estimate, and calibration raises an error listing such items unless a prior on the intercept keeps their estimates finite (ADR-0008).

Acceleration. An EM cycle is a fixed-point iteration \(x_{n+1} = F(x_n)\) of the vector \(x\) of free parameters; the largest eigenvalue of \(F\)’s Jacobian at the solution, the fraction of missing information, governs how slowly it converges [Du and Varadhan, 2020, p. 3]. By default a calibration accelerates it with SQUAREM [Du and Varadhan, 2020, p. 4, Algorithm 1]. From \(x_0\), two cycles give \(x_1 = F(x_0)\) and \(x_2 = F(x_1)\); with \(r = x_1 - x_0\), \(v = x_2 - x_1 - r\) and the steplength \(\alpha = -\lVert r \rVert / \lVert v \rVert\), the authors’ default (p. 4), the extrapolation is \(x_0 - 2 \alpha r + \alpha^2 v\). Where its log-posterior is above that of \(x_2\), Algorithm 1’s test with \(\eta = 0\), one cycle from it, the stabilization step, gives the next \(x_0\); elsewhere \(x_2\) does. No cycle then lowers the log-posterior, as no cycle of plain EM does [Dempster et al., 1977, p. 6]. The norms are Euclidean over the free parameters, a shared slope counted once, and an extrapolation with a parameter that is not finite, or a guessing parameter at or above its upper asymptote, is not kept. The extrapolation is not a cycle: the stopping rule applies to every cycle, an EM step with or without acceleration.

The record of the cycles. The result holds the marginal log-likelihood after each cycle, the extrapolations left out, and its last value is the calibration’s log-likelihood; with priors, it leaves out the log-prior.

Standard errors and covariances. The covariance of the estimated parameters, the slopes \(\lambda\), the intercepts \(\zeta\) and the logits of \(c\) and \(d\), is the inverse of the observed information at the estimates [Chalmers, 2018, p. 4], computed by Oakes’s identity [Oakes, 1999, p. 480]: the score of the marginal log-likelihood is the M-step’s gradient at the E-step’s own parameters (Equation 5), and its derivative as both move together is the observed-data Hessian, the sum of the complete-data Hessian and the missing information (Equation 6). That score, log-prior included, is differenced centrally with step \(10^{-5}\), the E-step recomputed at each shifted point, so the posterior precision takes in the log-prior’s second derivative [Mislevy, 1986, p. 182, Equations 15-17]; the result is symmetrized, which Chalmers [2018, p. 17] finds improves it (ADR-0007). The covariance of each item’s \(a\), \(b = -\zeta / \lambda\), \(c\) and \(d\) follows from that item’s block of it by the delta method, a 1PL’s block, when its common slope is estimated, holding the slope’s variance and its covariances with the item’s own parameters; the standard errors are the square roots of its diagonal.

Starting values. The slope 0.851, the intercept \(\Phi^{-1}(p_i) \cdot 1.702 / \sqrt{0.75}\), or 2 where \(p_i\) is 0 or 1, the guessing parameter 0.15 and the upper asymptote 0.85, where \(p_i\) is item \(i\)’s proportion correct among the examinees who answered it (ADR-0007); Bock and Aitkin [1981, p. 458] name the inverse normal of the proportion correct as a starting intercept.

Comparison with mirt
  • What matches. mirt(data, 1, itemtype = ...) in mirt 1.48, with its default grid, its starting values and SE.type = "Oakes" [Chalmers, 2026, p. 122]; irtlib computes the starting values over the answered responses only (ADR-0007).

  • Without priors the parity tests find the estimates within \(10^{-5}\) of mirt’s recorded at TOL = 1e-8, the log-likelihoods within a relative \(10^{-10}\), and the standard errors within a relative \(10^{-4}\), for the 1PL, the 2PL and fixed slopes, on the LSAT 6 and LSAT 7 data and on simulated data; each item’s covariance matrix of \(a\) and \(b\), from mirt’s covariance matrix of the slopes and intercepts, agrees within a relative \(2 \times 10^{-4}\) for the 1PL and the 2PL (ADR-0003).

  • With priors the estimates and standard errors agree as closely on the LSAT 7 3PL. On the simulated 2PL, 3PL and 4PL, mirt reports convergence where the gradient of the marginal log-posterior is still \(6.6 \times 10^{-5}\) to \(7.4 \times 10^{-4}\) in size; irtlib’s estimates bring it below \(10^{-6}\), at a higher log-posterior, and differ from mirt’s by up to \(1.7 \times 10^{-4}\), and by \(1.6 \times 10^{-2}\) on the 4PL, whose likelihood is nearly flat along a ridge (measured 2026-11-27). With a lognormal prior on the slope, mirt’s Hessian of the prior has the opposite sign on its last term (R/utils.R:1430), which its standard errors take in; irtlib differentiates the lognormal log-density itself. The 4PL’s asymptotes’ standard errors agree within a relative \(2 \times 10^{-3}\). The parity tests keep each departure as an expected failure.

  • The parameters and the priors. The M-step solves in mirt’s parameters [Chalmers, 2026, pp. 132-133], and the priors are mirt’s densities on them (ADR-0008).

  • The tolerance. mirt’s default TOL is \(10^{-4}\) for EM [Chalmers, 2026, p. 127]; irtlib’s is \(10^{-6}\) (ADR-0007).

  • Acceleration. mirt accelerates by Ramsay’s rule by default and offers SQUAREM [Chalmers, 2026, pp. 128-129]; the maximum is the same (ADR-0007).

  • Standard errors. Chalmers (2018, pp. 5-7), as mirt, differences only the missing information and takes the complete-data Hessian analytically; differencing the whole score keeps one path for every model and prior.

Parameters#

Parameter

Default

Description

Default from

model

"2PL"

"1PL" (one estimated slope shared by every item), "2PL", "3PL" or "4PL".

mirt’s default item type [Chalmers, 2026, p. 123]

fixed_slope

None

A slope every item keeps instead of estimating it; 1 with the 1PL gives slopes 1 and abilities \(N(0, 1)\).

no fixed slope (ADR-0008)

priors

None

A Priors on the slope, the intercept and the logits of \(c\) and \(d\), each a mean and a standard deviation. Recommended for the 3PL and the 4PL.

no default prior (ADR-0008)

tolerance

1e-6

The stopping rule: the largest change of an estimated parameter in a cycle.

ADR-0007

max_cycles

500

The most cycles before the calibration stops unconverged.

mirt’s NCYCLES [Chalmers, 2026, p. 129]

acceleration

"squarem"

"squarem" [Du and Varadhan, 2020, p. 4, Algorithm 1] or "none".

ADR-0007

grid

61 nodes on \([-6, 6]\)

The nodes the abilities are integrated over.

mirt’s quadpts and theta_lim [Chalmers, 2026, pp. 127, 129]

start of calibrate

None

Items to start from, one per column.

mirt’s starting values (ADR-0007)

Guarantees#

  1. Responses may be missing; an examinee who answered no item changes no estimate.

  2. With or without acceleration, a calibration converges to the same maximum.

  3. An item answered correctly by every examinee who answered it, or by none, raises an error naming it, unless a prior on the intercept is given.

  4. An item whose estimates are not valid in an item bank, such as a miskeyed item whose slope is not positive, is left out of the result’s bank, with a warning naming it.

  5. A calibration that does not meet its stopping rule within max_cycles says so in its result and warns with a ConvergenceWarning.

  6. Without priors, the marginal log-likelihood the result records after each cycle never falls from one cycle to the next, beyond rounding [Dempster et al., 1977, p. 7, Theorem 1]; with priors, the log-posterior does not [Dempster et al., 1977, p. 6], and the record, which leaves out the log-prior, can.

References#

[Bak87]

Frank B. Baker. Methodology review: item parameter estimation under the one-, two-, and three-parameter logistic models. Applied Psychological Measurement, 11(2):111–141, 1987. Open copy: https://hdl.handle.net/11299/103398. doi:10.1177/014662168701100201.

[BL81]

Mark A. Barton and Frederic M. Lord. An upper asymptote for the three-parameter logistic item-response model. Research Report RR-81-20, Educational Testing Service, Princeton, NJ, 1981. Open copy: https://files.eric.ed.gov/fulltext/ED207996.pdf. doi:10.1002/j.2333-8504.1981.tb01255.x.

[BA81] (1,2,3,4,5,6,7)

R. Darrell Bock and Murray Aitkin. Marginal maximum likelihood estimation of item parameters: application of an EM algorithm. Psychometrika, 46(4):443–459, 1981. Not openly available; Baker (1987) describes the method. doi:10.1007/BF02293801.

[Cha18] (1,2)

R. Philip Chalmers. Numerical approximation of the observed information matrix with Oakes' identity. British Journal of Mathematical and Statistical Psychology, 71(3):415–436, 2018. Open copy: https://onlinelibrary.wiley.com/doi/pdfdirect/10.1111/bmsp.12127. doi:10.1111/bmsp.12127.

[Cha26] (1,2,3,4,5,6,7)

R. Philip Chalmers. mirt: Multidimensional Item Response Theory. 2026. R package version 1.48, reference manual dated 2026-10-06. Open access. URL: https://cran.r-project.org/package=mirt.

[Cul16]

Steven Andrew Culpepper. Revisiting the 4-parameter item response model: Bayesian estimation and application. Psychometrika, 81(4):1142–1163, 2016. Not openly available; Zhang, Lu, Du and Zhang (2020) describe the method. doi:10.1007/s11336-015-9477-6.

[DLR77] (1,2,3,4,5)

A. P. Dempster, N. M. Laird, and D. B. Rubin. Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society: Series B (Methodological), 39(1):1–22, 1977. Not openly available; Woodruff and Hanson (1996) describe the method. doi:10.1111/j.2517-6161.1977.tb01600.x.

[DV20] (1,2,3,4)

Yu Du and Ravi Varadhan. SQUAREM: an R package for off-the-shelf acceleration of EM, MM and other EM-like monotone algorithms. Journal of Statistical Software, 92(7):1–41, 2020. Open access. doi:10.18637/jss.v092.i07.

[Mis86] (1,2,3,4,5)

Robert J. Mislevy. Bayes modal estimation in item response models. Psychometrika, 51(2):177–195, 1986. Not openly available; Harwell and Baker (1991) describe the method. doi:10.1007/BF02293979.

[Oak99] (1,2)

David Oakes. Direct calculation of the information matrix via the EM algorithm. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 61(2):479–482, 1999. Not openly available; Chalmers (2018) describes the method. doi:10.1111/1467-9868.00188.

[Thi82]

David Thissen. Marginal maximum likelihood estimation for the one-parameter logistic model. Psychometrika, 47(2):175–186, 1982. Not openly available; Baker (1987) describes the method. doi:10.1007/BF02296273.

[WF17]

Niels G. Waller and Leah Feuerstahler. Bayesian modal estimation of the four-parameter item response model in real, realistic, and idealized data sets. Multivariate Behavioral Research, 52(3):350–370, 2017. Not openly available; Harwell and Baker (1991) describe the Bayes modal estimation it applies. doi:10.1080/00273171.2017.1292893.

API Reference#

Marginal maximum likelihood calibration of the 1PL to 4PL with the EM algorithm, with optional priors.

class irtlib.mml.Acceleration(*values)[source]#

How MMLCalibrator accelerates its EM cycles.

"squarem" extrapolates from every two cycles and keeps an extrapolation only where its log-posterior is above the second cycle’s, so no cycle lowers the log-posterior; "none" runs plain EM. Both reach the same maximum by the same stopping rule, "squarem" in fewer cycles. A member equals its value, so either can be passed where an acceleration is expected.

Examples

>>> Acceleration("squarem") is Acceleration.SQUAREM
True
class irtlib.mml.MMLCalibrator(model: IrtModel | str = IrtModel.PL2, *, fixed_slope: float | None = None, priors: Priors | None = None, tolerance: float = 1e-06, max_cycles: int = 500, acceleration: Acceleration | str = Acceleration.SQUAREM, grid: QuadratureGrid | None = None)[source]#

Calibrate the 1PL to 4PL by marginal maximum likelihood with the EM algorithm, with optional priors.

Each call to calibrate() estimates the items of one response matrix, which may have missing responses. Abilities are normal with mean 0 and variance 1. With priors on the item parameters, the estimates are Bayes modal: they maximize the log-likelihood plus the log-prior.

The Marginal Maximum Likelihood page gives the method, its sources and the origin of each default.

Parameters:
modelirtlib.IrtModel or str, optional

"2PL", the default, estimates a slope per item; "1PL" one slope shared by every item; "3PL" also a guessing parameter per item, best with a guessing prior; "4PL" also an upper asymptote per item, best with priors on both asymptotes and thousands of examinees.

fixed_slopefloat, optional

A slope every item keeps instead of estimating it, with any model.

priorsPriors, optional

Priors on the slope, the intercept and the logits of the guessing parameter and upper asymptote of every item.

tolerancefloat, optional

The stopping rule: calibration stops when no estimated parameter changes by more than this in a cycle, an E-step and an M-step. Default is 1e-6.

max_cyclesint, optional

The most cycles a calibration runs before it stops unconverged. Default is 500.

accelerationAcceleration or str, optional

"squarem", the default, extrapolates between cycles to reach the same estimates in fewer of them; the extrapolations are not cycles. "none" runs plain EM.

gridirtlib.quadrature.QuadratureGrid, optional

The nodes the abilities are integrated over. Default is 61 equally spaced nodes on [-6, 6].

Raises:
ValueError

If fixed_slope is not finite and positive; a slope prior comes with fixed_slope, a guessing prior with a model other than the 3PL and 4PL, or an upper prior with a model other than the 4PL; tolerance is not positive; max_cycles is less than 1; or acceleration is not an Acceleration.

Examples

>>> import numpy
>>> responses = numpy.array([[1, 0, 1], [0, 0, 1], [1, 1, 0], [0, 1, 1], [1, 0, 0]], dtype=float)
>>> calibration = MMLCalibrator("1PL").calibrate(responses)
>>> calibration.converged, calibration.n_parameters
(True, 4)
calibrate(responses: NDArray[floating[Any]], start: ItemBank | None = None) → Calibration[source]#

Estimate the items of a response matrix.

Parameters:
responsesnumpy.ndarray

The response matrix: one row per examinee, one column per item, holding 1, 0 or NaN for a missing response.

startirtlib.ItemBank, optional

Items to start from, one per column; the 1PL starts from their mean slope. By default, the slope 0.851 and an intercept from each item’s proportion correct.

Returns:
Calibration

The estimates, the covariance of each item’s estimates and the log-likelihood at them, with the cycles run, which do not count the extrapolations of an acceleration, and the largest change of a parameter in the last one. If the stopping rule is not met within max_cycles, the result says so and a ConvergenceWarning is issued; if the information matrix cannot be inverted, or gives a variance that is not positive, the result has no covariances or standard errors and a RuntimeWarning is issued; if an item’s estimates are not valid in an item bank, such as a miskeyed item’s slope that is not positive, the result’s bank leaves the item out and a RuntimeWarning names it.

Raises:
TypeError

If the responses are neither Booleans, integers nor floats.

ValueError

If the responses fail irtlib.calibration.validate_responses(); an item was answered correctly by every examinee who answered it or by none, which leaves it no finite estimate; the expected information of the parameters is singular; or start has a different number of items, or leaves an item’s guessing parameter at or above its upper asymptote.

class irtlib.mml.Priors(slope: tuple[float, float] | None = None, intercept: tuple[float, float] | None = None, guessing: tuple[float, float] | None = None, upper: tuple[float, float] | None = None)[source]#

Priors on the parameters of every item, each given as a mean and a standard deviation (ADR-0008).

A prior applies to each item’s parameter, and once to a parameter the items share, such as the 1PL’s slope.

Parameters:
slopetuple[float, float] or None

The mean and standard deviation of the log of every slope: a lognormal prior on the slope.

intercepttuple[float, float] or None

The mean and standard deviation of a normal prior on every intercept, -a * b. It keeps the estimates of items answered correctly by everyone or by no one finite.

guessingtuple[float, float] or None

The mean and standard deviation of a normal prior on the logit of every guessing parameter; for the 3PL and 4PL.

uppertuple[float, float] or None

The mean and standard deviation of a normal prior on the logit of every upper asymptote; for the 4PL.

Raises:
ValueError

If a mean is not finite, or a standard deviation is not finite and positive.

Examples

>>> Priors(guessing=(-1.386, 0.5)).guessing
(-1.386, 0.5)
irtlib.mml.marginal_log_likelihood(responses: NDArray[floating[Any]], items: NDArray[floating[Any]], grid: QuadratureGrid | None = None) → float[source]#

Return the marginal log-likelihood of a response matrix, with abilities normal with mean 0 and variance 1.

Parameters:
responsesnumpy.ndarray

The response matrix: one row per examinee, one column per item, holding 1, 0 or NaN for a missing response.

itemsnumpy.ndarray

A matrix of items [a, b, c, d], one row per column of responses.

gridirtlib.quadrature.QuadratureGrid, optional

The nodes the abilities are integrated over. Default is 61 equally spaced nodes on [-6, 6].

Returns:
float

The log-likelihood, summed over examinees.

Raises:
TypeError

If the responses are neither Booleans, integers nor floats.

ValueError

If the responses fail irtlib.calibration.validate_responses(), or items is not a matrix of four columns with one row per item.

Examples

>>> import numpy
>>> round(marginal_log_likelihood(numpy.array([[1.0], [0.0]]), numpy.array([[1.0, 0.0, 0.0, 1.0]])), 6)
-1.386294