Unit 3 · Topic 3.14 · about 25 minutes
AP Statistics 3.14: Setting Up a Chi-Square Test for Homogeneity or Independence
Decide whether a two-way table calls for a test of homogeneity or independence, then write the hypotheses and check the conditions in context.
Unit 3: 15 to 25% of the multiple-choice section
What you'll be able to do
- Describe chi-square distributions: their values, their shape and how the shape changes with the degrees of freedom.
- Identify whether a two-way table calls for a chi-square test for homogeneity or a chi-square test for independence, naming the populations and variables.
- Write the null and alternative hypotheses for a chi-square test for homogeneity or independence.
- Verify the conditions for a chi-square test for homogeneity or independence.
Key vocabulary
| Term | What it means | The exam trap |
|---|---|---|
| Chi-square test for homogeneity | The test of whether the distribution of one categorical variable differs across two or more populations or treatments, using independent random samples or a randomized experiment. | Grade groups formed by splitting one random sample afterward do not make a homogeneity test; the samples must be taken separately or the treatments assigned. |
| Chi-square test for independence | The test of whether two categorical variables are associated in a single population, using one random sample with both variables recorded for each individual. | Its hypotheses are about an association in one population, so borrowing the homogeneity wording about several populations misstates them. |
| Expected count | The count predicts for one cell, (row total)(column total)/(table total). | Rounding expected counts to whole numbers changes the statistic; they describe an average and can be decimals, such as 22.33. |
| Chi-square statistic | , where is a cell's observed count and its expected count: the distance between observed and expected counts relative to the expected counts. | Raw gaps are not what it adds: missing by 6 adds 3.6 when 10 were expected, but only 0.12 when 300 were. |
| Chi-square distribution | A family of density curves, one for each number of degrees of freedom, that take only positive values and are skewed right. | More degrees of freedom make the skew weaker, not stronger, and the curve is never symmetric about 0. |
Predict first
Two studies end up with two-way tables holding exactly the same counts. Study 1 took one random sample of 300 students at a school and recorded each student's grade (10th, 11th or 12th) and whether the student plays a school sport. Study 2 took a separate random sample of 100 students from each of the three grades and recorded whether each plays a school sport. Do the two studies call for the same chi-square test?
What the chi-square statistic measures
Both tests compare the counts you observed in a two-way table with the counts you would expect if the null hypothesis were true. An expected count is the count predicts for one cell. For a two-way table it equals (row total)(column total)/(table total), and the next lesson shows where that comes from.
The chi-square statistic measures the distance between the observed and expected counts, relative to the expected counts:
Each cell adds a squared difference divided by a positive expected count, so no cell can pull the total below 0. A of 0 would mean every observed count matched its expected count exactly, and the farther the data sit from what predicts, the larger gets. Dividing by the expected count keeps the comparison fair. Missing by 6 when you expected 10 adds ; missing by 6 when you expected 300 adds only 0.12.
Chi-square distributions
When is true, the chi-square statistic follows a chi-square distribution. There is a whole family of these density curves, one for each number of degrees of freedom. For a two-way table, the degrees of freedom are (number of rows minus 1) times (number of columns minus 1), so a 2 by 3 table has 2. The next lesson uses this number to find the p-value. Every one of them takes only positive values and is skewed right. As the degrees of freedom increase, the skew becomes less pronounced.
Chi-square distribution with 2 degrees of freedom
Each bar is the probability that the statistic lands in that interval of width 1. Values pile up near 0 and trail far off to the right.
Chi-square distribution with 10 degrees of freedom
Same horizontal axis as the chart above. The distribution is still skewed right, but far less than with 2 degrees of freedom.
Homogeneity or independence?
The arithmetic for the two tests is identical, from the expected counts to the p-value. What separates them is the design of the study, because the design decides which question the data can answer.
- A chi-square test for homogeneity compares the distribution of one categorical variable across two or more populations or treatments. The data come from independent random samples, one from each population, or from a randomized experiment.
- A chi-square test for independence asks whether two categorical variables are associated in a single population. The data come from one random sample, with both variables recorded for each individual.
A quick way to tell: count the samples. Several samples, or several treatment groups, set up by the researcher means homogeneity. One sample, split up afterward by a second variable, means independence.
Sort it
Which chi-square test fits each study? Tap a card, then tap its bin.
Homogeneity
Independence
| Hypothesis | Homogeneity | Independence |
|---|---|---|
| There is no difference in the distribution of the categorical variable across the populations or treatments. | There is no association between the two categorical variables in the population; they are independent. | |
| There is a difference in the distribution of the categorical variable across the populations or treatments. | There is an association between the two categorical variables in the population; they are not independent. |
Always fill these in with the actual variables and populations. For Study 1 in the opening question, is that there is no association between grade level and playing a school sport among students at the school. For Study 2, is that the distribution of sport participation is the same for the school's 10th, 11th and 12th graders.
| Condition | Homogeneity | Independence |
|---|---|---|
| Randomization | Independent random samples, one from each population, or a randomized experiment | One random sample from the population |
| 10% | When sampling without replacement, each sample is no more than 10% of its population; not needed for a randomized experiment | When sampling without replacement, |
| Expected counts | All expected counts are greater than 5 | All expected counts are greater than 5 |
| Response | Satisfied | Neutral | Dissatisfied | Total |
|---|---|---|---|---|
| Apology email | 21 | 24 | 15 | 60 |
| Email plus free ride pass | 34 | 22 | 4 | 60 |
| Phone call from a supervisor | 29 | 21 | 10 | 60 |
| Total | 84 | 67 | 29 | 180 |
Worked exampleSetting up a test for three complaint responses
A transit agency randomly assigns 180 riders who complained about late buses to receive one of three responses, 60 riders each: an apology email, an apology email with a free ride pass, or a phone call from a supervisor. A month later, each rider rates the agency as Satisfied, Neutral or Dissatisfied. The results are in the table above. The agency wants to know whether the distribution of ratings differs among the three responses. Identify the test, state the hypotheses and check the conditions.
Identify the test. Riders were randomly assigned to three treatments, and one categorical variable, the rating, was recorded. That calls for a chi-square test for homogeneity.
State the hypotheses. : there is no difference in the distribution of ratings (satisfied, neutral, dissatisfied) among riders like these who receive the apology email, the email with a ride pass, or the phone call. : there is a difference in the distribution of ratings among the three responses.
Check randomization and 10%. The responses were randomly assigned to riders, which meets the randomization condition. This is a randomized experiment, so the 10% condition does not apply.
Check expected counts. Every row has 60 riders, so every row has the same expected counts: satisfied, neutral and dissatisfied. The smallest is 9.67, so all expected counts are greater than 5.
A chi-square test for homogeneity is appropriate. Notice the observed count of 4 in the ride pass row. It is below 5, and that does not matter, because the condition is about expected counts.
Check your understanding
A researcher selects a random sample of 400 residents of a city and records each person's favorite season and whether the person has seasonal allergies. She wants to know whether favorite season and allergy status are related. Which test is appropriate?
A travel company takes independent random samples of 100 adults from each of three age groups (18 to 34, 35 to 54, and 55 or older) and asks each adult to choose a favorite type of vacation: beach, city or outdoors. Which is the correct null hypothesis for a chi-square test for homogeneity?
Which statement about chi-square distributions is true?
A chi-square test for independence uses a two-way table with 3 rows and 4 columns. The smallest observed count in the table is 3, and the smallest expected count is 6.2. Is the expected counts condition met?
A high school with 2,800 students wants to test whether grade level and preferred lunch option are associated among its students. Which plan for collecting data meets the randomization condition for a chi-square test for independence?
Exam strategy for this topic
- Section I, Multiple Choice: 42 questions in 90 minutes.
- Section II, Free Response: 4 questions in 90 minutes.
- A graphing calculator with statistical capabilities is expected on both sections.
Questions students ask
What is the quickest way to tell homogeneity from independence?
Count the samples. Several samples, or several treatment groups set up by the researcher, means homogeneity. One sample split up afterward by a second variable means independence.
Is the expected counts cutoff 10, like the tests for proportions?
No. For a chi-square test every expected count has to be greater than 5. The at-least-10 rule belongs to the normality condition for proportions.
Can a chi-square statistic be 0 or negative?
It is 0 only if every observed count matches its expected count exactly. It can never be negative, because each cell adds a squared difference divided by a positive expected count.
How many degrees of freedom does a two-way table have?
(number of rows minus 1) times (number of columns minus 1), so a 2 by 3 table has 2. The next lesson uses that number to find the p-value.
Does a randomized experiment need the 10 percent condition?
No. In the transit study the three responses were randomly assigned to riders, which meets the randomization condition, and the 10 percent condition does not apply.
Course alignment, for teachers
AP Statistics topic 3.14, Unit 3: Inference for Categorical Data: Proportions.
- Skill 2.C: Identify appropriate statistical inference methods.
- Skill 2.E: Identify the null and alternative hypotheses.
- Skill 4.C: Describe distributions and compare relative positions of points within a distribution.
- Skill 4.E: Justify the use of a chosen statistical inference method by verifying conditions.