Maximum Likelihood#
- API:
- Sources:
Magis and Raîche [2012]; Warm [1989]; Chang and Ying [1996]; Veerkamp and Berger [1994]
Motivation#
The maximum likelihood (ML) estimate is the ability at which the examinee’s responses are most likely. It needs no prior, so it adds nothing to what the responses say, and its standard error comes straight from the test information. Its weakness is responses all correct or all incorrect, which no finite ability explains best; irtlib reports them as they are, \(+\infty\) or \(-\infty\), and lets the caller choose bounds or a fallback estimator. Maximum A Posteriori and Expected A Posteriori add a prior, and Weighted Likelihood removes the estimate’s first-order bias.
Definition#
The estimate maximizes \(L_j(\theta)\), and its standard error is \(1 / \sqrt{I(\hat\theta)}\) [Magis and Raîche, 2012, p. 4, Equations 2 and 3]. The likelihood of responses all correct rises with the ability and that of responses all incorrect falls, so their estimates are \(+\infty\) and \(-\infty\) [Warm, 1989, p. 442]. As \(\theta \to -\infty\) each \(P_i\) tends to \(c_i\), and as \(\theta \to +\infty\) to \(d_i\), so the likelihood tends to \(\prod_i c_i^{u_{ij}} (1 - c_i)^{1 - u_{ij}}\) and to \(\prod_i d_i^{u_{ij}} (1 - d_i)^{1 - u_{ij}}\): under the 3PL and 4PL, responses that are neither all correct nor all incorrect can also have their supremum at an infinity.
The maximum likelihood estimate is the maximizer over the extended real line: \(+\infty\) or \(-\infty\) wherever the likelihood comes closest to its supremum only in that limit, with standard error \(\infty\), since the information tends to 0 at either infinity (ADR-0010). An examinee who answered no item has a constant likelihood, which every ability maximizes: its estimate is NaN, and its standard error \(\infty\), the information being 0.
Implementation#
Bounds or a fallback. The caller has two ways to finite numbers, never used together:
bounds: the estimate maximizes the likelihood within them, and responses all correct or all incorrect give the bound they point to. Bounds are always set in practice [Warm, 1989, p. 442].fallback: another estimator, called once on the rows whose estimate is not finite, the unanswered rows included, whose estimates, standard errors, evaluation counts and warnings replace theirs; thefrom_fallbackfield ofAbilityEstimatesmarks those rows, and the fallback’s warnings name the rows of the caller’s matrix.
The search. Where an item answered has \(c_i > 0\) or \(d_i < 1\), the likelihood can have several maxima: under the 3PL the likelihood equation may have several roots [Chang and Ying, 1996, p. 223], and the likelihood several local maxima [Veerkamp and Berger, 1994, p. 4]. The search evaluates the log-likelihood at equally spaced abilities of the range: 101 when no item answered has a slope \(a_i\) above 2.5, 0.12 apart on \([-6, 6]\), and otherwise \(\lceil 40 \max_i a_i \rceil + 1\), 0.3 divided by the steepest slope apart on \([-6, 6]\), since a steep item can make a peak narrower than 0.12, up to 2,401 points, 0.005 apart, for slopes of 60 and above, so that a pathological slope cannot exhaust memory. It refines the best between its neighbours by Newton’s method on the log-likelihood’s first and second derivatives, from the vertex of the parabola through the three points, keeping each step inside a bracket that shrinks to the side the first derivative points to and bisecting the bracket where a step would leave it, and it keeps the refinement only if no worse. When every item answered has \(c_i = 0\) and \(d_i = 1\), the second derivative is \(-I\) (see Maximum A Posteriori), so the log-likelihood is concave and has at most one maximum. The search then skips the points: the estimate is a bound where the first derivative points out of the range, and otherwise the zero of the first derivative, found by the same bracketed Newton’s method from the middle of the range.
On about 38,000 random mixed patterns of 1 to 60 3PL and 4PL items with slopes from 0.5 to 2.5, half with responses drawn from the model, 101 and 201 points found the global maximum on \([-6, 6]\) every time and 81 points missed it once, while Brent’s method over the whole range, with no points, missed it 203 times, by a median of 3.7 in ability. On about 27,000 patterns of 1 to 30 items, half of them with slopes up to 60, the points spaced by the steepest slope missed it twice, each time by less than 0.001 in log-likelihood, where 101 points missed it 50 times and 201 points 11 (measured 2026-11-28). The numbers of points have no published source; the sources wanted list them.
Without bounds. The range starts as \([-6, 6]\). Beyond the lower end of the range, a correct response’s probability is at most its value at the end, since it rises with the ability, and an incorrect one’s at most \(1 - c_i\); beyond the upper end, a correct one’s is at most \(d_i\) and an incorrect one’s at most its value at the end. While these bounds leave room beyond an end for a log-likelihood above both the best found and the two limits, that end moves out, twice as far each time, and the new stretch is searched the same way, with as many points as the range, so that their spacing doubles with each stretch. The estimate is then the infinity of the larger limit, \(-\infty\) of two equal ones, if that limit is at least the best value found, within a relative \(10^{-12}\), and the best ability found otherwise. After 64 moves of an end, which only items of a vanishing discrimination need, the search stops at the best ability found and warns.
Comparison with mirt and catR
mirt 1.48 also gives \(+\infty\) or \(-\infty\) to responses all correct or all incorrect (
R/fscores.internal.R:397-405), with no standard error, NA, where irtlib’s is \(\infty\), and NA to both for an examinee who answered no item (R/fscores.internal.R:94-96, 185). It searches the other responses with R’snlmfrom the EAP estimate, up to an ability of \(\pm 20\) (R/fscores.R:305;R/fscores.internal.R:687), takes the standard error fromnlm’s numerical Hessian, the observed information (R/fscores.internal.R:1072-1101), which is \(I\) for items with \(c_i = 0\) and \(d_i = 1\), and turns an estimate whose standard error exceeds 30 into an infinity (R/fscores.internal.R:1094-1096), which irtlib does not do.catR 3.17 sets bounds by default: its default
constantPatt = NULLestimates responses all correct or all incorrect by maximum likelihood too [Magis et al., 2022, p. 115], which returns the end of itsrangethat the score points to (R/thetaEst.R:9-10, 100-109). Where the likelihood has a local minimum inside the range, catR’sthetaEstsolves the likelihood equation withuniroot(R/thetaEst.R:100-102), which can converge to that minimum, while irtlib maximizes the likelihood: the parity tests keep those cases as expected failures (ADR-0003).
Parameters#
Parameter |
Default |
Description |
Default from |
|---|---|---|---|
|
None |
The interval the estimate maximizes the likelihood within; None searches the extended real line. |
|
|
None |
Another estimator for the examinees without a finite estimate; not with |
|
|
|
The search’s tolerance in ability. |
catsim’s (ADR-0010) |
Guarantees#
Responses all correct get \(+\infty\) and responses all incorrect \(-\infty\), with standard error \(\infty\), unless
boundsorfallbackis given.With
bounds, the estimate of every examinee who answered an item lies within them.Where the likelihood has several maxima, the estimate is the highest the search’s points separate.
An examinee who answered no item gets NaN, with standard error \(\infty\), unless
fallbackis given.
References#
Hua-Hua Chang and Zhiliang Ying. A global information approach to computerized adaptive testing. Applied Psychological Measurement, 20(3):213–229, 1996. Open copy: https://hdl.handle.net/11299/119092. doi:10.1177/014662169602000303.
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.
David Magis, Gilles Raîche, and Juan Ramón Barrada. catR: Generation of IRT Response Patterns under Computerized Adaptive Testing. 2022. R package version 3.17, reference manual, published on CRAN 2022-06-24. Open access. URL: https://cran.r-project.org/package=catR.
Wim J. J. Veerkamp and Martijn P. F. Berger. Some new item selection criteria for adaptive testing. Research Report 94-6, University of Twente, 1994. Open access. URL: https://ris.utwente.nl/ws/files/5155670/RR_94-6.pdf.
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.maximum_likelihood(responses: ArrayLike, items: NDArray[floating[Any]], *, bounds: tuple[float, float] | None = None, fallback: Callable[[NDArray[floating[Any]], NDArray[floating[Any]]], AbilityEstimates] | None = None, tol: float = 1e-06) AbilityEstimates[source]#
Return each examinee’s maximum likelihood estimate, with its standard error.
Without
boundsthe estimate maximizes the likelihood over the whole ability scale, infinities included: it isinfor-infwhere the likelihood comes closest to its supremum only in that limit, as it does for responses all correct or all incorrect, and its standard error is theninf. Withboundsit maximizes the likelihood within them, and is finite. An examinee who answered no item has no estimate, NaN, and standard errorinf. Afallbackreplaces every estimate that is not finite, infinite or NaN. A search that cannot settle whether a larger likelihood lies beyond its range warns withRuntimeWarning, and the estimate is the best ability found.The Maximum 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 ofresponses, witha > 0and0 <= c < d <= 1.- boundstuple[float, float] or None, optional
The range the estimate is searched in; responses all correct or all incorrect give the bound they point to. Default is None, the whole ability scale.
- fallbackCallable or None, optional
An estimator called as
fallback(responses, items), once, on the rows whose estimate is not finite, such asfunctools.partial(expected_a_posteriori, log_prior=normal_log_prior(0.0, 1.0)); its estimates, standard errors, evaluation counts and warnings replace theirs, andfrom_fallbackmarks them. The warnings of its estimates are issued with the rows ofresponses, and those of irtlib’s estimators it calls only through them: a warning it issues itself passes through unchanged, and an estimator it runs in another thread issues its own. Default is None, which keeps them.- tolfloat, optional
The absolute tolerance of the search, in the ability scale. Default is 1e-6.
- Returns:
- AbilityEstimates
The estimates, their standard errors, the number of evaluations of each examinee’s likelihood or of its derivatives, each examinee’s warnings, and which rows the fallback gave.
- Raises:
- TypeError
If the responses are neither Booleans, integers nor floats.
- ValueError
If both
boundsandfallbackare given,boundsis not a finite interval,tolis not positive,itemsis not an(n, 4)matrix of finite numbers,responsesis not a matrix with one column per item, a response is not 0, 1 or NaN, or the fallback does not return one estimate and one entry ofwarningsper row it is given.
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]]) >>> responses = numpy.array([[1, 0, numpy.nan], [1, 1, 1]]) >>> maximum_likelihood(responses, items).theta.round(4) array([-0.6463, inf]) >>> maximum_likelihood(responses, items, bounds=(-4.0, 4.0)).theta.round(4) array([-0.6463, 4. ]) >>> estimates = maximum_likelihood(responses, items, fallback=expected_a_posteriori) >>> estimates.theta.round(4), estimates.from_fallback (array([-0.6463, 0.8555]), array([False, True]))