The chi-square test, step by step
When to use chi-square, how to calculate it, and how to word your conclusion.
Updated 2 min read
The chi-square (χ²) test asks one question: is the difference between what you observed and what you expected small enough to be due to chance?
When to use it
Use chi-square when your data are counts in categories: numbers of offspring with each phenotype, numbers of woodlice that move to the dry or the damp side of a choice chamber. Do not use it for measurements such as length or mass; compare means with a t-test instead.
The steps
- State the null hypothesis: there is no significant difference between the observed and expected numbers.
- Calculate the expected count for each category (for example from a 3:1 Mendelian ratio).
- For each category, calculate (O − E)² / E.
- Add them up: χ² = Σ (O − E)² / E.
- Find the degrees of freedom: number of categories − 1.
- Compare χ² with the critical value at p = 0.05.
Reading the result
- χ² smaller than the critical value: fail to reject the null hypothesis. The difference can be explained by chance.
- χ² larger than the critical value: reject the null hypothesis. The difference is statistically significant.
Worked example
A cross is expected to give a 3:1 ratio. Out of 200 offspring, 140 show the dominant phenotype and 60 the recessive phenotype.
| Observed (O) | Expected (E) | (O − E)² / E | |
|---|---|---|---|
| Dominant | 140 | 150 | 0.67 |
| Recessive | 60 | 50 | 2.00 |
| Total | 200 | 200 | χ² = 2.67 |
Degrees of freedom = 2 − 1 = 1. The critical value at p = 0.05 is 3.84. Because 2.67 < 3.84, we fail to reject the null hypothesis: the results fit a 3:1 ratio.
Write "fail to reject", not "accept" or "prove". A statistical test never proves a hypothesis.