Model Comparison#
Motivation#
A model with more parameters always fits at least as well; the question is whether the improvement outweighs the parameters spent. The likelihood-ratio test compares two nested models, such as the 2PL and the 3PL calibrated on the same responses; the information criteria rank any models calibrated on them; and \(G^2\) tests one model against every pattern of responses. BIC selects the true model as the sample grows, when it is among the candidates, and AIC does not; AIC is efficient when no candidate is true [Vrieze, 2012, Pages 10-11].
Definition#
For \(k\) estimated parameters and the maximized log-likelihood \(\log L\):
the likelihood-ratio statistic of nested models is \(-2\) times the difference of their log-likelihoods, “distributed as \(\chi^2\)” with the difference in their numbers of parameters as its degrees of freedom [Orlando and Thissen, 2000, p. 51];
AIC is \(-2\log L + 2k\) [Akaike, 1974, p. 719];
BIC is \(-2\log L + k\log N\) for \(N\) examinees, Schwarz’s criterion [Schwarz, 1978, p. 461] multiplied by \(-2\), with the sample size Vrieze [2012, Page 10] uses;
\(G^2\) compares the model with the general multinomial over response patterns, \(2\sum_x r_x \log(r_x / (N \tilde P_x))\) over the observed patterns \(x\), observed \(r_x\) times with marginal probability \(\tilde P_x\) [Bock and Aitkin, 1981, p. 450].
Implementation#
\(G^2\)’s degrees of freedom are \(2^M - 1 - k\) for \(M\) items, as in the values Bock and Aitkin [1981, p. 455, Table 3] and Thissen [1982, p. 178] report, whatever the patterns observed; Bock and Aitkin’s Equation 16 (p. 450) counts the observed patterns instead. The multinomial is not defined when responses are missing, so \(G^2\) needs complete responses.
The log-likelihoods. With priors, the log-likelihood is the one at the Bayes modal estimates, without the log-prior. Every statistic here takes marginal log-likelihoods, and refuses a calibration of another likelihood, such as the conditional one of Conditional Maximum Likelihood, which is not on their scale (ADR-0006).
Comparison with mirt
mirt 1.48 counts \(G^2\)’s degrees of freedom as \(2^M - 1 - k\) too.
On calibrations of the same responses, the parity tests find the numbers of parameters equal to mirt’s, the log-likelihoods, AIC and BIC within a relative \(10^{-10}\), \(G^2\) and the likelihood-ratio statistic within \(10^{-6}\), and their degrees of freedom equal (ADR-0003).
Parameters#
The functions take calibrations; bic() also takes the number of examinees,
and g2() the responses. None has a setting.
Guarantees#
A calibration whose likelihood is not marginal raises an error.
The likelihood-ratio test raises an error unless the general model has more parameters than the restricted one, on the same items.
\(G^2\) of responses with a missing entry raises an error.
References#
Hirotugu Akaike. A new look at the statistical model identification. IEEE Transactions on Automatic Control, 19(6):716–723, 1974. Not openly available; Vrieze (2012) describes the criterion. doi:10.1109/TAC.1974.1100705.
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.
Maria Orlando and David Thissen. Likelihood-based item-fit indices for dichotomous item response theory models. Applied Psychological Measurement, 24(1):50–64, 2000. Not openly available; Kang and Chen (2007) describe the method. doi:10.1177/01466216000241003.
Gideon Schwarz. Estimating the dimension of a model. The Annals of Statistics, 6(2):461–464, 1978. Open copy: https://projecteuclid.org/journals/annals-of-statistics/volume-6/issue-2/Estimating-the-Dimension-of-a-Model/10.1214/aos/1176344136.pdf. doi:10.1214/aos/1176344136.
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.
Scott I. Vrieze. Model selection and psychological theory: a discussion of the differences between the Akaike information criterion (AIC) and the Bayesian information criterion (BIC). Psychological Methods, 17(2):228–243, 2012. Open copy (author manuscript): https://pmc.ncbi.nlm.nih.gov/articles/PMC3366160/. doi:10.1037/a0027127.
API Reference#
Comparison of calibrated models: the likelihood-ratio test, AIC, BIC and G².
- class irtlib.comparison.ChiSquareTest(statistic: float, df: int, p_value: float)[source]#
A statistic referred to a chi-square distribution.
- Parameters:
- statisticfloat
The statistic.
- dfint
Its degrees of freedom.
- p_valuefloat
The probability of a statistic at least as large under the null model.
- irtlib.comparison.aic(calibration: Calibration) float[source]#
Return the Akaike information criterion of a calibration; smaller is better.
- Parameters:
- calibrationCalibration
A calibration of the marginal likelihood; one with priors is judged by its log-likelihood without the log-prior.
- Returns:
- float
-2 * log_likelihood + 2 * n_parameters.
- Raises:
- ValueError
If the calibration’s likelihood is not marginal.
- irtlib.comparison.bic(calibration: Calibration, n_examinees: int) float[source]#
Return the Bayesian information criterion of a calibration; smaller is better.
- Parameters:
- calibrationCalibration
A calibration of the marginal likelihood; one with priors is judged by its log-likelihood without the log-prior.
- n_examineesint
The number of examinees the calibration estimated its items from.
- Returns:
- float
-2 * log_likelihood + n_parameters * log(n_examinees).
- Raises:
- ValueError
If
n_examineesis less than 1, or the calibration’s likelihood is not marginal.
- irtlib.comparison.g2(calibration: Calibration, responses: NDArray[floating[Any]]) ChiSquareTest[source]#
Return the \(G^2\) statistic of a calibration against the general multinomial over response patterns.
The patterns’ probabilities are those of every item at its estimates, including the items the calibration’s bank leaves out.
- Parameters:
- calibrationCalibration
The calibration to evaluate, of the marginal likelihood.
- responsesnumpy.ndarray
The complete response matrix the calibration estimated its items from: one row per examinee, one column per item, 1 or 0.
- Returns:
- ChiSquareTest
\(G^2\), on the number of possible response patterns less one, less the number of estimated parameters.
- Raises:
- TypeError
If the responses are neither Booleans, integers nor floats.
- ValueError
If the responses fail
irtlib.calibration.validate_responses(), have a missing response, or do not have one column per item; the model leaves no degrees of freedom; or the calibration’s likelihood is not marginal.
- irtlib.comparison.likelihood_ratio(restricted: Calibration, general: Calibration) ChiSquareTest[source]#
Return the likelihood-ratio test of a restricted model against a more general one it is nested in.
The two must be calibrations of the same responses, the restricted model a special case of the general one, such as the 1PL of the 2PL; only the numbers of items and parameters can be checked. The test of a parameter on the boundary of its range, such as the 3PL’s guessing parameter at 0 against the 2PL, is the ordinary one, whose p-value is then conservative. Calibrations with priors are compared by their log-likelihoods without the log-prior, and a restricted model that fits better, as when a calibration stopped short, gives a negative statistic and a p-value of 1.
- Parameters:
- restrictedCalibration
The calibration of the restricted model, of the marginal likelihood.
- generalCalibration
The calibration of the general model, of the marginal likelihood.
- Returns:
- ChiSquareTest
Twice the gain in log-likelihood, on the difference in the numbers of parameters.
- Raises:
- ValueError
If the two calibrations have different numbers of items, the general model does not have more parameters, or a calibration’s likelihood is not marginal.