STA 264 · Statistics for Biological and Agricultural Sciences
Our notes
2 min readWhat it tests
The chi-square (χ²) test compares observed counts with expected counts.
χ² = Σ(O − E)²/E
Goodness of fit: genetics
Does a cross fit Mendel's 3:1? Among 200 offspring, 142 are tall and 58 are short.
Expected: 150 and 50.
χ² = (142 − 150)²/150 + (58 − 50)²/50 = 64/150 + 64/50 = 0.427 + 1.28 = 1.71.
df = 2 − 1 = 1. The critical value at 5% = 3.84.
1.71 < 3.84, so the data fit the 3:1 ratio.
Check using a z test for a proportion: p̂ = 0.71, p₀ = 0.75, SE = √(0.75 × 0.25/200) = 0.0306. z = −0.04/0.0306 = −1.31; z² = 1.71. This equals χ². Correct.
Critical values
| df | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| 5% | 3.84 | 5.99 | 7.81 | 9.49 | 11.07 | 12.59 |
Contingency tables: association
Does disease depend on the breed?
| Sick | Healthy | Total | |
|---|---|---|---|
| Local | 10 | 40 | 50 |
| Exotic | 25 | 25 | 50 |
| Total | 35 | 65 | 100 |
Expected = row total × column total ÷ grand total.
Expected for Local, Sick: 50 × 35/100 = 17.5. The others: 32.5, 17.5, 32.5.
χ² = (10 − 17.5)²/17.5 + (40 − 32.5)²/32.5 + (25 − 17.5)²/17.5 + (25 − 32.5)²/32.5
= 3.214 + 1.731 + 3.214 + 1.731 = 9.89.
df = (rows − 1)(columns − 1) = 1. So 9.89 > 3.84: disease is associated with breed. Exotic birds were sick more often in this sample.
Check with the 2 × 2 shortcut: χ² = N(ad − bc)²/[(a + b)(c + d)(a + c)(b + d)] = 100(250 − 1000)²/(50 × 50 × 35 × 65) = 56,250,000/5,687,500 = 9.89. Correct.
Yates' correction
For 2 × 2 tables, especially small ones, use (|O − E| − 0.5)² in place of (O − E)². Here, it gives: χ² = (7²)(1/17.5 + 1/32.5 + 1/17.5 + 1/32.5) = 49 × 0.1758 = 8.62. It's still significant.
Conditions
- Use counts, never percentages or means.
- Each observation is in one cell, and independent of others.
- Expected counts should be 5 or more in most cells. Otherwise combine classes, or use Fisher's exact test for a 2 × 2 table.
Reporting the direction
χ² only says there's an association. To describe it, give percentages: 20% of local birds and 50% of exotic birds were sick.
Association is not cause. These birds may have differed in housing as well as breed.
Goodness of fit with more classes
A dihybrid cross gave 180, 60, 45 and 35 (total 320). Testing 9:3:3:1, the expected counts are 180, 60, 60 and 20.
χ² = 0 + 0 + 225/60 + 225/20 = 3.75 + 11.25 = 15.0; df = 3; critical = 7.81.
Reject the 9:3:3:1 ratio. The genes may be linked, or a class may survive poorly.
If parameters are estimated
When you've estimated a value from the data (such as λ for a Poisson fit), subtract 1 more df for each.
Exams usually ask: test a genetic ratio; complete a contingency table and test for association; state the df; explain when the test isn't valid.
Common mistake: running χ² on percentages. A sample of 10 and one of 1,000 would then look the same, when they aren't.
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Best pick Introductory Statistics 2e, 11.3 Test of Independence
(opens openstax.org in a new tab)
OpenStax, Introductory Statistics 2e, 11.3 Test of Independence, CC BY-NC-SA 4.0 · licence
-
Introductory Statistics 2e, 11.2 Goodness-of-Fit Test
(opens openstax.org in a new tab)
OpenStax, Introductory Statistics 2e, 11.2 Goodness-of-Fit Test, CC BY-NC-SA 4.0 · licence
-
Chi-squared test
(opens en.wikipedia.org in a new tab)
Wikipedia, Chi-squared test, CC BY-SA 4.0 · licence
-
Contingency table
(opens en.wikipedia.org in a new tab)
Wikipedia, Contingency table, CC BY-SA 4.0 · licence
-
OpenStax, Introductory Statistics 2e (whole free textbook)
The whole book, free to read online or download as a PDF (the PDF is large: Wi-Fi).
(opens openstax.org in a new tab)
OpenStax, OpenStax, Introductory Statistics 2e (whole free textbook), CC BY-NC-SA 4.0 · licence
Watch
-
Contingency table chi-square test | Probability and Statistics | Khan Academy
18 min · ≈ 81 MB · about ₦45
(opens youtube.com in a new tab)
-
Test of Independence Using Chi-Square Distribution
13 min · ≈ 59 MB · about ₦33
(opens youtube.com in a new tab)
-
Chi-Square Test of Independence | Contingency Table | Hypothesis Test
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
Contingency Tables: SU6 | Chi-Square Test | STTN124: NWU | Step-by-Step Tutorial
37 min · ≈ 167 MB · about ₦94
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.