Weighted Likelihood#

API:

irtlib.ability.weighted_likelihood()

Sources:

Warm [1985]; Warm [1989]; Magis and Raîche [2012]; Magis [2016]

Motivation#

Warm’s weighted likelihood estimate (WLE) removes the first-order bias of the maximum likelihood estimate [Warm, 1989, p. 427]; [Warm, 1989, p. 431, Theorem], without a prior. Warm finds finite estimates for responses all correct or all incorrect on his tests [Warm, 1989, p. 443, Table 1], and Magis and Raîche [2012, p. 11] propose the estimator for them. Choose it over Maximum Likelihood when the estimate’s bias matters, and over Maximum A Posteriori and Expected A Posteriori when no prior should enter the estimate.

Definition#

Warm’s estimate is the root of the modified score equation

\[\sum_i \frac{(u_{ij} - P_i) P_i'}{P_i Q_i} + \frac{J}{2 I} = 0, \quad J = \sum_i \frac{P_i' P_i''}{P_i Q_i}\]

[Warm, 1989, p. 431, Equation 10]; [Warm, 1989, p. 430], the derivative of the log of the weighted likelihood \(w(\theta) L_j(\theta)\), with \(\partial \log w / \partial\theta = J / (2 I)\), which the estimate maximizes (p. 446, Equations A3 and A4). When every \(c_i = 0\), \(w = I^{1/2}\) (p. 431), in Warm’s model, which fixes \(d_i = 1\) (p. 428, Equation 1). The estimate’s variance is asymptotically \(1 / I\), that of the maximum likelihood estimate (p. 431).

Warm’s dissertation gives the same steps: the maximum likelihood estimate’s bias is \(-J / (2 I^2)\), the expression of Lord (1983a) as Warm [1985, p. 7, Equation 6] gives it; the weight’s log-derivative \(J / (2 I)\) cancels it (p. 66, Equations A.6 and A.7), which gives the modified score equation (p. 8, Equation 11). In general the weight has no closed form, but when every \(c_i = 0\), in Warm’s model, which has no upper asymptote, it is \(I^{1/2}\) [Warm, 1985, p. 9], and under the 1PL and the 2PL the WLE is the Bayes modal estimate under Jeffreys’ prior [Magis and Raîche, 2012, p. 6]. When an item has \(c_i > 0\) or \(d_i < 1\), \(J\) is not the derivative of \(I\), so the WLE is defined by its equation, not by a likelihood weighted by \(I^{1/2}\).

Implementation#

The standard error is by default \(1 / \sqrt{I(\hat\theta)}\), from the asymptotic variance \(1 / I\) [Warm, 1989, p. 431], infinite where the information is 0. The argument se chooses one of two others, each infinite there too, which both take

\[F = \frac{J' I - J I'}{2 I^2},\]

