Chi-Square Tests for Independence and Homogeneity - Complete Interactive Lesson
Part 1: The Chi-Square Statistic and Its Distribution
📊 The Chi-Square Statistic and Its Distribution
Part 1 of 7 — Measuring How Far Counts Are From Expected
Where Chi-Square Tests Fit
Chi-square tests answer questions about two-way tables of categorical data. On the AP exam there are two of them:
| Test | Question it answers |
|---|---|
| Homogeneity | Is the distribution of one categorical variable the same in two or more populations (or treatment groups)? |
| Independence | In one population, are two categorical variables associated? |
Both tests use the same statistic, the same expected counts and the same degrees of freedom. This part builds those tools; Parts 2 and 3 cover each test.
ℹ️ The goodness-of-fit test (one categorical variable against a claimed distribution) is not part of the current AP Statistics course.
Expected Counts
If the null hypothesis is true, each cell of a two-way table has an expected count:
Example: 200 students (100 in Grade 10, 100 in Grade 12) report how they get to school.
| Bus | Car | Walk | Total | |
|---|---|---|---|---|
| Grade 10 | 32 | 40 | 28 | 100 |
| Grade 12 | 18 | 50 | 32 | 100 |
| Total | 50 | 90 | 60 | 200 |
Expected count for Grade 10, Bus: . The full set of expected counts is 25, 45, 30 in each row.
The Chi-Square Statistic
The sum runs over every cell of the table. Each term measures the distance between an observed and an expected count relative to the expected count, so a gap of 7 matters more in a cell that expects 25 than in a cell that expects 250.
For the example:
🔑 only when every observed count equals its expected count. The farther the counts are from expected, the larger gets.
The Statistic Check 🎯
📈 Chi-Square Distributions
When the null hypothesis is true, the chi-square statistic follows a chi-square distribution with
For the transport example, .
Shape of the family
| Feature | What to know |
|---|---|
| Values | Always positive (a sum of squares divided by positive counts) |
| Shape | Skewed right |
| Effect of | The skew becomes less pronounced as increases |
Why the p-value is a right-tail area
Only large values of are evidence against : they mean the observed counts sit far from what predicts. So the p-value is always the area to the right of the observed under the chi-square curve with the correct .
For the example, with gives a right-tail area of about 0.07 (from a table or technology). Parts 4 and 5 show how to read the table.
Distribution Check 📈
Chi-Square Calculation 🧮
A two-way table has row totals 60 and 90, column totals 50, 70 and 30, and a table total of 150.
1) Expected count for row 1, column 2 = ?
2) The observed count in that cell is 35. What is its contribution to ?
3) Degrees of freedom for this table = ?
Part 2: Chi-Square Test for Independence
📊 Chi-Square Test for Independence
Part 2 of 7 — Are Two Categorical Variables Related?
Topics in This Part
| Section |
|---|
| 📐 When to Use It |
| 📊 Two-Way Tables & Expected Counts |
| 🧮 The Test Statistic |
| 📝 Full Worked Example |
🔑 Key Concept: The chi-square test for independence uses data from one sample to determine whether two categorical variables are associated (related) or independent.
When to Use the Test for Independence
| Feature | Detail |
|---|---|
| Data source | One sample or one group of subjects |
| Variables | Two categorical variables measured on each subject |
| The two variables are independent (not associated) | |
| The two variables are associated (dependent) |
Example: Survey 300 students and record both grade level (freshman, sophomore, junior, senior) and preferred lunch (pizza, salad, sandwich). Is there an association between grade and lunch preference?
Expected Counts
For each cell in a two-way table:
This gives the count you would expect if the two variables were truly independent.
Worked Example
Data: A random sample of 200 adults:
| Favor | Oppose | Total | |
|---|---|---|---|
| Male | 60 | 40 | 100 |
| Female | 45 | 55 | 100 |
| Total | 105 | 95 | 200 |
: Gender and opinion are independent.
: Gender and opinion are associated.
Expected counts:
| Favor | Oppose | |
|---|---|---|
| Male | ||
| Female |
calculation:
Using a table:
Conclusion: Since , we reject . There is convincing evidence of an association between gender and opinion on this issue.
Independence Test Concepts 🎯
Expected Count Practice 🧮
A two-way table has row totals of 80 and 120, column totals of 90 and 110, and a grand total of 200.
1) Expected count for the top-left cell (row 1, column 1)?
2) Expected count for the bottom-right cell (row 2, column 2)?
3) Degrees of freedom for this table?
Independence Test Decisions 🔍
Exit Quiz — Test for Independence ✅
Part 3: Chi-Square Test for Homogeneity
📊 Chi-Square Test for Homogeneity
Part 3 of 7 — Comparing Distributions Across Populations
Topics in This Part
| Section |
|---|
| 📐 Independence vs. Homogeneity |
| 📊 Setting Up the Test |
| 🧮 Worked Example |
| 📝 AP Exam Distinction |
🔑 Key Concept: The test for homogeneity uses data from two or more independent samples (or treatment groups) to determine whether the distribution of a single categorical variable is the same across all populations.
Independence vs. Homogeneity
| Feature | Independence | Homogeneity |
|---|---|---|
| Samples | One sample | Two or more independent samples |
| Variables | Two categorical variables | One categorical variable across groups |
| Variables are independent | Distribution is the same across populations | |
| Calculation | Identical formula: | Same formula |
⚠️ AP Exam: The math is identical. The difference is in the hypotheses and context. Read the problem carefully to determine which test is appropriate.
Hypotheses for Homogeneity
Worked Example
Problem: Two schools were surveyed about favorite subject. Is the distribution of preferences the same?
| Math | English | Science | Total | |
|---|---|---|---|---|
| School A | 45 | 30 | 25 | 100 |
| School B | 35 | 40 | 25 | 100 |
| Total | 80 | 70 | 50 | 200 |
: The distribution of favorite subject is the same for School A and School B.
Expected counts: (each row total = 100, grand total = 200)
| Math | English | Science | |
|---|---|---|---|
| School A | |||
| School B |
:
Using a table with :
Conclusion: Since , we fail to reject . There is not convincing evidence that the distribution of favorite subject differs between the two schools.
Homogeneity Concepts 🎯
Independence or Homogeneity? 🔍
Identify the correct test for each scenario.
Homogeneity Calculation 🧮
Three brands of cereal are compared on sugar level (Low, Medium, High). Samples: Brand A: 50, Brand B: 60, Brand C: 40. Grand total: 150. Column totals: Low = 60, Medium = 50, High = 40.
1) Expected count for Brand A, Low sugar?
2) Expected count for Brand C, High sugar?
3) for this table?
Exit Quiz — Test for Homogeneity ✅
Part 4: Conditions and Degrees of Freedom
📊 Conditions and Degrees of Freedom
Part 4 of 7 — When Can You Use the Test?
Topics in This Part
| Section |
|---|
| ✅ Three Conditions |
| 📐 Degrees of Freedom |
| 📈 How Changes the Distribution |
| ⚠️ What to Do When a Condition Fails |
🔑 Key Concept: Both chi-square tests (homogeneity and independence) require the same three conditions: Random, 10%, and Expected Counts.
The Three Conditions
| Condition | Requirement | AP Language |
|---|---|---|
| Random | Independence test: a random sample. Homogeneity test: independent random samples or a randomized experiment | "The problem states..." or "We are told..." |
| 10% | When sampling without replacement, of the population (not needed for a randomized experiment) | " is less than 10% of all [population]" |
| Expected Counts | All expected counts are greater than 5 | "All expected counts are greater than 5" ✓ |
⚠️ Critical AP Detail: For chi-square, the expected counts condition uses expected counts, NOT observed counts. This is different from the Large Counts condition for proportions ( and ).
Degrees of Freedom
Both tests use the same formula:
| Table | |
|---|---|
Count only the rows and columns of categories; the total row and total column are not part of the table's dimensions.
Why Degrees of Freedom Matter
The distribution changes shape with :
| Shape | |
|---|---|
| Strongly right-skewed | |
| Moderately right-skewed | |
| Much less skewed |
As increases, the skew becomes less pronounced and the curve spreads to the right, so the same value gives a larger p-value when is larger.
What If a Condition Fails?
| Condition | If It Fails |
|---|---|
| Random | Results may not generalize to the population; state the limitation |
| 10% | Observations are not independent enough; the p-value is questionable |
| Expected Counts | The chi-square distribution may not describe the statistic well, so the p-value may be inaccurate |
🔑 AP Tip: If an expected count is 5 or less, say that the condition is not met. If the problem asks you to proceed anyway, state the concern and continue with caution.
Conditions & df Concepts 🎯
Degrees of Freedom Practice 🧮
1) A two-way table has 2 rows and 6 columns.
2) Independence test with a table:
3) Homogeneity test comparing 4 groups on a categorical variable with 3 levels: Table is .
Condition Checking 🔍
Exit Quiz — Conditions & Degrees of Freedom ✅
Part 5: Interpreting Results
📊 Interpreting Results
Part 5 of 7 — Reading Output and Drawing Conclusions
Topics in This Part
| Section |
|---|
| 📐 Interpreting the Statistic |
| 📊 Using the Table |
| 📝 Writing AP Conclusions |
| 🔍 Follow-Up Analysis |
🔑 Key Concept: A large value means the observed data differ substantially from what is expected under . The p-value tells you how surprising your would be if were true.
What the Value Tells You
| Value | Interpretation |
|---|---|
| Near 0 | Observed counts closely match expected → little evidence against |
| Moderate | Some discrepancy → may or may not be significant |
| Large | Big differences → strong evidence against |
The p-value makes this precise: it gives the probability of getting a as large or larger than yours, assuming is true.
Reading the Table
The table gives right-tail areas for the distribution:
| 1 | 2.706 | 3.841 | 5.024 | 6.635 |
| 2 | 4.605 | 5.991 | 7.378 | 9.210 |
| 3 | 6.251 | 7.815 | 9.348 | 11.345 |
| 4 | 7.779 | 9.488 | 11.143 | 13.277 |
| 5 | 9.236 | 11.070 | 12.833 | 15.086 |
How to use: If with : , so .
AP Conclusion Template
If : "Since the p-value () is less than , we reject . There is convincing evidence that [state in context]."
If : "Since the p-value () is greater than , we fail to reject . There is not convincing evidence that [state in context]."
⚠️ Never say "accept " — say "fail to reject ."
Follow-Up: Which Cells Drive the Result?
After rejecting , examine individual cell contributions :
| Contribution | Interpretation |
|---|---|
| Large | This category/cell is a major source of the discrepancy |
| Small | This category/cell fits the model well |
Also note the direction: Is (more than expected) or (fewer than expected)?
Interpretation Concepts 🎯
Using the Table 🧮
Use the partial table above.
1) , . Is less than or greater than 0.05? Enter "less" or "greater".
2) , . The p-value is between which two table values? Enter the larger boundary (e.g., "0.10").
3) For , what value gives ?
Conclusion Writing 🔍
Exit Quiz — Interpreting Results ✅
Part 6: Problem-Solving Workshop
📊 Problem-Solving Workshop
Part 6 of 7 — Full AP Free-Response Practice
Topics in This Part
| Section |
|---|
| 📝 Homogeneity Worked Example |
| 📝 Independence Worked Example |
| ⚠️ Common AP Mistakes |
🔑 Key Concept: Chi-square FRQs follow the same 4-step framework: Hypotheses, Conditions, Calculate, Conclude. Practice writing each step clearly.
Worked Example 1: Test for Homogeneity
Problem: 150 volunteers were randomly assigned to one of three study methods (50 each) and then took the same exam:
| Pass | Fail | Total | |
|---|---|---|---|
| Flashcards | 32 | 18 | 50 |
| Practice tests | 40 | 10 | 50 |
| Rereading | 27 | 23 | 50 |
| Total | 99 | 51 | 150 |
Step 1 — Hypotheses: : There is no difference in the distribution of exam results (pass/fail) across the three study methods. : There is a difference in the distribution of exam results across the three study methods.
Step 2 — Conditions:
- Random: Volunteers were randomly assigned to methods ✓
- 10%: Not needed, because the data come from a randomized experiment ✓
- Expected Counts: Each row expects passes and failures. All expected counts are greater than 5 ✓
Step 3 — Calculate:
From the table: , so (technology: ).
Step 4 — Conclude: Since the p-value is less than , we reject . There is convincing evidence that the distribution of exam results differs across the three study methods. Because the methods were randomly assigned, we can conclude that the method affects the pass/fail distribution for volunteers like these.
🔍 Follow-up: The Practice tests / Fail cell had the largest contribution (2.882): far fewer failures than expected.
Worked Example 2: Test for Independence
Problem: A random sample of 400 adults records education level and exercise frequency:
| ≤ 3 days/week | > 3 days/week | Total | |
|---|---|---|---|
| No degree | 120 | 80 | 200 |
| College degree | 70 | 130 | 200 |
| Total | 190 | 210 | 400 |
Step 1 — Hypotheses: : Education level and exercise frequency are independent among adults. : Education level and exercise frequency are associated among adults.
Step 2 — Conditions:
- Random: Random sample stated ✓
- 10%: of all adults ✓
- Expected Counts: , , , . All greater than 5 ✓
Step 3 — Calculate:
. From the table: so .
Step 4 — Conclude: Since the p-value is less than (in fact less than 0.01), we reject . There is convincing evidence of an association between education level and exercise frequency among adults. This is an observational study, so it does not show that education causes more exercise.
⚠️ Common AP Mistakes on Chi-Square FRQs
| Mistake | Fix |
|---|---|
| Using observed counts for the expected counts check | Must use expected counts, all greater than 5 |
| Forgetting | Always state with the formula |
| Not stating hypotheses in context | Name the variable(s) and the population(s), not just ": independent" |
| Saying "accept " | Say "fail to reject " |
| Confusing independence and homogeneity | One sample with two variables → independence; several samples or groups with one variable → homogeneity |
| Not showing the formula with substitution | Show with at least some terms |
| Claiming causation from an independence test | Association ≠ causation (unless randomized experiment) |
Workshop Concept Check 🎯
Quick Calculations 🧮
A random sample of 120 adults is classified by age group (row totals: under 40 = 70, 40 and over = 50) and favorite drink (column totals: coffee = 60, tea = 36, neither = 24). The observed count for under 40 / coffee is 42.
1) Expected count for under 40 / coffee?
2) Contribution of that cell, ?
3) for this table?
Which Test? 🔍
Exit Quiz — Problem-Solving Workshop ✅
Part 7: Review & Applications
📊 Review & Applications
Part 7 of 7 — Comprehensive Chi-Square Review
Topics in This Part
| Section |
|---|
| 📋 Both Tests Side-by-Side |
| 📐 Formula & Condition Summary |
| 📝 Mixed Practice |
🔑 Key Concept: This review covers the two chi-square tests on the AP exam. Know when to use each, how to check conditions, and how to write full AP-quality solutions.
The Two Chi-Square Tests Compared
| Feature | Homogeneity | Independence |
|---|---|---|
| Samples | Two or more independent samples, or treatment groups | One sample |
| Variables | One categorical variable | Two categorical variables |
| No difference in the distribution across populations or treatments | No association between the variables in the population | |
| Data format | Two-way table | Two-way table |
Universal Formula
Universal Conditions
| Condition | Requirement |
|---|---|
| Random | Random sample (independence); independent random samples or randomized experiment (homogeneity) |
| 10% | of the population when sampling without replacement |
| Expected Counts | All expected counts greater than 5 |
Expected Counts
Decision Guide: Which Test?
| Question | Answer |
|---|---|
| Are two categorical variables related in one population (one sample)? | Independence |
| Is one categorical variable distributed the same way across several groups? | Homogeneity |
| One proportion against a claimed value? | One-proportion test (not chi-square) |
| Two groups, a yes/no variable? | Two-proportion test (a homogeneity test gives the same conclusion) |
Key AP Reminders
- is always and the p-value is always a right-tail area
- The count condition uses expected counts, not observed
- Never say "accept "
- Association ≠ causation (unless randomized experiment)
- Show the formula with substitution on FRQs
- State explicitly
Comprehensive Concept Check 🎯
Mixed Practice 🧮
1) A two-way table has row total 50, column total 40 and table total 200. Expected count for that cell?
2) Independence test, table.
3) , . From the table (: 5.991; : 7.378). Is less than 0.025? Enter "yes" or "no".
Quick Decisions 🔍
Final Exam — Chi-Square Unit ✅