χ²α O O E E χ²

χ²-Tests

Goodness-of-fit tests and contingency table tests — using observed vs expected frequencies to test distributional assumptions and association between variables.

χ² Goodness of Fit 📊 Contingency Tables 🔗 Test of Association 📐 Degrees of Freedom ★ Cambridge 9231 Lesson 4.3 of 5
4.3 χ²-Tests

The χ²-Statistic

The chi-squared test compares observed frequencies (O) from data with expected frequencies (E) derived from a theoretical model or assumption. The test statistic measures how far the observed data deviate from what is expected.

Chi-Squared Test Statistic χ² = Σ (O − E)² / E Summed over all cells/categories. Under H₀, this follows a χ² distribution with ν degrees of freedom. Larger χ² means greater discrepancy between observed and expected.

The χ²-Distribution

The chi-squared distribution with ν degrees of freedom is right-skewed (unlike the symmetric normal). Its shape depends entirely on ν:

Always Right-Skewed
χ² ≥ 0 always. The distribution is right-skewed, becoming more symmetric as ν increases. Critical region is always in the right tail.
Mean = ν
E(χ²) = ν and Var(χ²) = 2ν. As ν → ∞, χ²(ν) → N(ν, 2ν) approximately.
Critical Region
Always right-tailed — a large χ² value indicates poor fit (big O−E differences). Use MF19 Table 7 to find χ²_α,ν.

Two Types of χ²-Test in Cambridge 9231

Test TypeH₀H₁Degrees of Freedom
Goodness of Fit Data follows the specified distribution Data does not follow the specified distribution k − 1 − p (where p = parameters estimated)
Contingency Table
(Test of Association)
Row and column variables are independent Row and column variables are associated (r−1)(c−1)
⛔ The 5-Rule — Expected Frequencies

The χ² approximation is only valid when all expected frequencies are at least 5. If any E < 5, you must combine adjacent categories (merge cells) until all E ≥ 5. Never combine observed frequencies — always merge based on the expected values. Combining reduces the number of categories and therefore the degrees of freedom.

Common Critical Values (from MF19)

νχ² at 10%χ² at 5%χ² at 2.5%χ² at 1%
12.7063.8415.0246.635
24.6055.9917.3789.210
36.2517.8159.34811.345
47.7799.48811.14313.277
59.23611.07012.83315.086
610.64512.59214.44916.812
813.36215.50717.53520.090
1015.98718.30720.48323.209

Goodness of Fit Tests

A goodness-of-fit (GOF) test assesses whether sample data is consistent with a specified theoretical distribution — uniform, Poisson, binomial, normal, or a custom probability model.

Six-Step Procedure — Goodness of Fit Test
1Hypotheses
H₀: The data follow [distribution name] with [parameters].
H₁: The data do not follow [distribution name].
Be specific — name the distribution and any known parameters.
2Expected frequencies E
Calculate E = n × P(category) for each cell.
If parameters are estimated from data (e.g. λ̂ = x̄ for Poisson), count each estimated parameter — it costs one degree of freedom.
3Merge cells (if needed)
Check all E ≥ 5. If any E < 5, merge with an adjacent category.
Merge both O and E for the combined cell. Record new degrees of freedom after merging.
4Test statistic χ²
χ² = Σ (O − E)² / E
Compute each term (O−E)²/E and sum. Show the working in a table — Cambridge requires this.
5Degrees of freedom
ν = k − 1 − p
k = number of categories after merging, p = number of parameters estimated from data.
Always −1 for the constraint Σ E = n.
6Decision & conclusion
Compare χ² with critical value from MF19 at significance level α.
χ² < χ²_α → fail to reject H₀ — data consistent with model.
χ² ≥ χ²_α → reject H₀ — data not consistent with model.
Write conclusion in context.

Common GOF Distributions — Degrees of Freedom Summary

Uniform / Given probabilities
ν = k − 1
No parameters estimated from data. k = number of categories after merging.
Poisson (λ estimated from x̄)
ν = k − 2
One parameter λ estimated ⟹ p=1, so subtract 1 extra.
Binomial (p estimated)
ν = k − 2
One parameter p estimated from data. If n also estimated: ν = k−3.
Normal (μ and σ² estimated)
ν = k − 3
Two parameters estimated (μ̂ = x̄, σ̂² = s²) ⟹ p=2.
E
GOF Test — Poisson Distribution
The number of faults per metre of wire is recorded for 200 metres:
Faults: 0, 1, 2, 3, 4+
Frequency: 72, 88, 28, 8, 4
Test at 5% whether a Poisson distribution is a good fit.
Estimate λ
x̄ = (0×72+1×88+2×28+3×8+4×4)/200 = (0+88+56+24+16)/200 = 184/200 = 0.92
λ̂ = 0.92 (estimated from data — costs 1 d.f.)
Expected frequencies
E(X=0) = 200×e⁻⁰·⁹² = 200×0.3985 = 79.70
E(X=1) = 200×0.92×e⁻⁰·⁹² = 200×0.3666 = 73.32
E(X=2) = 200×0.92²/2×e⁻⁰·⁹² = 200×0.1686 = 33.72
E(X=3) = 200×0.92³/6×e⁻⁰·⁹² = 200×0.0517 = 10.35
E(X≥4) = 200−79.70−73.32−33.72−10.35 = 2.91
Merge cells
E(X=3) = 10.35 ≥ 5 ✓   E(X≥4) = 2.91 < 5 ✗ → merge X=3 and X≥4
Combined: O = 8+4=12, E = 10.35+2.91 = 13.26
χ² calculation
(72−79.70)²/79.70 = 0.745
(88−73.32)²/73.32 = 2.942
(28−33.72)²/33.72 = 0.971
(12−13.26)²/13.26 = 0.120
χ² = 4.778
Degrees of freedom
k = 4 categories after merging, p = 1 (λ estimated)
ν = 4 − 1 − 1 = 2
Decision
Critical value: χ²_{0.05, 2} = 5.991
4.778 < 5.991 → Fail to reject H₀
The data are consistent with a Poisson distribution with λ = 0.92 at the 5% level.

Contingency Tables

A contingency table records counts for combinations of two categorical variables. The χ²-test of association tests whether the two variables are independent.

Hypotheses for Contingency Table Test H₀: The two variables are independent (no association) H₁: The two variables are associated Never say "correlated" for categorical variables — use "associated" or "not independent."

Expected Frequencies — The Key Formula

Expected frequency for cell (i, j) E_{ij} = (Row i total × Column j total) / Grand total This formula assumes independence — under H₀, the joint probability is the product of the marginal probabilities. Cambridge always asks you to calculate at least one expected frequency to show working.

Example — 2×3 Contingency Table

Category A Category B Category C Row Total
Group 1 30
(E=28.8)
45
(E=43.2)
15
(E=18.0)
90
Group 2 18
(E=19.2)
27
(E=28.8)
15
(E=12.0)
60
Column Total 48 72 30 150

E for cell (Group 1, Category A) = 90×48/150 = 28.8. All expected values ≥ 5 ✓ No merging needed.

Degrees of freedom — contingency table ν = (r − 1)(c − 1) r = number of rows, c = number of columns. For a 2×3 table: ν = (2−1)(3−1) = 2. No parameters are estimated from the data, so no additional subtraction.

Yates' Continuity Correction — 2×2 Tables

⚠️ Yates' Correction — Only for 2×2 Tables For a 2×2 contingency table, the χ² approximation can be improved by applying Yates' correction:

χ²_Yates = Σ (|O − E| − 0.5)² / E

