Chi-Square Tests for Independence and Homogeneity - Complete Interactive Lesson
Part 1: Chi-Square Goodness-of-Fit
📊 Chi-Square Goodness-of-Fit Test
Part 1 of 7 — Testing Categorical Distributions
When to Use Chi-Square Goodness-of-Fit
Use when you want to test whether observed frequencies match expected frequencies for a categorical variable.
Example: A die is rolled 60 times. Do the results suggest it is fair?
| Outcome | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| Observed | 8 | 12 | 7 | 15 | 9 | 9 |
| Expected | 10 | 10 | 10 | 10 | 10 | 10 |
The Chi-Square Statistic
where = observed count and = expected count.
For the die example:
Hypotheses
- : The observed distribution matches the expected distribution
- : The observed distribution does NOT match the expected
Conditions
- Random sample or random assignment
- Expected counts ≥ 5 for all categories
- Independence — observations are independent
🔑 Chi-square tests are always right-tailed — larger values provide more evidence against .
Goodness-of-Fit Check 🎯
Chi-Square Calculation 🧮
A bag should contain equal numbers of 4 colors. From 80 candies: Red=24, Blue=18, Green=22, Yellow=16.
1) Expected count for each color = 80/4 = ?
2) Compute
3) Degrees of freedom = = ?
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 for Each Test |
| ⚠️ What to Do When Conditions Fail |
| 📝 AP Exam Condition-Checking |
🔑 Key Concept: All three chi-square tests (GoF, Independence, Homogeneity) require the same three conditions: Random, 10%, and Large Counts.
The Three Conditions
| Condition | Requirement | AP Language |
|---|---|---|
| Random | Data from random sample or randomized experiment | "The problem states..." or "We are told..." |
| 10% | of the population (if sampling without replacement) | " is less than 10% of all [population]" |
| Large Counts | All expected counts | "All expected counts are at least 5" ✓ |
⚠️ Critical AP Detail: For chi-square, the Large Counts condition uses expected counts, NOT observed counts. This is different from the Large Counts condition for proportions ().
Degrees of Freedom Summary
| Test | Formula | Example |
|---|---|---|
| Goodness of Fit | (where = number of categories) | 6 sides of a die → |
| Independence | table → | |
| Homogeneity | table → |
Why Degrees of Freedom Matter
The distribution changes shape with :
| Shape | |
|---|---|
| Strongly right-skewed | |
| Moderately right-skewed | |
| More symmetric |
Higher shifts the distribution to the right and increases the mean ().
What If Conditions Fail?
| Condition | If It Fails |
|---|---|
| Random | Results may not generalize — state the limitation |
| 10% | Standard errors may be wrong — results are questionable |
| Large Counts | Combine categories or use Fisher exact test (not on AP exam) |
🔑 AP Tip: On the AP exam, if an expected count is below 5, you should note this but may still be asked to proceed with the test. State the concern and continue.
Conditions & df Concepts 🎯
Degrees of Freedom Practice 🧮
1) GoF test with 8 categories:
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 |
|---|
| 📝 GoF 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: Goodness-of-Fit
Problem: A company claims its candy mix is 30% red, 20% blue, 20% green, 15% yellow, 15% orange. A random sample of 200 candies yields:
| Color | Red | Blue | Green | Yellow | Orange |
|---|---|---|---|---|---|
| Observed | 75 | 35 | 32 | 28 | 30 |
| Expected | 60 | 40 | 40 | 30 | 30 |
Step 1 — Hypotheses: : The distribution of colors matches the company claim. : The distribution of colors does not match the company claim.
Step 2 — Conditions:
- Random: Random sample stated ✓
- 10%: of all candies produced ✓
- Large Counts: All expected counts (smallest is 30) ✓
Step 3 — Calculate:
From the table: is between and (since ).
Step 4 — Conclude: Since the p-value is greater than , we fail to reject . There is not convincing evidence that the distribution of candy colors differs from the company claim.
🔍 Follow-up: The red category had the largest contribution (3.75), suggesting there may be more red candies than claimed.
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. : Education level and exercise frequency are associated.
Step 2 — Conditions:
- Random: Random sample stated ✓
- 10%: of all adults ✓
- Large Counts: Expected counts: , , , . All ✓
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.
⚠️ Common AP Mistakes on Chi-Square FRQs
| Mistake | Fix |
|---|---|
| Using observed counts for the Large Counts check | Must use expected counts |
| Forgetting | Always state with the formula |
| Not stating hypotheses in context | ": Color distribution matches claim" not just ": fit" |
| Saying "accept " | Say "fail to reject " |
| Confusing independence, homogeneity, and GoF | Read the study design carefully |
| 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 GoF test: categories A, B, C with observed = 30, 25, 45 and expected = 33.3, 33.3, 33.3 (total = 100, equal proportions).
1) Contribution from category A: (round to 2 decimal places)
2) Contribution from category C: (round to 2 decimal places)
3) for this test?
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 |
|---|
| 📋 All Three Tests Side-by-Side |
| 📐 Formula & Condition Summary |
| 📝 Mixed Practice |
🔑 Key Concept: This review covers all three chi-square tests. Know when to use each, how to check conditions, and how to write full AP-quality solutions.
Three Chi-Square Tests Compared
| Feature | Goodness of Fit | Independence | Homogeneity |
|---|---|---|---|
| Samples | One | One | Two or more |
| Variables | One categorical | Two categorical | One categorical |
| Distribution matches model | Variables are independent | Same distribution across groups | |
| Data Format | One-way table | Two-way table | Two-way table |
Universal Formula
Universal Conditions
| Condition | Requirement |
|---|---|
| Random | Random sample or randomized experiment |
| 10% | of population |
| Large Counts | All expected counts |
Expected Counts
| Test | How to Calculate |
|---|---|
| GoF | (hypothesized proportion) |
| Independence/Homogeneity |
Decision Guide: Which Test?
| Question | Answer |
|---|---|
| Does the data fit a specific model? | GoF |
| Are two variables related (one sample)? | Independence |
| Same distribution across groups (multiple samples)? | Homogeneity |
Key AP Reminders
- is always and always right-tailed
- Large Counts 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) GoF test, 4 categories, , equal proportions. Expected count per category?
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 ✅