Home / Courses / Introductory Statistics / Unit 7
Introductory Statistics Unit 7: Chi-square tests
Chi-square tests compare observed counts in categories to the counts you'd expect if the null hypothesis were true.
Covers: Tests for independence & homogeneity
Study guide
Chi-square tests handle categorical data with more than two categories. They compare observed counts to the counts expected if the null hypothesis were true, using χ² = Σ (Observed − Expected)²/Expected. Larger χ² values mean the data are farther from what H₀ predicts. Chi-square distributions are skewed right and depend on degrees of freedom.
The goodness-of-fit test checks whether one categorical variable matches a claimed distribution (for example, whether candy colors match the company's percentages). Expected counts are n times each claimed proportion, and df = number of categories − 1.
The test for independence uses one sample classified by two categorical variables and asks whether they're associated. The test for homogeneity uses separate samples from several populations and asks whether the distribution of one variable is the same across them. Both use a two-way table. The expected count in each cell is (row total × column total)/grand total, and df = (rows − 1)(columns − 1).
Conditions: data from random samples or a randomized experiment, the 10% condition when sampling without replacement, and all expected counts at least 5. If the test is significant, compare observed and expected counts (or look at the largest components of χ²) to describe where the biggest differences are. Conclusions follow the same p-value logic as other significance tests.
For a test of independence, H₀ says there is no association between the two variables and Hₐ says there is an association. For homogeneity, H₀ says the distribution of the variable is the same in every population. A significant chi-square result shows association, not causation, unless the data come from a randomized experiment.
Inference applies to samples. If the data cover an entire population, there is no sampling variability to test, and you can describe the population directly.
Key ideas
- Test for independence: one sample, two categorical variables. Are they associated?
- Test for homogeneity: several samples or groups, one categorical variable. Is the distribution the same across groups?
- Expected count for a cell is row total × column total ÷ grand total.
- Condition: all expected counts are at least 5.
- Bigger χ² means observed counts are further from expected, which means a smaller p-value.
Formulas and rules
Common mistakes
- Checking that observed counts are at least 5 instead of expected counts.
- Running the test on percentages instead of counts.
Words to know
- Chi-square statistic
- χ² = Σ (O − E)² / E
- Degrees of freedom for a two-way table
- (rows − 1)(columns − 1)
- Expected count in a two-way table cell
- (row total × column total) / grand total
- Independence vs homogeneity
- Independence: one sample, two variables. Homogeneity: several groups, one variable.
- Large-counts condition for chi-square
- All expected counts are at least 5.
- Chi-square goodness-of-fit test
- Checks whether one categorical variable matches a claimed distribution.
- Chi-square test for independence
- One sample, two categorical variables: are they associated?
- Chi-square test for homogeneity
- Several samples, one variable: is the distribution the same?
- Degrees of freedom (goodness of fit)
- Number of categories − 1.
- Expected count (goodness of fit)
- n × claimed proportion.
- Chi-square distribution
- Skewed right; its shape depends on degrees of freedom.
Sample practice questions
21 more questions like these, from level 1 to 5, are in the practice set.
Observed 30, expected 25. That cell's contribution to χ²?
- 25
- 1
- 5
- 0.2
Show the answer and steps
Answer: B) 1
- Contribution = (O − E)²/E.
- (30 − 25)²/25 = 25/25 = 1.
Degrees of freedom for a chi-square test on a 2 × 5 table?
- 9
- 5
- 4
- 10
Show the answer and steps
Answer: C) 4
- df = (rows − 1)(columns − 1).
- (2 − 1)(5 − 1) = 4.
Row total 40, column total 50, grand total 200. Expected count?
- 40
- 20
- 5
- 10
Show the answer and steps
Answer: D) 10
- Expected = row total × column total / grand total.
- 40 × 50/200 = 10.