Unit 3 · Topic 3.15 · about 25 minutes
AP Statistics 3.15: Carrying Out a Chi-Square Test for Homogeneity or Independence
Complete a chi-square test on a two-way table, from expected counts to a conclusion about the population or populations in context.
Unit 3: 15 to 25% of the multiple-choice section
What you'll be able to do
- Calculate expected counts for a two-way table of categorical data.
- Calculate the chi-square statistic and p-value for a chi-square test for homogeneity or independence.
- Interpret the p-value of a chi-square test for homogeneity or independence in context.
- Use the result of a chi-square test to justify a claim about the population or populations.
Key vocabulary
| Term | What it means | The exam trap |
|---|---|---|
| Expected count | The count predicts for a cell: (row total)(column total)/(table total). | Splitting a column total evenly between the rows only works for rows of equal size; the 120 therapy patients expect 54 improvements, not 67.5 or 60. |
| Chi-square statistic | , with the observed count and the expected count, summed over every cell of the table. | The total row and total column never enter the sum; only the inner cells do. |
| Degrees of freedom | (number of rows minus 1) times (number of columns minus 1) for a two-way table. | Counting cells gives 15 for a 3 by 5 table, but the degrees of freedom are . |
| p-value | The area to the right of the observed under the chi-square distribution with the right degrees of freedom, computed assuming is true. | Only the right tail counts: for with 2 degrees of freedom the p-value is about 0.0100, and 0.9900 is the left-tail area. |
Predict first
In a randomized experiment, 300 adults with lower back pain are split into two groups: 120 get physical therapy and 180 get a home exercise sheet. After six weeks, 135 of the 300 adults report improvement. If the treatment made no difference, how many of the 120 physical therapy patients would you expect to improve?
Expected counts
The expected count for a cell is the count the null hypothesis predicts:
The reasoning is the one you just used. If is true, the overall split of the column variable should show up in every row, so each row gets its share of each column. Expected counts describe what happens on average, so they do not have to be whole numbers. Keep the decimals, because rounding expected counts changes the chi-square statistic.
The statistic, the degrees of freedom and the p-value
With the expected counts in hand, add up one piece per cell:
The sum runs over every cell of the table, and never over the totals. When is true, has a chi-square distribution with
The p-value is the area to the right of the observed under that distribution, found with a table or technology. Only the right tail counts, because only large values of mean the data sit far from what predicts.
| Treatment | Improved | Did not improve | Total |
|---|---|---|---|
| Physical therapy | 63 (54) | 57 (66) | 120 |
| Home exercise sheet | 72 (81) | 108 (99) | 180 |
| Total | 135 | 165 | 300 |
Every cell misses its expected count by 9, but the cells with smaller expected counts contribute more: , , and . That makes with , and the p-value is . At , that is convincing statistical evidence that the distribution of outcomes (improved or not) differs between the two treatments for adults like these.
| Age group | Card | Phone | Cash | Total |
|---|---|---|---|---|
| 18 to 34 | 53 | 37 | 10 | 100 |
| 35 to 54 | 77 | 30 | 13 | 120 |
| 55 and older | 70 | 13 | 17 | 100 |
| Total | 200 | 80 | 40 | 320 |
Worked exampleIs payment method associated with age?
A city's consumer affairs office selects a random sample of 320 adults who live in the city and records each person's age group and usual way of paying at a store. The results are in the table above. Do the data provide convincing statistical evidence, at , of an association between age group and usual payment method among adults in the city?
Name the test and state hypotheses. One random sample with two categorical variables calls for a chi-square test for independence. : there is no association between age group and usual payment method among adults in the city. : there is an association between age group and usual payment method among adults in the city.
Check conditions. Randomization: one random sample of the city's adults. 10%: 320 is far less than 10% of the adults in the city. Expected counts: the 18 to 34 row and the 55 and older row each have expected counts of 62.5, 25 and 12.5, and the 35 to 54 row has 75, 30 and 15. For example, card for ages 18 to 34 is . All expected counts are greater than 5.
Calculate. , with . The p-value is .
Conclude in context. Because , reject . There is convincing statistical evidence of an association between age group and usual payment method among adults in the city.
, , p-value about 0.0026: convincing evidence that payment method and age group are associated in this city.
Percent of each age group who usually pay with a phone
The phone column is where observed and expected counts differ most: the youngest group pays by phone far more often than predicts, and the oldest group far less.
What the p-value means, and what to say when it is large
The p-value is the probability of a chi-square statistic as large as the one observed, or larger, computed by assuming is true. In context: assuming there is no association between age group and payment method among the city's adults, there is about a 0.0026 probability of getting a chi-square statistic of 16.30 or larger in a random sample of 320 adults.
As with every test, compare the p-value with : reject if the p-value is less than or equal to , and fail to reject if it is greater. Here , and the result answers the question that started the study. Do payment habits differ by age in this city? The data give convincing evidence that they do.
A large p-value needs more careful wording. Suppose another city's survey gave a p-value of 0.31. Because , fail to reject : the data do not provide convincing statistical evidence of an association between age group and payment method among adults in that city. Saying the two variables are independent would be accepting , and a test can never establish that.
Check your understanding
A random sample of 250 students at a large high school was asked where they usually study.
For a chi-square test for independence, what is the expected count of students in grades 11 to 12 who usually study at the library?
A chi-square test for homogeneity compares the distribution of favorite movie type (action, comedy, drama, horror or animated) across three age groups. How many degrees of freedom does the test have?
A chi-square test for independence on a two-way table with 2 rows and 3 columns gives . What is the p-value?
Independent random samples of students at three high schools are asked their favorite of four music genres. A chi-square test for homogeneity gives with 6 degrees of freedom and a p-value of 0.027. Which is a correct interpretation of the p-value?
A random sample of 400 students at a university is classified by handedness and by preferred sport. A chi-square test for independence gives a p-value of 0.31. At , which conclusion is correct?
Unit 3 check: 15 questions from every lesson in Unit 3
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
Why keep the decimals in expected counts?
An expected count describes what happens on average, so it does not have to be a whole number. Rounding it changes the chi-square statistic.
Why do some cells add more to than others?
Each piece divides by the expected count. In the back pain study every cell misses by 9, yet the cell expecting 54 adds 1.50 while the cell expecting 99 adds about 0.82.
How can I see which cells drove a large ?
Compare observed and expected counts cell by cell. In the payment survey the phone column stands out: 37 adults ages 18 to 34 paid by phone where 25 were expected, and only 13 adults 55 and older did, also against 25 expected.
Is the conclusion about the people sampled or the whole population?
The whole population. The 320 adults in the payment survey are known exactly; the test supports a claim about all adults in the city.
Can I find the p-value without a calculator?
Yes. A chi-square table gives it, read at the right degrees of freedom. A table brackets the p-value between two columns instead of giving it exactly, which is still enough to compare with .
Course alignment, for teachers
AP Statistics topic 3.15, Unit 3: Inference for Categorical Data: Proportions.
- Skill 3.C: Calculate and estimate expected counts, percentages, probabilities, and intervals.
- Skill 3.E: Calculate appropriate statistical inference method results.
- Skill 4.F: Interpret results of statistical inference methods.
- Skill 4.G: Justify a claim based on statistical inference method results.