Worked example
Worked example: a 9:3:3:1 dihybrid expectation sampled as 320, 95, 105, 20 vs expected 306, 102, 102, 34. Chi-square = (14²/306) + (7²/102) + (3²/102) + (14²/34) ≈ 6.6 on 3 df, below the 7.82 critical value.
The formula
The formula: χ² = Σ(O−E)²/E with df = categories − 1 (Pearson, 1900). Critical values at p = 0.05: 3.84 (df 1), 5.99 (2), 7.82 (3), 9.49 (4), 11.07 (5).
When is chi-square the right test?
When you compare counted data against a model of expected counts: Mendelian ratios, survey categories, outcome frequencies.
Why must expected counts be 5 or more?
The chi-square approximation of the sampling distribution needs reasonably sized cells; below 5 it distorts, and Fisher's exact test is the safer choice.
How do I test a Mendelian ratio?
Multiply your total by the ratio fractions to get expected counts (for 3:1 with 200 offspring: 150 and 50), then run the test above.