mindstair

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

Formulas and rules

χ² = Σ (Observed − Expected)² / Expected
df = (rows − 1)(columns − 1)
Expected = (row total × column total) / grand total

Common mistakes

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.

Question 1 (level 1)

Observed 30, expected 25. That cell's contribution to χ²?

  1. 25
  2. 1
  3. 5
  4. 0.2
Show the answer and steps

Answer: B) 1

  1. Contribution = (O − E)²/E.
  2. (30 − 25)²/25 = 25/25 = 1.
Question 2 (level 1)

Degrees of freedom for a chi-square test on a 2 × 5 table?

  1. 9
  2. 5
  3. 4
  4. 10
Show the answer and steps

Answer: C) 4

  1. df = (rows − 1)(columns − 1).
  2. (2 − 1)(5 − 1) = 4.
Question 3 (level 3)

Row total 40, column total 50, grand total 200. Expected count?

  1. 40
  2. 20
  3. 5
  4. 10
Show the answer and steps

Answer: D) 10

  1. Expected = row total × column total / grand total.
  2. 40 × 50/200 = 10.