01 / 21

Chi-Square Tests
Homogeneity & Independence

Learn how to set up a \(\chi^2\) test: state hypotheses, build two-way tables, compute expected counts, and choose the right test.

AP Statistics

What Is a \(\chi^2\) Test?

A chi-square test compares observed counts in categorical data to the counts we would expect if a certain hypothesis were true. The test statistic measures how far the observed data deviates from what we predicted.

In AP Statistics, you encounter three chi-square tests: Goodness-of-Fit, Independence, and Homogeneity. This lesson focuses on setting up the last two.

The Two-Way Table

Both the test for independence and the test for homogeneity rely on a two-way table (contingency table). It cross-classifies individuals by two categorical variables.

Variable 2 (Columns) Category A Category B Row Total Variable 1 (Rows) Group 1 Group 2 Col Total
\(O_{11}\)
\(O_{12}\)
\(O_{21}\)
\(O_{22}\)
\(R_1\)
\(R_2\)
\(C_1\)
\(C_2\)
n

Independence vs Homogeneity

Both tests use the same formula and the same mechanics, but they ask different questions about different study designs.

Test for Independence
One sample drawn, then classified on two variables. Question: Are the two variables associated?
Test for Homogeneity
Separate samples from each population, compared on one variable. Question: Is the distribution the same across populations?

A university population with four visibly different sampling routes

A university campus provides a setting for comparing sampling and study-design routes.The way people or groups enter a study determines its design. Sampling within groups, selecting whole groups and assigning treatments answer different questions.

Let the sampling design name the test

A four-by-three observed table with row totals 100 and column totals 140, 140 and 120 is linked to independence and homogeneity designs.For the displayed 400-student table, expected counts in each row are 35, 35 and 30, and df = (4 − 1)(3 − 1) = 6. One random sample classified twice tests independence; separately sampled class-year groups test homogeneity.

Hypotheses: Independence

When we test for independence, our hypotheses concern the relationship between two categorical variables within a single population.

\(H_0\) : Null
Variable A and Variable B are independent (no association) in the population.
\(H_a\) : Alternative
Variable A and Variable B are not independent (there is an association).

Hypotheses: Homogeneity

When we test for homogeneity, our hypotheses concern whether distributions are the same across multiple populations or treatments.

\(H_0\) : Null
The distribution of the response variable is the same for all populations.
\(H_a\) : Alternative
The distribution of the response variable is not the same for all populations.

Computing Expected Counts

Under \(H_0\), we compute what each cell count should be. The expected count for row \(i\), column \(j\) is:

This formula works identically for both independence and homogeneity tests. It represents the count we would see if the null hypothesis were exactly true.

Checking Conditions

Before performing a \(\chi^2\) test, you must verify three key conditions. The AP exam expects you to name and check each one.

1
Random: The data come from a random sample or randomized experiment.
2
Independent / 10% Rule: Individual observations are independent. If sampling without replacement, the sample is less than 10% of the population: \(n < 0.10N\).
3
Large Counts: All expected counts are at least 5: \(E_{ij} \geq 5\) for every cell.

Degrees of Freedom

The \(\chi^2\) distribution is specified by its degrees of freedom. For a two-way table with \(r\) rows and \(c\) columns:

2 × 2 Table
\(\text{df} = (2-1)(2-1) = 1\)
3 × 4 Table
\(\text{df} = (3-1)(4-1) = 6\)
5 × 2 Table
\(\text{df} = (5-1)(2-1) = 4\)

The same formula applies to both independence and homogeneity tests. More degrees of freedom means the \(\chi^2\) distribution is shifted to the right.

The \(\chi^2\) Distribution

0 2 4 6 8 10 12 14 16 Chi-square statistic df = 1 df = 3 df = 6

Step-by-Step Setup

1
Identify the test: Is this independence (one sample, two variables) or homogeneity (multiple samples, one variable)?
2
State hypotheses: Write \(H_0\) and \(H_a\) in context (name the variables or populations).
3
Check conditions: Random, Independent (10%), Large Counts (\(E_{ij} \geq 5\)).
4
Compute expected counts: Use \(E_{ij} = \frac{R_i \times C_j}{n}\) for each cell.
5
State df: Calculate \(\text{df} = (r-1)(c-1)\).

Example 1: Independence

A researcher randomly selects 200 adults and classifies each by exercise frequency (Low, Medium, High) and health status (Good, Poor). Is there an association?

Good Poor Total
Low 20 30 50
Medium 45 35 80
High 55 15 70
Total 120 80 200

Example 1: Expected Counts

Apply \(E_{ij} = \frac{R_i \times C_j}{n}\) to each cell. For instance, the expected count for (Low, Good):

Good (Expected) Poor (Expected)
Low 30 20
Medium 48 32
High 42 28

Example 2: Homogeneity

A school district surveys 150 students from School A and 150 students from School B about their preferred lunch option: Pizza, Salad, or Sandwich.

Pizza Salad Sandwich Total
School A 70 40 40 150
School B 50 60 40 150
Total 120 100 80 300

Common Mistakes

✕ Checking Observed Instead of Expected
The Large Counts condition requires all expected counts \(\geq 5\), not the observed counts.
✕ Wrong Test Type
Confusing independence with homogeneity. Ask: was one sample drawn, or were separate samples drawn?
✕ Generic Hypotheses
Writing "\(H_0\): no association" without naming the specific variables or populations in context loses points on the AP exam.

Summary Comparison

Feature Independence Homogeneity
Sampling One random sample Separate samples per population
Variables Two categorical variables One categorical variable
\(H_0\) Variables are independent Distributions are the same
Fixed totals Only grand total \(n\) Row (or column) totals fixed
Expected count formula \(\frac{R_i \times C_j}{n}\) \(\frac{R_i \times C_j}{n}\)
df \((r-1)(c-1)\) \((r-1)(c-1)\)
Test statistic \(\chi^2 = \displaystyle\sum\frac{(O-E)^2}{E}\) \(\chi^2 = \displaystyle\sum\frac{(O-E)^2}{E}\)

Question 1 of 5

A researcher randomly surveys 500 voters and records each person's political party and stance on an issue (Support, Oppose, Neutral). Which test should be used?

Question 2 of 5

In a \(3 \times 4\) two-way table, what are the degrees of freedom for the \(\chi^2\) test?

Question 3 of 5

A two-way table has a row total of 60, a column total of 80, and a grand total of 200. What is the expected count for that cell?

Question 4 of 5

Which condition for a \(\chi^2\) test requires that all expected counts be at least 5?

Question 5 of 5

A study independently samples 100 freshmen and 100 seniors, then asks each student to name their preferred social media platform. The appropriate null hypothesis is: