Every test so far has concerned a mean. The chi-squared test concerns counts: it asks whether the frequencies you observed differ from what a hypothesis predicts by more than chance would explain.
The idea of a chi-squared test
Compare observed frequencies O with the expected frequencies E that H0 predicts. If they are close, H0 survives; if they diverge, it does not.
Two standard uses:
Goodness of fit — do the data follow a stated distribution? H0: they do.
Independence (a contingency table) — are two categorical variables associated? H0: they are independent.
Expected frequencies
For goodness of fit, E comes from the hypothesised distribution. If a fair die is rolled 60 times, each face is expected 660=10 times.
For a contingency table:
E=grand totalrow total×column total
Pass
Fail
Total
Method A
40
20
60
Method B
30
30
60
Total
70
50
120
E(A, Pass)=12060×70=35E(A, Fail)=12060×50=25
and by the same calculation E(B, Pass)=35, E(B, Fail)=25.
Each term measures a squared discrepancy relative to what was expected: being 5 out of 25 matters more than being 5 out of 35.
Degrees of freedom
Goodness of fit:
ν=(number of categories)−1−(parameters estimated from the data)
Six die faces with nothing estimated gives ν=5.
Contingency table:
ν=(r−1)(c−1)
A 2×2 table gives ν=1; a 3×4 table gives ν=2×3=6.
Some critical values at the 5% level:
ν
1
2
3
5
6
χ0.052
3.841
5.991
7.815
11.070
12.592
Contingency tables
Test at the 5% level whether pass rate is associated with teaching method, for the table above.
1. Hypotheses.H0: method and outcome are independent. H1: they are associated.
2. Expected frequencies.35,25,35,25 as computed.
3. Statistic.χ2=3.43.
4. Degrees of freedom and critical value.ν=(2−1)(2−1)=1, so χ0.052=3.841.
5. Compare and conclude.3.43<3.841, so do not reject H0: at the 5% level there is insufficient evidence of an association between teaching method and pass rate.
Conditions and interpretation
All expected frequencies must be at least 5. Small expected values make the E(O−E)2 term unstable, and the chi-squared approximation breaks down.
If some are too small, combine adjacent categories until every expected value reaches 5 — and recalculate the degrees of freedom for the reduced number of categories.
Other requirements: the data must be frequencies from a random sample, and the observations independent — each item counted in exactly one cell.