UNIHIVE

Study Hub UNIPORT STA 260.1

STA 260.1 · Introduction to Probability and Statistics

Chi-square tests and contingency tables

Goodness of fit and tests of independence for counts in categories.

Our notes

1 min read

When to use χ²

For counts (frequencies) in categories, not measurements. The statistic compares observed counts O with expected counts E:
χ² = Σ (O − E)²/E.
Large values mean the data disagree with H₀.

Goodness of fit

Does the data fit a stated distribution?
Example: a die is rolled 120 times: faces 1 to 6 come up 15, 25, 20, 18, 22, 20 times. H₀: fair, so E = 20 each.
χ² = (25 + 25 + 0 + 4 + 4 + 0)/20 = 58/20 = 2.9.
Degrees of freedom = categories − 1 = 5; critical value at 5% = 11.070. 2.9 < 11.07: no evidence the die is unfair.
If you estimate parameters from the data (for example λ for a Poisson fit), subtract one more degree of freedom for each.

Test of independence (contingency table)

Rows and columns are two classifications. H₀: they are independent.
Expected count for a cell = (row total × column total) / grand total.
Degrees of freedom = (rows − 1)(columns − 1).

Worked example

100 students, by gender and whether they use the library weekly:

YesNoTotal
Female302050
Male203050
Total5050100

Every expected count = 50 × 50/100 = 25.
χ² = 4 × (5²/25) = 4.0, df = 1, critical value 3.841.
4.0 > 3.841: reject H₀ at 5%; library use appears to depend on gender in this sample.
(Checked by computer: χ² = 4.000, p ≈ 0.046, without the continuity correction.)

Conditions

  • Counts must be independent observations (each person counted once).
  • Expected counts should be at least 5 in most cells; otherwise merge categories or use an exact test.
  • For a 2 × 2 table some textbooks apply Yates' correction: Σ (|O − E| − 0.5)²/E. Here it gives 4 × 4.5²/25 = 3.24, which would not reject; follow your lecturer's rule and say which you used.

Measuring the strength

χ² shows whether there is a relation, not how strong. For a 2 × 2 table, φ = √(χ²/n) = √0.04 = 0.2: a weak association.

Exams usually ask

  • Compute expected counts, χ², df and the conclusion.
  • Goodness of fit to uniform, binomial or Poisson.
  • State the conditions for the test.

Common mistake

Running χ² on percentages or means. Use the actual counts; percentages change the statistic.

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 260.1 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.