Maximum A Posteriori#

API:

irtlib.ability.maximum_a_posteriori()

Sources:

Samejima [1969]; Magis and Raîche [2012]; Warm [1989]; Bock and Mislevy [1982]; Bock and Aitkin [1981]

Motivation#

The maximum a posteriori (MAP), or Bayes modal, estimate is the most likely ability given the responses and a prior density of ability: the mode of the posterior. Under a normal prior the posterior of responses all correct or all incorrect has a finite mode, and the standard error adds the prior’s precision to the test information. Expected A Posteriori takes the posterior’s mean instead of its mode, and Maximum Likelihood uses no prior.

Samejima [1969, p. 7, Equations 2-5 and 2-6] defines the Bayes modal estimator, the ability that maximizes the prior density times the likelihood; Bock and Mislevy [1982, p. 432] credit Bock and Aitkin [1981] with the name MAP, and Magis and Raîche [2012, p. 4] attribute the estimator to Birnbaum (1969).

Definition#

The MAP estimate maximizes the posterior, \(\log \pi(\theta) + \log L_j(\theta)\) for a prior density \(\pi\) [Magis and Raîche, 2012, p. 5, Equation 5]; [Warm, 1989, p. 430]. For a normal prior of variance \(\sigma^2\) its standard error is \(1 / \sqrt{1 / \sigma^2 + I(\hat\theta)}\) [Magis and Raîche, 2012, p. 5, Equation 6].

Against the maximum likelihood and EAP estimates. When every answered item has \(c_i = 0\) and \(d_i = 1\) the observed information is \(I\) [Warm, 1989, p. 449], so the log-likelihood’s second derivative is \(-I < 0\) and the log-likelihood is concave. Under a normal prior the log-posterior is then concave too, and its derivative is the prior’s term alone at the maximum likelihood estimate, pointing toward the prior mean, and the likelihood’s term alone at the prior mean, pointing toward that estimate: the single mode lies between the two. Under a uniform prior on an interval wide enough, the MAP and maximum likelihood estimates are equivalent [Magis and Raîche, 2012, p. 5]. As items accumulate, the posterior approaches normality [Bock and Mislevy, 1982, p. 434], and its mode, the MAP estimate, and its mean, the Expected A Posteriori estimate, draw together.

Implementation#

The standard error. For any prior, irtlib takes \(1 / \sqrt{I(\hat\theta) - (\log\pi)''(\hat\theta)}\), with the prior’s second derivative a central difference of step \(10^{-4}\): Equation 6 for a normal prior, and for a uniform one, inside its support, the maximum likelihood standard error. Where the difference is not finite, at the edge of a bounded prior’s support, the prior adds nothing; where the sum is not positive, the standard error is \(\infty\). The general form has no published source; the sources wanted list it.

The search. It evaluates the log-posterior at equally spaced abilities within the bounds: under a normal prior, as many as the Maximum Likelihood search for the same items, and under any other prior 201, 0.06 apart on \([-6, 6]\). Three or more tied at the maximum make a flat posterior, and the estimate is the middle one; otherwise the best is refined between its neighbours, and the refinement is kept only if no worse, so the estimate stays inside the prior’s support and is the highest of the modes the points separate. With a normal prior \(N(\mu, \sigma^2)\) the refinement is the maximum likelihood search’s Newton’s method, with \(-(\theta - \mu) / \sigma^2\) and \(-1 / \sigma^2\) added to the derivatives, and on items that all have \(c_i = 0\) and \(d_i = 1\) the log-posterior is concave too, and the search skips the points as the maximum likelihood search does. With any other prior the refinement is SciPy’s bounded search, scipy.optimize.minimize_scalar. An examinee who answered no item gets the prior’s mode.

The points come first for two reasons. A prior that is zero on part of the bounds, such as a uniform prior on \([-1, 1]\) searched over \([-6, 6]\), makes the log-posterior \(-\infty\) there, a flat region that a bounded scalar search cannot cross; and a posterior with several modes, from a prior with several or from a 3PL likelihood, has local modes where a local search can stop. The prior’s support must hold at least one of the points, which any interval wider than their spacing does.

The observed information. When every answered item has \(c_i = 0\) and \(d_i = 1\), the observed information is \(I\) exactly [Warm, 1989, p. 449], whose model fixes \(d_i = 1\) [Warm, 1989, p. 428, Equation 1].

Comparison with mirt and catR
  • mirt 1.48 maximizes the same posterior with nlm and takes the standard error from nlm’s numerical Hessian (R/fscores.internal.R:684-703, 1047-1070): the observed information plus the prior’s precision. When every answered item has \(c_i = 0\) and \(d_i = 1\), the two standard errors agree.

  • catR 3.17 computes the same standard errors, Equation 6 for a normal prior and the maximum likelihood one inside a uniform prior’s support (R/semTheta.R:43-50, 82-89).

Parameters#

Parameter

Default

Description

Default from

log_prior

the standard normal

The prior’s log-density, such as normal_log_prior() or uniform_log_prior().

abilities \(N(0, 1)\) (ADR-0008)

bounds

(-6.0, 6.0)

The interval the estimate maximizes the posterior within.

catsim’s (ADR-0010)

tol

1e-6

The search’s tolerance in ability.

catsim’s (ADR-0010)

Guarantees#

  1. Every estimate lies within the bounds, whatever the responses.

  2. An examinee who answered no item gets the prior’s mode.

  3. Where the posterior has several modes, the estimate is the highest the search’s points separate.

  4. A standard error that the prior and the information leave undefined is \(\infty\).

References#

[BA81] (1,2)

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.

[BM82] (1,2,3)

R. Darrell Bock and Robert J. Mislevy. Adaptive EAP estimation of ability in a microcomputer environment. Applied Psychological Measurement, 6(4):431–444, 1982. Open copy: http://purl.umn.edu/93227. doi:10.1177/014662168200600405.

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

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.

[Sam69] (1,2)

Fumiko Samejima. Estimation of latent ability using a response pattern of graded scores. Psychometrika, 34(S1):1–97, 1969. Psychometrika Monograph Supplement No. 17. Open copy: https://psychometricsociety.org/sites/main/files/file-attachments/mn17.pdf. doi:10.1007/BF03372160.

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

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_a_posteriori(responses: ArrayLike, items: NDArray[floating[Any]], *, log_prior: LogPrior | None = None, bounds: tuple[float, float] = (-6.0, 6.0), tol: float = 1e-06) → AbilityEstimates[source]#

Return each examinee’s MAP estimate, the mode of its posterior within the bounds, with its standard error.

The estimate is the highest mode the search finds, inside the prior’s support, and finite whatever the responses; an examinee who answered no item gets the prior’s mode. The evaluation count is the number of evaluations of the posterior or of its derivatives.

The Maximum A Posteriori 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.

log_priorLogPrior or None, optional

The prior’s log-density. Default is normal_log_prior(), the standard normal.

boundstuple[float, float], optional

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

tolfloat, optional

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

Returns:
AbilityEstimates

The modes, their standard errors, inf where the information and the prior’s curvature give none, and the evaluation counts.

Raises:
TypeError

If the responses are neither Booleans, integers nor floats.

ValueError

If tol is not positive, bounds is not a finite interval, items is not an (n, 4) matrix of finite numbers, responses is not a matrix with one column per item, a response is not 0, 1 or NaN, or the log-posterior is not finite at any search point.

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 = maximum_a_posteriori(numpy.array([[1, 0, numpy.nan], [1, 1, 1]]), items)
>>> estimates.theta.round(4), estimates.standard_errors.round(4)
(array([-0.2728,  0.823 ]), array([0.8029, 0.8002]))