STA 260.1 · Introduction to Probability and Statistics
Our notes
1 min readWhen 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:
| Yes | No | Total | |
|---|---|---|---|
| Female | 30 | 20 | 50 |
| Male | 20 | 30 | 50 |
| Total | 50 | 50 | 100 |
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
-
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, 3.4 Contingency Tables
(opens openstax.org in a new tab)
OpenStax, Introductory Statistics 2e, 3.4 Contingency Tables, CC BY-NC-SA 4.0 · licence
-
Contingency table
(opens en.wikipedia.org in a new tab)
Wikipedia, Contingency table, CC BY-SA 4.0 · licence
-
Pearson's chi-squared test
(opens en.wikipedia.org in a new tab)
Wikipedia, Pearson's chi-squared test, CC BY-SA 4.0 · licence
-
NOUN BIO 206: Biostatistics
NOUN course book (PDF, about 1.2 MB). Statistics for agriculture and biology: descriptive statistics, sampling, probability.
(opens nou.edu.ng in a new tab)
-
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)
-
Chi-Square Test of Independence | Contingency Table | Hypothesis Test
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
Chi-Square Tests: Crash Course Statistics #29
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Chi Square Test
7 min · ≈ 32 MB · about ₦18
(opens youtube.com in a new tab)
-
Chi Square Test| Contingency Table Test for independence
38 min · ≈ 171 MB · about ₦96
(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.