UNIHIVE

Study Hub UNIPORT STA 264

STA 264 · Statistics for Biological and Agricultural Sciences

Chi-square tests and contingency tables

Goodness of fit, tests of association, and genetic ratios.

Our notes

2 min read

What 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

df123456
5%3.845.997.819.4911.0712.59

Contingency tables: association

Does disease depend on the breed?

SickHealthyTotal
Local104050
Exotic252550
Total3565100

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

Watch

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.

All STA 264 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.