Internal assessment › Statistics
The chi-squared (χ²) test
When to use it
Your data are counts in categories: individuals, seeds or quadrats sorted into groups. Two versions:
- Goodness of fit: do the counts fit a ratio you predicted beforehand, such as 9:3:3:1 from a dihybrid cross?
- Test of association: are two ways of sorting the same individuals linked? For example, is species A found with species B more or less often than chance would give?
Assumptions, in plain words
- The numbers are raw counts: not percentages, not means, not measurements.
- Each individual (or quadrat) is counted once, in one category only.
- The categories were decided before counting.
- Each expected count E should be at least 5 (a common rule of thumb; the guide and booklet don't set one). If not, merge categories or collect more data.
The hypotheses
Goodness of fit
- H0
- The F2 phenotypes occur in the ratio 9:3:3:1.
- H1
- The F2 phenotypes do not occur in the ratio 9:3:3:1.
Association
- H0
- The presence of species A is independent of the presence of species B (no association).
- H1
- Presence of species A is associated with presence of species B.
How to calculate it
- Expected counts, goodness of fit: E = total count × that category's share of the ratio. For 9:3:3:1, the first share is 9/16.
- Expected counts, association: E = row total × column total ÷ grand total, for each cell.
- Degrees of freedom: goodness of fit, df = number of categories − 1. Association, df = (rows − 1) × (columns − 1).
- Compare χ2 with the data booklet's critical value for your df at p = 0.05.
- Spreadsheet:
=CHISQ.TEST(observed range, expected range)returns p, once you have worked out the expected counts.=CHISQ.INV.RT(0.05, df)gives the critical value. - No correction: the booklet formula is used as it stands, with no continuity (Yates) correction for 2 × 2 tables. The calculator does the same. Some textbooks apply one; the guide and booklet do not mention it.
Worked examples
Invented data, written for teaching, checked with SciPy.
Goodness of fit: F2 offspring of a cereal plant with two kernel traits, against 9:3:3:1
| Phenotype | O | E | (O − E)² / E |
|---|---|---|---|
| A_B_ (dominant colour, dominant shape) | 312 | 310.5 | 0.0072 |
| A_bb (dominant colour, recessive shape) | 98 | 103.5 | 0.2923 |
| aaB_ (recessive colour, dominant shape) | 109 | 103.5 | 0.2923 |
| aabb (recessive colour, recessive shape) | 33 | 34.5 | 0.0652 |
| Total | 552 | 552.0 | χ² = 0.6570 |
- E for A_B_ = 552 × 9/16 = 310.5. The others: 552 × 3/16 = 103.5, and 552 × 1/16 = 34.5.
- χ2 = 0.0072 + 0.2923 + 0.2923 + 0.0652 = 0.6570 (0.657 to 3 decimal places); df = 4 − 1 = 3.
- Critical value (data booklet, df 3, p = 0.05) = 7.81. 0.657 < 7.81; p = 0.883.
Association: species A and species B in 40 quadrats
| B present | B absent | Row total | |
|---|---|---|---|
| A present | 6 (11) | 16 (11) | 22 |
| A absent | 14 (9) | 4 (9) | 18 |
| Column total | 20 | 20 | 40 |
- E for “both present” = 22 × 20 ÷ 40 = 11. The other cells: 11, 9 and 9.
- χ2 = 2.2727 + 2.2727 + 2.7778 + 2.7778 = 10.1010 (10.101 to 3 decimal places); df = (2 − 1) × (2 − 1) = 1.
- Critical value (data booklet, df 1, p = 0.05) = 3.84. 10.101 > 3.84; p = 0.0015.
Look at the cells: A and B were found together in 6 quadrats where 11 were expected. They occur together less often than chance would give, which may point to interspecific competition. The test alone cannot show the cause. p. 83, syllabus statement C4.1.15
Python's SciPy and R's chisq.test apply Yates to 2 × 2 tables by default (8.18 here instead of 10.10); switch it off to match the booklet.
How to report it: fill in the blanks
Write the sentences yourself and name the software you used.
How to read the result
- χ2 below the critical value: the gaps between O and E are small enough that chance alone could explain them. The counts are consistent with the ratio; that does not prove it.
- χ2 at or above the critical value: evidence against H0. For association, compare O with E cell by cell to see the direction: together more often than expected, or less.
The graph that goes with it
Common mistakes
- Using percentages or means instead of counts.
- Ignoring expected counts below 5. Each expected count E should be at least 5 (a common rule of thumb; the guide and booklet don't set one).
- The wrong df: the number of individuals instead of the number of categories.
- Saying the test “proves” the ratio. Evidence can support a claim but never prove it with certainty. p. 7, Nature of science
- Counting one quadrat or individual in two cells.
- Treating an association as proof of competition, or of any cause. p. 7, Nature of science; p. 83, syllabus statement C4.1.14
Named in the guide?
Yes. Tool 3 names the chi-squared test p. 31, Tool 3: Mathematics. D3.2.21 (HL) uses it on dihybrid crosses, with the p = 0.05 level, null and alternative hypotheses, and observed versus expected p. 101, syllabus statement D3.2.21. C4.1.15 uses it for association between two species from presence and absence data p. 83, syllabus statement C4.1.15. The formula and the critical values for df 1 to 8 are in the data booklet.