Calibration Results – irtlib.calibration#
The response matrix and the result that every calibrator shares (ADR-0006).
A response matrix has one row per examinee and one column per item, and holds 1 for a correct response, 0 for an
incorrect one and NaN where the examinee did not answer the item. Conditional and joint maximum likelihood share the
leaving out of the examinees and items that have no finite estimate, documented with irtlib.cml and
irtlib.jml.
- class irtlib.calibration.Calibration(estimates: NDArray[floating[Any]], items: ItemBank | None, covariances: NDArray[floating[Any]] | None, log_likelihood: float, log_likelihoods: NDArray[floating[Any]], likelihood: Likelihood, n_parameters: int, item_parameters: NDArray[integer[Any]], converged: bool, change: float, grid: QuadratureGrid | None, abilities: AbilityEstimates | None)[source]#
The result of a calibration, by any method.
Printed, it shows its attributes and a table of each item’s estimates and standard errors, by row and name, and names the arrays it leaves out with their shapes.
- Parameters:
- estimatesnumpy.ndarray
The estimates
[a, b, c, d]of every item, one row per column of the response matrix, whether or not they are valid for an item bank; NaN for a parameter of an item the method gives no estimate.- itemsirtlib.ItemBank or None
The items whose estimates are valid in an item bank, every parameter finite with
a > 0and0 <= c < d <= 1, each nameditem_and its column, as in a bank of every item; None if no item’s estimates are. The calibrator warns with aRuntimeWarningnaming the items it leaves out, such as a miskeyed item, whose slope is not positive.- covariancesnumpy.ndarray or None
The covariance of each item’s estimates, one 4 x 4 matrix per row of
estimates, its rows and columns in the ordera, b, c, d, NaN in those of a parameter not estimated, and symmetric. A parameter shared by every item, such as the 1PL’s slope, appears in each item’s matrix, with its variance and its covariances with that item’s estimates. Only the variances are checked, so a matrix may not be positive definite. None, with a warning, when the information matrix could not be inverted or gives a variance that is not finite and positive.- log_likelihoodfloat
The logarithm of the likelihood named by
likelihood, at the estimates, before any correction the method makes to them once the likelihood is maximized; with priors, without the log-prior.- log_likelihoodsnumpy.ndarray
The same logarithm after each cycle of the calibration’s algorithm, such as an EM cycle, a Newton-Raphson iteration, or an item and an ability step of joint maximum likelihood, the extrapolations of an acceleration left out; empty if the calibration stopped before its first cycle. For a method that maximizes the likelihood, the last is
log_likelihood. Markov chain Monte Carlo records it after each iteration of its chains, at the mean of the items they drew in it, so its last differs fromlog_likelihood, at the posterior means. With priors, without the log-prior.- likelihoodLikelihood
The likelihood the calibration maximizes, or, for Markov chain Monte Carlo, in whose posterior it draws the items, given as a member or its name. Model comparison and S-X² take only marginal ones.
- n_parametersint
The number of free parameters estimated: a parameter shared by every item counted once, and for the joint likelihood the ability of every examinee kept, less one for each constraint that fixes the scale.
- item_parametersnumpy.ndarray
The number of parameters estimated for each item, a parameter shared by every item counted for each.
- convergedbool
Whether the stopping rule was met; if not, the calibration ran out of cycles or could not go on, and warned with
ConvergenceWarning. For Markov chain Monte Carlo, whether its chains agree.- changefloat
The stopping rule’s final value: the largest change of an estimated item parameter in the last cycle; for Newton-Raphson, in the cycle’s full step, before any halving; for Markov chain Monte Carlo, the largest potential scale reduction.
- gridirtlib.quadrature.QuadratureGrid or None
The nodes abilities were integrated over, which item fit uses too: set when the likelihood is marginal, and None otherwise, since no other likelihood integrates over abilities.
- abilitiesirtlib.ability.AbilityEstimates or None
The abilities estimated with the items, one per row of the response matrix, at the estimates before any correction: set when the likelihood is joint, and None otherwise, since no other likelihood estimates them.
- Raises:
- ValueError
If
likelihoodnames noLikelihood;gridis set for a likelihood that is not marginal, or missing for a marginal one; orabilitiesis set for a likelihood that is not joint, or missing for a joint one.
- exception irtlib.calibration.ConvergenceWarning[source]#
A calibration ran out of cycles before its stopping rule was met, or its chains did not agree.
- class irtlib.calibration.Likelihood(*values)[source]#
The likelihood a calibration maximizes, whose logarithm at the estimates it reports.
MARGINALis the likelihood of the item parameters with abilities integrated out over a grid, which marginal maximum likelihood maximizes, and in whose posterior Markov chain Monte Carlo draws the items;CONDITIONALthe likelihood of the responses given each examinee’s number correct, which conditional maximum likelihood maximizes;JOINTthe likelihood of the responses given every examinee’s ability, which joint maximum likelihood maximizes over the abilities and the item parameters together. A member equals its name in lower case.Examples
>>> Likelihood("conditional") is Likelihood.CONDITIONAL True
- irtlib.calibration.default_grid() QuadratureGrid[source]#
Return the grid abilities are integrated over by default (ADR-0007).
- Returns:
- irtlib.quadrature.QuadratureGrid
61 equally spaced nodes on [-6, 6], with equal weights.
Examples
>>> grid = default_grid() >>> grid.nodes.size, float(grid.nodes[0]), float(grid.nodes[-1]) (61, -6.0, 6.0)
- irtlib.calibration.validate_responses(responses: ArrayLike) NDArray[floating[Any]][source]#
Return a response matrix as a new float array, after checking its type, its shape, its values and its items.
The matrix must have at least one examinee and one item, and every item must be answered by some examinee; an examinee who answered no item is accepted. Booleans and integers are read as 1 and 0.
- Parameters:
- responsesarray_like
The response matrix: one row per examinee, one column per item, holding 1, 0 or NaN.
- Returns:
- numpy.ndarray
A float copy of the responses, of the same shape.
- Raises:
- TypeError
If the responses are neither Booleans, integers nor floats.
- ValueError
If the matrix is not two-dimensional or is empty, holds a value other than 0, 1 and NaN, or has an item no examinee answered.
Examples
>>> import numpy >>> validate_responses(numpy.array([[1, 0], [numpy.nan, 1]])) array([[ 1., 0.], [nan, 1.]])