Lesson 108 — Chi-squared test: goodness of fit and independence
Chi-squared statistics: asymptotic distribution, degrees of freedom, goodness-of-fit test and independence test in contingency tables. Yates correction, Cramér's V.
Used in: 3rd year High School · Stochastik LK German · H2 Statistics Singapore · Math B Japanese — inferential statistics
Rigorous notation, full derivation, hypotheses
Rigorous definition
Chi-squared distribution
"Chi-squared distributions have an additivity property: if and are independent, then ." — OpenStax Statistics, §11.1
Goodness-of-fit test
Independence test in table
"Expected frequencies for an independence test are calculated assuming that the row proportions are equal across all columns. If the null hypothesis is true (variables independent), this assumption is satisfied." — OpenIntro Statistics, §6.4
Assumptions for validity (Cochran's rule)
Yates correction ( table)
Effect size: Cramér's V
Chi-squared curve with df = 5. The yellow region to the right of the critical value is the rejection region for H0 at level alpha = 5%.
Worked examples
Exercise list
42 exercises · 10 with worked solution (25%)
- Ex. 108.1Application
A six-sided die is rolled 60 times. What is the number of degrees of freedom in the goodness-of-fit test for the uniform distribution?
- Ex. 108.2Application
For the die from the previous exercise rolled 60 times, what is the expected frequency per face?
- Ex. 108.3Application
A die is rolled 60 times: observing 12, 8, 11, 9, 13, 7 for faces 1 to 6. Calculate and conclude at 5%.
- Ex. 108.4Application
Calculate the degrees of freedom for the independence test in a contingency table.
- Ex. 108.5Application
In a contingency table with , , , calculate .
- Ex. 108.6Application
In an independence test, we obtained with . The critical value at 5% is 5.99. What is the conclusion?
- Ex. 108.7ApplicationAnswer key
Calculate Cramér's V: , , table (so ).
- Ex. 108.8ApplicationAnswer key
In which situations should the Yates correction be applied to the chi-squared test?
- Ex. 108.9ApplicationAnswer key
A researcher has in two of five cells in a table. Is the chi-squared test appropriate? Justify.
- Ex. 108.10Application
Observe in observations with expected proportions . Calculate .
- Ex. 108.11Application
For the previous exercise (3 categories, fully specified distribution), what is the number of degrees of freedom?
- Ex. 108.12Application
A study measures blood pressure (high/normal) in the same group of patients before and after an exercise program. Why is the standard independence chi-squared test inadequate?
- Ex. 108.13Application
What is the critical value (chi-squared with 1 degree of freedom at the 5% level)?
- Ex. 108.14Application
Calculate the expected frequencies for the table with cells , , , .
- Ex. 108.15Application
With the expected values from the previous exercise, calculate and conclude at 5%.
- Ex. 108.16ApplicationAnswer key
Why is in every contingency table? Explain geometrically or algebraically.
- Ex. 108.17Application
What are the mean and variance of ? For , is the distribution approximately symmetric?
- Ex. 108.18Application
In a goodness-of-fit test with categories, how do the degrees of freedom change when we estimate parameters of the distribution from the data itself?
- Ex. 108.19Application
Show that the chi-squared statistic is always non-negative.
- Ex. 108.20ApplicationAnswer key
Is the goodness-of-fit chi-squared test one-tailed (right tail) or two-tailed? Why?
- Ex. 108.21Application
in with expected uniform distribution. Calculate and conclude at 1%.
- Ex. 108.22Application
What is the conceptual difference between homogeneity test and independence test? Does the formula for change?
- Ex. 108.23Application
with . What is the conclusion at 5% and at 1%? (Critical values: 11.07 and 15.09 respectively.)
- Ex. 108.24Understanding
What would it mean to obtain in a goodness-of-fit test? Is this possible in real data?
- Ex. 108.25Understanding
Why do very large samples make a problematic measure? What alternative should be used?
- Ex. 108.26UnderstandingAnswer key
Describe the shape of the chi-squared curve for small (e.g. ) vs. large (e.g. ). How does this relate to its origin as a sum of squares?
- Ex. 108.27UnderstandingAnswer key
Which formula below is Pearson's chi-squared statistic?
- Ex. 108.28Understanding
Explain why Cochran's rule () is necessary for the validity of the chi-squared test.
- Ex. 108.29ModelingAnswer key
Dihybrid cross in peas predicts phenotypes in ratio 9:3:3:1. In 160 offspring observe 95, 30, 27, 8. Test goodness of fit at 5%.
- Ex. 108.30Modeling
Survey of 400 university students (200 men, 200 women) tabulates opinion on quotas (Favorable/Neutral/Against): men 70/60/70, women 110/50/40. Test independence at 5%.
- Ex. 108.31Modeling
A sample of 200 M&M's from a package shows: 30 red, 35 orange, 22 yellow, 40 green, 55 blue, 18 brown. According to the manufacturer, proportions are 13%, 20%, 14%, 16%, 24%, 13%. Test goodness of fit at 5%.
- Ex. 108.32Modeling
A/B/C test on landing page: 200 visitors per variation. Conversions: A = 24, B = 30, C = 40. Test homogeneity of conversion rates at 5%.
- Ex. 108.33Modeling
Four machines produce defects: 30, 40, 25, 35 defects respectively (total 130). Test whether the defect rate is uniform among machines at the 5% level.
- Ex. 108.34ModelingAnswer key
Clinical trial with 50 patients (25 per group): vaccine resulted in 18 cures, placebo in 12 cures. Build the table and apply the chi-squared test with Yates correction at 5%.
- Ex. 108.35Modeling
Do DNIT highway accident data follow a Poisson distribution? Describe the complete flowchart for the goodness-of-fit test, including how to handle the unknown parameter.
- Ex. 108.36Understanding
Which condition below is necessary for the validity of the independence chi-squared test?
- Ex. 108.37Understanding
In a before-after study, the same 80 patients are classified as hypertensive or normal before and after intervention. Why use McNemar instead of standard chi-squared?
- Ex. 108.38Understanding
A survey of 500 Brazilians records region (North, Southeast, South) and payment preference (cash vs. installment). Which test is most appropriate to verify whether preference and region are independent?
- Ex. 108.39Challenge
An emergency room recorded 210 visits in one week (30 per day expected). Observed: Sun=18, Mon=40, Tue=28, Wed=25, Thu=29, Fri=42, Sat=28. Is the flow uniform across days? Test at 5%.
- Ex. 108.40Challenge
Electoral survey in 3 Brazilian states (SP, RJ, MG) with 600 voters (200 per state) records candidate preference (A, B, C). Data: SP=(80,70,50), RJ=(60,90,50), MG=(70,60,70). Test independence between state and candidate at 5% and calculate Cramér's V.
- Ex. 108.41ProofAnswer key
Show that for categories, where is the bilateral statistic for proportion test. This explains why .
- Ex. 108.42Proof
Prove the formula for the independence test in an table, explaining how many independent constraints the margins impose on the count vector.
Sources
- OpenStax Statistics — Illowsky, Dean · CC-BY · Chapter 11 (§11.1–11.5). Primary source for exercises and examples.
- OpenIntro Statistics (4th ed) — Diez, Çetinkaya-Rundel, Barr · CC-BY-SA · §6.3–6.4. Conceptual approach and context-based exercises.
- Introduction to Modern Statistics — Çetinkaya-Rundel, Hardin · CC-BY-SA · §18–19. Perspective via simulation and modern inference.