S-X²#

API:

irtlib.fit.s_x2(); irtlib.fit.ItemFit

Sources:

Orlando and Thissen [2000]

Motivation#

Orlando and Thissen’s S-X² tests, item by item, whether a calibrated model predicts the responses observed. It groups examinees by their number-correct score, which is observed, rather than by an ability estimate, whose groups depend on the model [Orlando and Thissen, 2000, p. 52], and it applies to every model from the 1PL to the 4PL. The Mean Squares compare each response with its expectation at the examinee’s ability instead.

Definition#

For item \(i\) of \(M\) and score \(k = 1, \dots, M - 1\), with \(N_k\) examinees at score \(k\) and \(O_{ik}\) the observed proportion of them answering item \(i\) correctly,

\[S\text{-}X^2_i = \sum_{k=1}^{M-1} N_k \frac{(O_{ik} - E_{ik})^2}{E_{ik}(1 - E_{ik})}\]

[Orlando and Thissen, 2000, p. 54, Equation 13]. The expected proportion is

\[E_{ik} = \frac{\sum_q P_i(X_q)\, S^{*i}_{k-1}(X_q)\, A_q}{\sum_q S_k(X_q)\, A_q}\]

(p. 54, Equation 12), where \(S_k(X_q)\) is the probability of a number correct of \(k\) at ability \(X_q\), which Item Response Functions defines, and \(S^{*i}_k\) the same without item \(i\) (p. 54). The statistic sums \((O - E)^2 / E\) over the cells of the table of scores by responses, and its degrees of freedom are the rows of the table less the number of parameters estimated for the item (p. 56).

Implementation#

The grid. The nodes and their normal masses \(A_q\) are the calibration’s grid, so S-X² takes a calibration by Marginal Maximum Likelihood (ADR-0006).

Collapsing the table. Orlando and Thissen collapse the rows from both ends toward the middle until every expected count is at least 1 [Orlando and Thissen, 2000, p. 56]. irtlib collapses the two cells of each score row, incorrect and correct: rows no examinee reached are dropped, a row with one examinee is merged into the next, the last into the one before, and while an expected count is below min_expected, the first such row is merged into its neighbour, the first row into the second, the last into the one before and any other into the neighbour with fewer examinees. The degrees of freedom are floored at 0. An item whose collapsed table leaves no degrees of freedom, including one collapsed to a single row, has none and no statistic.

Complete responses. S-X² “cannot handle incomplete data directly” [Zhang and Wang, 2022, p. 705], so it needs complete responses (ADR-0006).

The table. Besides each item’s statistic, the result holds the table Equation 13 sums over before any row is collapsed: the number of examinees \(N_k\) at each number correct \(k = 1, \dots, M - 1\), and each item’s observed and expected proportions correct, \(O_{ik}\) and \(E_{ik}\), at each.

Comparison with mirt
  • The collapsing is mirt 1.48’s (R/utils.R:2410-2546); the parity tests check the collapsed expected counts against mirt’s within a relative \(10^{-13}\).

  • At mirt’s estimates, the statistics and \(p\)-values agree with mirt’s within a relative \(10^{-10}\); on irtlib’s own calibration, within a relative \(10^{-4}\) (ADR-0003).

  • mirt skips an item whose table collapses to a single row; irtlib reports it with no degrees of freedom and no statistic.

  • The table before collapsing holds what mirt 1.48’s itemfit returns as O.org and E.org with return.tables = TRUE (manual p. 85; R/itemfit.R:861-863), as proportions correct with the group sizes rather than counts (R/utils.R:2392-2408; R/itemfit.R:836-837). S_X2.plot draws it (R/itemfit.R:838-859), against the number correct by the code’s default S_X2.plot_raw.score = TRUE (R/itemfit.R:265), or against each number correct’s EAP estimate with FALSE (R/itemfit.R:844-849), the default the manual states (p. 85).

  • The parity tests check the group sizes and observed proportions exactly, and the expected counts, \(N_k E_{ik}\), within a relative \(10^{-10}\). Their data leave no number correct without examinees, the smallest group holding 20, so only the unit tests cover an empty one.

Parameters#

Parameter

Default

Description

Default from

min_expected

1.0

The smallest expected count a cell of the collapsed table may hold.

Orlando and Thissen [2000, p. 56]

Guarantees#

  1. Every item of the calibration gets a statistic, the items its bank leaves out included, unless its collapsed table leaves no degrees of freedom.

  2. A missing response, or a calibration whose likelihood is not marginal, raises an error.

  3. The table holds every number correct from 1 to \(M - 1\), however the statistic collapses it; the observed proportion at a number correct no examinee has is NaN.

References#

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

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.

[ZW22]

Xue Zhang and Chun Wang. Modified item-fit indices for dichotomous IRT models with missing data. Applied Psychological Measurement, 46(8):705–719, 2022. Open copy: https://files.eric.ed.gov/fulltext/ED628568.pdf. doi:10.1177/01466216221125176.

API Reference#

irtlib.fit.s_x2(calibration: Calibration, responses: NDArray[floating[Any]], *, min_expected: float = 1.0) → ItemFit[source]#

Return the S-X² item-fit statistic of every item of a calibration, from the responses it was calibrated on.

Every item is evaluated at its estimates, including the items the calibration’s bank leaves out.

The S-X² page gives the method, its sources and the origin of each default.

Parameters:
calibrationCalibration

The calibration whose items are evaluated, of the marginal likelihood, whose grid the expected counts are integrated over.

responsesnumpy.ndarray

The complete response matrix the calibration estimated its items from: one row per examinee, one column per item, 1 or 0.

min_expectedfloat, optional

The smallest expected count a cell may keep after collapsing, at least 0. Default is 1. The expected counts are integrated over the calibration’s grid.

Returns:
ItemFit

Each item’s statistic, degrees of freedom and p-value, and the number of examinees in each score group with each item’s observed and expected proportions correct there.

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 of the calibration; min_expected is negative; or the calibration’s likelihood is not marginal, so that it has no grid.

class irtlib.fit.ItemFit(statistic: NDArray[floating[Any]], df: NDArray[integer[Any]], p_value: NDArray[floating[Any]], group_sizes: NDArray[integer[Any]], observed: NDArray[floating[Any]], expected: NDArray[floating[Any]])[source]#

S-X² of each item and the table it is computed from.

Each item has its statistic, degrees of freedom and p-value. The table groups the examinees by their number correct, from 1 to M - 1 for M items, before any score group is collapsed: column k - 1 of observed and expected is the score group of number correct k. Printed, it shows a table of each item’s statistic, degrees of freedom and p-value.

Parameters:
statisticnumpy.ndarray

S-X² of each item; NaN where no degrees of freedom are left after collapsing.

dfnumpy.ndarray

The degrees of freedom of each item’s statistic.

p_valuenumpy.ndarray

The probability of a statistic at least as large under the calibrated model; NaN where df is 0.

group_sizesnumpy.ndarray

The number of examinees in each score group, shape (M - 1,).

observednumpy.ndarray

The proportion of each score group answering each item correctly, shape (M, M - 1), one row per item; NaN in a score group no examinee is in.

expectednumpy.ndarray

The proportion the calibrated model expects to answer each item correctly in each score group, shape (M, M - 1), one row per item.