the derivative of \(J / (2 I)\) [Magis, 2016, Section 3.1, Equation 20], at the estimate. As \(J / I\) is the mean of the items’ \(P_i'' / P_i'\) weighted by their information, irtlib takes \(F\) as half the weighted mean of their derivatives plus half their weighted covariance with the derivatives of the items’ log-information, whose terms stay bounded as \(I\) tends to 0. Equation 20 as written loses every digit where the estimate lies far from every item answered, with \(I\) below about \(10^{-14}\) (measured 2026-12-02). "corrected" is \(1 / \sqrt{I - F}\), the information that Magis and Raîche [2012, p. 6, Equation 14] correct by subtracting \(F\). When every item has \(c_i = 0\) and \(d_i = 1\), \(I - F\) is the curvature of the weighted log-likelihood at its maximum, so it is positive; with a guessing parameter or an upper asymptote below 1 it can be negative, which leaves no standard error, NaN. It was on 13 of 3,920 sets of responses, 0.4% of their probability, on random 3PL tests of 2 to 8 items, and on none of 4,560 on 2PL tests (measured 2026-11-24). "sandwich" is \(I^{1/2} / |I - F|\) [Magis, 2016, Section 3.1, Equation 19], the standard error that M-estimation gives the class of estimators the WLE belongs to (Section 2.1, Equation 13; Section 3, Result 1, Equation 16).

Against the WLE’s spread at a known ability, over every set of responses to 5 and to 10 items and 3,000 simulated ones to 20 and to 40, the standard error \(1 / \sqrt{I}\) overestimates the error of short tests, by 10% under the 2PL and by 28% under the 3PL at 5 items: a stopping rule on the standard error runs a few items longer than needed. "corrected" roughly halves that gap. "sandwich" is closest under the 3PL but underestimates the error under the 2PL, by 8% at 5 items, which would stop tests too early. From 20 items on, the three agree within about 3% (measured 2026-11-24).

Not the approximation. Expanding the modified score around the maximum likelihood estimate gives \(\hat\theta_{\mathrm{WLE}} \approx \hat\theta_{\mathrm{ML}} + J / (2 I^2)\), which irtlib does not use: it fails where the WLE matters most, since the maximum likelihood estimate is infinite for responses all correct or all incorrect, and with a guessing parameter it can lie where \(I\) is near 0.

The search. It evaluates the modified score at 121 equally spaced abilities within the bounds, 0.1 apart on the default \([-6, 6]\), so two roots closer than that can fall between the same two points and go unseen. Each change of sign from positive to negative, refined by Brent’s method as SciPy’s scipy.optimize.brentq implements it (SciPy 1.18.1, scipy/optimize/Zeros/brentq.c:36-130), from the values of the scan at its ends, is a maximum of the weighted likelihood, and so is a bound the score points out of. Of several, the estimate is the one of largest weighted likelihood, ranked by integrating the score from the lower bound with scipy.integrate.quad; an integral that does not converge warns with SciPy’s IntegrationWarning, and the estimate is the candidate ranked highest by the integrals as they stand. irtlib’s estimate lies within the bounds whatever the responses. An examinee who answered no item has no estimate, NaN, and standard error \(\infty\), as under maximum likelihood (ADR-0010).

Comparison with mirt and catR
  • mirt 1.48 maximizes \(\log L_j + \tfrac12 \log I\) instead (R/fscores.internal.R:705-738), Warm’s estimate when every answered item has \(c_i = 0\) and \(d_i = 1\), and takes its standard error from nlm’s numerical Hessian of that weighted log-likelihood (R/fscores.internal.R:1103-1119). On 2PL items that curvature is \(I - F\), and the parity tests find mirt’s standard errors within a relative \(2 \times 10^{-4}\) of "corrected", the Hessian’s accuracy.

  • catR 3.17 uses the same standard error by default (R/semTheta.R:90-96), and Magis’s sandwich formula with sem.type = "new" (R/semTheta.R:90-94); the parity tests compare both. Where Warm’s modified score has three roots in the range, two maxima of the weighted likelihood and a minimum, catR’s uniroot can converge to the lower maximum, where irtlib returns the one of larger weighted likelihood: the parity tests keep that case as an expected failure (ADR-0003).

Parameters#

Parameter

Default

Description

Default from

bounds

(-6.0, 6.0)

The interval the estimate lies within.

catsim’s (ADR-0010)

tol

1e-6

The root search’s tolerance in ability.

catsim’s (ADR-0010)

se

"fisher"

The standard error’s formula, a WleStandardError: "fisher", "corrected" or "sandwich".

catR’s sem.type = "classic"; catsim’s

Guarantees#

  1. The estimate of every examinee who answered an item lies within the bounds, whatever the responses.

  2. Where the weighted likelihood has several maxima in the bounds, the estimate is the one of largest weighted likelihood among those the scan separates.

  3. An examinee who answered no item gets NaN, with standard error \(\infty\).

  4. Every formula’s standard error is \(\infty\) where the information is 0; "corrected" gives NaN where \(I - F\) is negative, without a warning.

References#

[Mag16] (1,2,3)

David Magis. Efficient standard error formulas of ability estimators with dichotomous item response models. Psychometrika, 81(1):184–200, 2016. Not openly available. doi:10.1007/s11336-015-9443-3.

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

David Magis and Gilles Raîche. Random generation of response patterns under computerized adaptive testing with the R package catR. Journal of Statistical Software, 48(8):1–31, 2012. Open access. doi:10.18637/jss.v048.i08.

[War85] (1,2,3)

Thomas A. Warm. Weighted Likelihood Estimation of Ability in Item Response Theory with Tests of Finite Length. PhD thesis, University of Oklahoma, 1985. Open access. URL: https://hdl.handle.net/11244/5356.

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

Thomas A. Warm. Weighted likelihood estimation of ability in item response theory. Psychometrika, 54(3):427–450, 1989. Not openly available; Warm's (1985) dissertation, https://hdl.handle.net/11244/5356, derives the same results. doi:10.1007/BF02294627.

API Reference#

irtlib.ability.weighted_likelihood(responses: ArrayLike, items: NDArray[floating[Any]], *, bounds: tuple[float, float] = (-6.0, 6.0), tol: float = 1e-06, se: WleStandardError | str = WleStandardError.FISHER) → AbilityEstimates[source]#

Return each examinee’s weighted likelihood estimate, Warm’s, with its standard error.

The estimate is the root of Warm’s modified score within the bounds; of several, the one of largest weighted likelihood, and of none, the bound the score points to. An examinee who answered no item has no estimate, NaN, and standard error inf. The evaluation count is the number of modified-score evaluations. A ranking integral that does not converge warns with scipy.integrate.IntegrationWarning.

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

Parameters:
responsesarray_like

The response matrix, one row per examinee and one column per item: 1 or True for a correct response, 0 or False for an incorrect one, and NaN for a missing one.

itemsnumpy.ndarray

The items [a, b, c, d], a matrix of shape (n, 4), one row per column of responses, with a > 0 and 0 <= c < d <= 1.

boundstuple[float, float], optional

The range the estimate is searched in. Default is (THETA_MIN_EXTENDED, THETA_MAX_EXTENDED), [-6, 6].

tolfloat, optional

The absolute tolerance of the root search, in the ability scale. Default is 1e-6.

seWleStandardError or str, optional

The formula of the standard error, a WleStandardError. Default is "fisher".

Returns:
AbilityEstimates

The estimates, their standard errors by the formula se, and the evaluation counts.

Raises:
TypeError

If the responses are neither Booleans, integers nor floats.

ValueError

If bounds is not a finite interval, tol is not positive, se is not a WleStandardError, items is not an (n, 4) matrix of finite numbers, responses is not a matrix with one column per item, or a response is not 0, 1 or NaN.

Examples

>>> import numpy
>>> items = numpy.array([[1.0, -1.0, 0.0, 1.0], [1.5, 0.0, 0.2, 1.0], [0.8, 1.0, 0.0, 0.95]])
>>> estimates = weighted_likelihood(numpy.array([[1, 0, numpy.nan], [1, 1, 1]]), items)
>>> estimates.theta.round(4), estimates.standard_errors.round(4)
(array([-0.5154,  1.8903]), array([1.4041, 1.9431]))
>>> weighted_likelihood(numpy.array([[1, 0, numpy.nan], [1, 1, 1]]), items, se="sandwich").standard_errors.round(4)
array([0.9436, 1.8597])
class irtlib.ability.WleStandardError(*values)[source]#

The formula of the standard error of a weighted likelihood estimate, for weighted_likelihood().

"fisher" is the inverse square root of the test information at the estimate. "corrected" and "sandwich" also take the derivative of Warm’s term of the modified score there; "corrected" gives NaN where the corrected information is negative. Each is inf where the information is 0. The Weighted Likelihood page gives the formulas and their sources. A member equals its value, so either can be passed where a formula is expected.

Examples

>>> WleStandardError("sandwich") is WleStandardError.SANDWICH
True