Cambridge 9231 may or may not require Yates' correction — the question will specify "with" or "without Yates' correction." If not specified for a 2×2 table, apply it. For tables larger than 2×2, never apply it.
E
2×2 Contingency Table with Yates' Correction
A study examines whether gender is associated with subject preference:
ScienceArtsTotal
Male452570
Female304070
Total7565140
Test at 5% whether gender and subject preference are associated (use Yates' correction).
H₀, H₁
H₀: Gender and subject preference are independent.   H₁: They are associated.
Expected values
E(M,Sci) = 70×75/140 = 37.5   E(M,Arts) = 70×65/140 = 32.5
E(F,Sci) = 70×75/140 = 37.5   E(F,Arts) = 70×65/140 = 32.5
All E ≥ 5 ✓
χ² with Yates'
Each cell |O−E| = |45−37.5| = 7.5, then |O−E|−0.5 = 7.0
χ² = 4×(7.0²/37.5) = 4×1.307 = 5.227
Degrees of freedom
ν = (2−1)(2−1) = 1.   Critical value: χ²_{0.05,1} = 3.841
Decision
5.227 > 3.841 → Reject H₀
Significant evidence at 5% that gender and subject preference are associated.

Degrees of Freedom

Getting the degrees of freedom correct is one of the most frequently examined points in χ² questions. The formula depends on the test type and what parameters were estimated.

The General Formula

Goodness-of-fit ν ν = k − 1 − p k = number of categories AFTER merging. p = number of parameters estimated from the data. The −1 accounts for the constraint that Σ E = n (total must be fixed).
Contingency table ν ν = (r − 1)(c − 1) r = rows, c = columns. No parameter estimation penalty because expected frequencies use marginal totals from the observed data.

Parameter Counting — What Reduces ν?

SituationParameters estimated (p)Extra d.f. lost
Uniform distribution (given probabilities)0None
Poisson with λ given0None
Poisson with λ estimated from x̄1−1
Binomial with p given, n known0None
Binomial with p estimated from data1−1
Normal with μ, σ² given0None
Normal with μ estimated (= x̄)1−1
Normal with μ and σ² both estimated2−2
💡 Why Estimating Parameters Costs Degrees of Freedom

When you estimate a parameter from the data (e.g. λ̂ = x̄), you are using the data to fit the model. This forces one additional constraint on the expected frequencies, reducing the number of "free" cells by one. It is the same principle as losing one d.f. when estimating σ² in the t-test.

Decision Flow — Which Test, Which ν?

ν Quick Reference
GOF
Uniform/Given
ν = k − 1
Probabilities all specified. No estimation.
GOF
Poisson (λ̂)
ν = k − 2
λ estimated from sample mean. One parameter.
GOF
Binomial (p̂)
ν = k − 2
p estimated from sample proportion. One parameter.
GOF
Normal (x̄, s²)
ν = k − 3
Both μ and σ² estimated. Two parameters.
Contingency
r × c table
ν = (r−1)(c−1)
No free parameter estimation. Marginal totals fixed.
After merging
cells
Always use k = number of categories after merging, not before. Merging reduces k.

Worked Examples

1
GOF Test — Discrete Uniform Distribution
A die is rolled 120 times. Frequencies: 1→18, 2→22, 3→17, 4→25, 5→19, 6→19. Test at 10% whether the die is fair.
H₀, H₁
H₀: Die is fair (each face equally likely, P = 1/6).   H₁: Die is not fair.
Expected
E = 120/6 = 20 for each face. All E = 20 ≥ 5 ✓
χ²
Σ(O−E)²/E = (18−20)²/20 + (22−20)²/20 + (17−20)²/20 + (25−20)²/20 + (19−20)²/20 + (19−20)²/20
= 4/20 + 4/20 + 9/20 + 25/20 + 1/20 + 1/20 = 44/20 = 2.2
ν and CV
ν = 6−1−0 = 5 (no estimation).   χ²_{0.10,5} = 9.236
Conclusion
2.2 < 9.236 → Fail to reject H₀.
No evidence at 10% that the die is unfair.
2
3×4 Contingency Table — Test of Association
A survey records income level (Low/Medium/High) vs opinion on a policy (Agree/Neutral/Disagree/No opinion). The contingency table has χ² = 18.74. Degrees of freedom = (3−1)(4−1) = 6. Test at 5%.
H₀, H₁
H₀: Income level and policy opinion are independent.   H₁: They are associated.
Critical value
ν = 6.   χ²_{0.05,6} = 12.592
Decision
18.74 > 12.592 → Reject H₀
Significant evidence at 5% that income level and policy opinion are associated.
3
GOF Test — Normal Distribution
Heights of 100 students are grouped into intervals. x̄ = 170 cm, s = 8 cm are estimated from the data. After calculating expected frequencies and merging, 6 categories remain. Compute ν.
Parameters
μ estimated (= x̄ = 170), σ² estimated (= s² = 64). p = 2 parameters.
ν
ν = k − 1 − p = 6 − 1 − 2 =
3
Expected frequencies — Normal
Use z-standardisation: E for interval (a, b) = n × [Φ((b−μ̂)/σ̂) − Φ((a−μ̂)/σ̂)]
Use ±∞ for the open-ended tails.

Practice Questions

Question 1 — GOF: Binomial
[8 marks]
In a genetics experiment, litters of 4 mice are examined. Among 100 litters, the number with white fur are:
White: 0, 1, 2, 3, 4 → Frequency: 12, 30, 38, 14, 6
Estimate p, then test at 5% whether a Binomial(4, p) distribution fits the data.
Estimate p̂ = x̄/4 where x̄ = Σ(x·f)/100. Then compute B(4,p̂) probabilities, multiply by 100 for expected frequencies. Merge any cells with E < 5. ν = k−2 (p estimated).
✓ Solution
x̄ = (0×12+1×30+2×38+3×14+4×6)/100 = (0+30+76+42+24)/100 = 172/100 = 1.72
p̂ = 1.72/4 = 0.43

Expected frequencies (n=100, B(4,0.43)):
P(0) = 0.57⁴ = 0.1056 → E=10.56
P(1) = 4×0.43×0.57³ = 0.3154 → E=31.54
P(2) = 6×0.43²×0.57² = 0.3536 → E=35.36
P(3) = 4×0.43³×0.57 = 0.1765 → E=17.65
P(4) = 0.43⁴ = 0.0342 → E=3.42 < 5 → merge with X=3: O=14+6=20, E=17.65+3.42=21.07

χ² = (12−10.56)²/10.56 + (30−31.54)²/31.54 + (38−35.36)²/35.36 + (20−21.07)²/21.07
= 0.197 + 0.075 + 0.197 + 0.054 = 0.523

ν = 4−1−1 = 2. χ²_{0.05,2} = 5.991
0.523 < 5.991 → Fail to reject H₀
Binomial(4, 0.43) is a good fit at the 5% level.
Question 2 — Contingency Table: 2×3
[7 marks]
Test at 5% whether type of employment is associated with commuting method, given:
CarPublic TransportOtherTotal
Full-time806020160
Part-time30401080
Total11010030240
E_{ij} = row total × col total / grand total. ν = (2−1)(3−1) = 2. Check all E ≥ 5.
✓ Solution
H₀: Employment type and commuting method independent. H₁: Associated.

Expected values:
E(FT,Car)=160×110/240=73.33   E(FT,PT)=160×100/240=66.67   E(FT,Other)=160×30/240=20.00
E(PT,Car)=80×110/240=36.67   E(PT,PT)=80×100/240=33.33   E(PT,Other)=80×30/240=10.00
All E ≥ 5 ✓

χ² = (80−73.33)²/73.33 + (60−66.67)²/66.67 + (20−20)²/20 + (30−36.67)²/36.67 + (40−33.33)²/33.33 + (10−10)²/10
= 0.607 + 0.667 + 0 + 1.213 + 1.333 + 0 = 3.820

ν=(2−1)(3−1)=2. χ²_{0.05,2} = 5.991
3.820 < 5.991 → Fail to reject H₀
No significant association between employment type and commuting method at 5%.
Question 3 — Degrees of Freedom
[4 marks]
State the degrees of freedom for each χ²-test:
(a) GOF test for Poisson with λ unknown, 7 categories after merging.
(b) GOF test for Normal with μ, σ² both estimated, 5 categories remaining.
(c) 4×5 contingency table.
(d) GOF test with 4 equally likely categories, no estimation.
Use ν = k−1−p for GOF; ν = (r−1)(c−1) for contingency.
✓ Solution
(a) k=7, p=1 (λ estimated): ν = 7−1−1 = 5
(b) k=5, p=2 (μ and σ² estimated): ν = 5−1−2 = 2
(c) r=4, c=5: ν = (4−1)(5−1) = 12
(d) k=4, p=0: ν = 4−1−0 = 3
Question 4 — GOF with Merging
[8 marks]
Calls arriving at a call centre per minute are recorded over 180 minutes:
Calls: 0, 1, 2, 3, 4, 5+
Freq: 20, 52, 56, 35, 12, 5
The mean is 2.03. Test at 5% whether a Poisson distribution with λ = 2 (given, not estimated) is a good fit.
Since λ=2 is given (not estimated from data), p=0, so ν=k−1. Calculate Poisson(2) probabilities for 0,1,2,3,4,≥5 and multiply by 180. Merge any with E<5.
✓ Solution
H₀: Calls ~ Poisson(2) (λ=2 given). H₁: Not Poisson(2).

Expected frequencies (×180):
P(0)=e⁻²=0.1353→E=24.35
P(1)=2e⁻²=0.2707→E=48.72
P(2)=2e⁻²=0.2707→E=48.72
P(3)=4/3×e⁻²=0.1804→E=32.47
P(4)=2/3×e⁻²=0.0902→E=16.24
P(≥5)=1−all above→E=180−170.50=9.50
All E≥5 ✓ No merging needed.

χ²=(20−24.35)²/24.35+(52−48.72)²/48.72+(56−48.72)²/48.72+(35−32.47)²/32.47+(12−16.24)²/16.24+(5−9.50)²/9.50
=0.777+0.221+1.088+0.197+1.108+2.132=5.523

ν=6−1−0=5 (λ given, not estimated). χ²_{0.05,5}=11.070
5.523<11.070→Fail to reject H₀
Data are consistent with a Poisson(2) distribution at the 5% level.

Interactive χ²-Calculator

Enter observed and expected frequencies for a goodness-of-fit test. The tool checks the 5-rule, computes χ², and gives the decision.

χ²-Test Calculator (Goodness of Fit)
Enter observed and expected values, then click Calculate.

Formula Sheet — χ²-Tests

Test Statistic
χ² = Σ(O−E)²/EAll cells
With Yates' (2×2)Σ(|O−E|−0.5)²/E
Must have E≥5Merge if not
Critical regionRight tail only
Degrees of Freedom
GOF generalν = k−1−p
Poisson (λ given)ν = k−1
Poisson (λ̂=x̄)ν = k−2
Normal (μ̂,σ̂²)ν = k−3
Contingency r×cν = (r−1)(c−1)
Expected Frequencies
GOFE = n × P(category)
Contingency E_{ij}(Rᵢ × Cⱼ) / N
Merge conditionAny E < 5 → merge
After mergingRecount k
Hypotheses
GOF H₀Data follow [distribution]
GOF H₁Data do not follow
Contingency H₀Variables are independent
Contingency H₁Variables are associated
Key Critical Values (5%)
ν=13.841 (Yates: use this)
ν=25.991
ν=37.815
ν=49.488
ν=511.070
Poisson Probabilities
P(X=x)e⁻λ λˣ / x!
P(X≥k)1 − Σ P(X=x), x=0 to k−1
λ̂ = x̄From sample mean
Check: Σ E = nAlways verify
📋 Cambridge Exam Strategy — χ²-Tests
  • Always show the expected frequency table — Cambridge awards marks for E values even if the final χ² is wrong. Set up a table with O, E, and (O−E)²/E columns.
  • Check all E ≥ 5 explicitly — state "all expected frequencies ≥ 5" or identify which cell needs merging. This check earns a mark.
  • Degrees of freedom: State ν explicitly and show how it was calculated (k, p). A common error is forgetting to subtract p when parameters are estimated.
  • Yates' correction: Only for 2×2 tables and only when specified. For larger tables, use the standard formula.
  • Conclusion language: For GOF — "data are/are not consistent with a [distribution] at the X% level." For contingency — "there is/is not significant evidence of an association between [variable A] and [variable B]." Never use "correlation."
  • Normal GOF: Standardise interval boundaries using z = (x−μ̂)/σ̂, use Φ tables to find probabilities, multiply by n. Open-ended intervals use Φ(−∞) = 0 and Φ(+∞) = 1.
← Lesson 4.2: Inference 9231 P4 · Lesson 4.3 of 5