Why the Pearson Statistic Measures More Than Raw Differences
For grouped loss data or any other categorical observations, a goodness-of-fit analysis compares the number observed in each category with the number predicted by a model. A difference of 10 observations may be important when a model expects 20, but relatively modest when it expects 1,000. The Pearson chi-square statistic accounts for this scale by dividing each squared difference by its expected count before adding the contributions.
This tutorial focuses on calculating and interpreting that statistic. The categories must be mutually exclusive and collectively cover the observations, and the model must supply a probability for each category. The statistic is a summary of discrepancy; by itself, it is not a p-value or a conclusion about whether to reject a model.
Every term is nonnegative. A category contributes zero when its observed count equals its expected count; otherwise, its contribution grows with the squared discrepancy relative to the expected count. The total \(X^2\) combines these category-level contributions into one statistic.
Calculating Expected Counts and Contributions
The expected count is found from the model probability and the sample size, not by rounding the probability or comparing it directly with an observed count. For example, if a model assigns probability \(0.30\) to a category in a sample of 100, then that category’s expected count is \(100(0.30)=30\). Expected counts may be fractional; the arithmetic should use their unrounded values.
A reliable calculation has three stages: determine \(E_j\), compute \(O_j-E_j\) and square it, then divide by \(E_j\). Keep the category contributions visible until the final sum. This makes it easier to check the arithmetic and see which categories drive the statistic.
Worked Example: A Three-Category Portfolio Classification
A hypothetical insurer classifies 120 claims into three severity bands. A specified model assigns probabilities \(0.25\), \(0.50\), and \(0.25\) to the bands. The observed counts are 24, 66, and 30. Calculate the Pearson statistic, showing each contribution.
Method. Calculate expected counts from \(E_j=np_j\), then sum the category contributions. The common mistake to avoid is comparing observed counts with probabilities instead of expected counts.
The probabilities sum to \(0.25+0.50+0.25=1.00\), so the categories form a complete classification. The sample size is \(n=120\). Thus the expected counts are
For the first band, the difference is \(24-30=-6\). Its squared difference is \((-6)^2=36\), so its contribution is \(36/30=1.2\). For the second band, the difference is \(66-60=6\), giving contribution \(6^2/60=36/60=0.6\). For the third band, \(30-30=0\), so its contribution is \(0^2/30=0\).
Check. Observed counts sum to \(24+66+30=120\), and expected counts sum to \(30+60+30=120\). The deviations sum to \(-6+6+0=0\), as they must when both sets of counts total \(n\). The first band contributes twice as much as the second despite having the same absolute discrepancy, because its expected count is smaller.
Why the Denominator Is the Expected Count
The denominator scales a discrepancy according to the count level predicted by the model. A useful justification comes from comparing the Pearson statistic with the likelihood-ratio discrepancy for multinomial counts. This is a local approximation: it explains the form of the Pearson statistic when observed counts are not far from expected counts, rather than asserting that the two statistics are identical for every data set.
Write \(O_j=E_j+\delta_j\), where \(\delta_j\) is the discrepancy in category \(j\). Because the observed and expected totals both equal \(n\), the discrepancies sum to zero: \(\sum_j\delta_j=0\). The likelihood-ratio discrepancy has terms \(2O_j\log(O_j/E_j)\). For \(\delta_j/E_j\) close to zero, expand the logarithm using \(\log(1+x)\approx x-x^2/2\):
Summing across categories makes the linear terms cancel because \(\sum_j\delta_j=0\). The remaining second-order terms are \(\sum_j\delta_j^2/E_j\), which is precisely the Pearson statistic. This derivation explains why squared discrepancies are scaled by expected counts: it gives a standardized measure of departure, rather than a simple total of raw squared differences.
Worked Example: Grouped Loss Amounts Under a Specified Model
In a hypothetical study, 200 loss amounts are placed into four prespecified ranges. A model assigns probabilities \(0.40\), \(0.30\), \(0.20\), and \(0.10\), respectively. The observed counts are 72, 66, 38, and 24. Calculate the statistic and identify the largest category contribution.
Method. Use the model probabilities to obtain expected counts, then calculate each squared discrepancy divided by its expected count. The common mistake to avoid is reporting only the overall count differences and overlooking their different scales.
The probabilities sum to \(1.00\). With \(n=200\), the expected counts are
The category calculations are:
- Range 1: \(O_1-E_1=72-80=-8\), so the contribution is \((-8)^2/80=64/80=0.8\).
- Range 2: \(O_2-E_2=66-60=6\), so the contribution is \(6^2/60=36/60=0.6\).
- Range 3: \(O_3-E_3=38-40=-2\), so the contribution is \((-2)^2/40=4/40=0.1\).
- Range 4: \(O_4-E_4=24-20=4\), so the contribution is \(4^2/20=16/20=0.8\).
The largest contribution is \(0.8\), shared by ranges 1 and 4. Their raw discrepancies differ in size: 8 for range 1 and 4 for range 4. The smaller discrepancy in range 4 has the same contribution because its expected count is also smaller. The check is that both sets of counts sum to 200: \(72+66+38+24=200\) and \(80+60+40+20=200\).
Reading the Contribution Pattern
The statistic’s total can hide useful detail, so inspect the individual contributions as well. A large contribution means that a category has a notable discrepancy relative to its expected count. Its sign is not retained in the contribution: squaring makes an excess and a shortfall of the same size contribute equally. To describe direction, retain the signed difference \(O_j-E_j\) alongside the contribution.
The following example shows how a relatively large contribution can arise from a moderate raw discrepancy when the expected count is comparatively small. It also illustrates why the statistic is not just a count of how many categories differ from expectation.
Worked Example: Locating the Main Source of Discrepancy
A hypothetical system allocates 160 service requests among four types. Under a specified model, their probabilities are \(0.50\), \(0.25\), \(0.15\), and \(0.10\). The observed counts are 88, 32, 30, and 10. Calculate each contribution and the total, then state which category contributes most.
Method. Compute \(E_j=160p_j\) for each type, and then apply the Pearson contribution formula. The common mistake to avoid is deciding which category matters most from the raw difference alone.
Expected counts are \(160(0.50)=80\), \(160(0.25)=40\), \(160(0.15)=24\), and \(160(0.10)=16\). The contributions are as follows:
- Type 1: \(88-80=8\), so \(8^2/80=64/80=0.8\).
- Type 2: \(32-40=-8\), so \((-8)^2/40=64/40=1.6\).
- Type 3: \(30-24=6\), so \(6^2/24=36/24=1.5\).
- Type 4: \(10-16=-6\), so \((-6)^2/16=36/16=2.25\).
Type 4 contributes most, at \(2.25\). Its raw shortfall of 6 is smaller than the absolute discrepancy of 8 in types 1 and 2, but the expected count of 16 is much lower than 80 or 40. The count checks are \(88+32+30+10=160\) observed and \(80+40+24+16=160\) expected. The signed differences, \(8,-8,6,-6\), sum to zero.
Common Calculation Traps and Scope
A Pearson statistic is only as correctly calculated as its inputs and arithmetic. Before interpreting the total, confirm that the probabilities correspond to the stated categories and sum to one, and that each expected count uses the same sample size. Keep sufficient precision during intermediate calculations, especially when expected counts are not integers.
- Using raw differences as the statistic. Adding \(O_j-E_j\) is not useful here: the signed differences sum to zero. The formula squares each difference and divides by its expected count.
- Using an unweighted sum of squares. The quantity \(\sum_j(O_j-E_j)^2\) omits the scaling by \(E_j\) and is not the Pearson statistic.
- Using \(p_j\) in the denominator. The denominator is \(E_j=np_j\), a count, not the category probability.
- Dropping the sign too soon. The contribution uses a squared difference, but the sign of \(O_j-E_j\) is needed to distinguish an excess from a shortfall.
- Treating the total as a decision by itself. A value of \(X^2\) summarizes discrepancy; a test decision also requires an appropriate reference distribution and calibration.
When model parameters have been estimated from data, the category probabilities used in the calculation may depend on those estimates. The arithmetic definition of \(X^2\) remains the same, but its reference distribution and calibration require additional consideration. Likewise, the statistic alone does not determine whether a particular grouping or expected-count pattern is suitable for inference.
Check Your Understanding
For each problem, calculate the expected counts first, then use the category contributions to obtain the Pearson statistic.
- A hypothetical sample of 90 policies is divided among three contract types. A specified model gives probabilities \(0.20\), \(0.50\), and \(0.30\), and observed counts are 12, 48, and 30. Find the statistic. (Answer: \(X^2=2.5333\))
- A sample of 150 laboratory measurements is grouped into three ranges with model probabilities \(0.40\), \(0.40\), and \(0.20\). Observed counts are 70, 58, and 22. Find each contribution and the total. (Answer: contributions \(1.6667,\ 0.0667,\ 2.1333\); \(X^2=3.8667\))
- For 240 hypothetical repair costs, a model assigns probabilities \(0.50\), \(0.25\), \(0.15\), and \(0.10\) to four bands. Observed counts are 108, 72, 36, and 24. Calculate \(X^2\). (Answer: \(X^2=3.6000\))
- A hypothetical survey of 100 members has four response categories with model probabilities \(0.30\), \(0.30\), \(0.25\), and \(0.15\). The observed counts are 25, 35, 20, and 20. Find the statistic and the largest contribution. (Answer: contributions \(0.8333,\ 0.8333,\ 1.0000,\ 1.6667\); \(X^2=4.3333\), largest contribution \(1.6667\))
- In a sample of 180 claims, model probabilities for three classes are \(0.50\), \(0.30\), and \(0.20\); observed counts are 96, 45, and 39. A candidate reports the unweighted sum of squared differences, \(126\). Calculate the Pearson statistic and explain the correction. (Answer: expected counts \(90,54,36\); contributions \(0.4000,\ 1.5000,\ 0.2500\); \(X^2=2.1500\). The unweighted sum omits division by expected counts.)