# Setting Up a Chi-Square Test for Homogeneity or Independence

> AP Statistics · AP 2024 Statistics Syllabus
> Source: https://www.owlsprep.com/study/ap-statistics-u12-setting-up-a-chi-square/

We will cover distinguishing chi-square tests for homogeneity vs independence, writing formally correct hypotheses, verifying all required validity conditions, and calculating expected cell counts from two-way table data.

**Prerequisites:** [Construct and interpret two-way contingency tables for categorical data](https://www.owlsprep.com/study/ap-statistics-u11-two-way-tables/); [Core logic of hypothesis testing for population parameters](https://www.owlsprep.com/study/ap-statistics-u10-intro-to-hypothesis-testing/)

## Learning objectives

- Distinguish between chi-square tests for homogeneity and independence based on underlying study design
- State formally correct null and alternative hypotheses for both test types aligned with AP rubric requirements
- Calculate expected cell counts accurately from raw two-way contingency table data
- Verify all three mandatory validity conditions to confirm a chi-square test can be run

## Identifying Homogeneity vs Independence Test Scenarios

While both tests use identical calculation workflows, their use cases are defined entirely by how data was collected, not the structure of the two-way table. A test for homogeneity is used when you sample from two or more separate independent populations, and measure one single categorical variable on each group. A test for independence is used when you sample from one single combined population, and measure two different categorical variables on each individual.

**Chi-Square Test for Homogeneity** — A hypothesis test comparing the distribution of a single categorical variable across 2+ independent populations or treatment groups

*Example:* Comparing preference for 3 different soda brands across 4 separate independently sampled age groups

**Chi-Square Test for Independence** — A hypothesis test assessing if two measured categorical variables are associated within a single sampled population

*Example:* Checking if student course selection (STEM / humanities / arts) is associated with after-school part-time work status

**Exam command terms**

AP exam questions use subtle language to signal the correct test type, watch for these cues:

- **Random assignment to treatment groups** — Study is an experiment, use chi-square test for homogeneity

- **Simple random sample from one population, two variables recorded** — Observational study, use chi-square test for independence

- **Compare distributions across groups** — Explicit prompt for homogeneity test

**Worked example:** A researcher recruits 200 first-year college students, records their declared major, and their self-reported weekly exercise frequency. Is this scenario appropriate for a test of homogeneity or independence?

1. First identify sampling design: all 200 students come from a single population of first-year college students
2. Two separate categorical variables are measured for each individual: major, and exercise frequency
3. This is a chi-square test for independence scenario, not homogeneity

## Writing Null and Alternative Hypotheses Correctly

A very common point loss on the AP exam is incorrectly phrasing hypotheses for chi-square tests, which do not reference a single population proportion like 1-proportion z-tests. For homogeneity tests, the null states that the distribution of the categorical variable is identical across all populations, while the alternative states that at least one distribution differs. For independence tests, the null states that the two variables are not associated (independent), while the alternative states that the two variables are associated (dependent).

$$H_0: \text{ The distribution of [categorical variable] is the same across all groups.} \\ H_a: \text{ At least one group's distribution of [categorical variable] differs.}$$

$$H_0: \text{ [Variable 1] and [Variable 2] are independent (no association) in the population.} \\ H_a: \text{ [Variable 1] and [Variable 2] are dependent (associated) in the population.}$$

> **Common AP Deduction Alert**
>
> Never write hypotheses that reference "correlation" for categorical variables, or state that "all proportions are different" for the alternative. The alternative only requires at least one cell to differ from the null expectation.

**Worked example:** Write formal hypotheses for a test investigating if movie genre preference (action, comedy, drama) differs between high school freshmen, sophomores, juniors, and seniors, where each grade was sampled separately.

1. Identify test type first: 4 separate independent populations (each grade level), one categorical variable (genre preference) → homogeneity test
2. Null hypothesis: The distribution of movie genre preference is identical across all four grade levels.
3. Alternative hypothesis: At least one grade level has a different distribution of movie genre preference.

**Check your understanding**

Test your hypothesis writing knowledge:

1. Which of the following is a valid null hypothesis for an independence test?

   - H0: All proportions of pet owners are equal across 5 neighborhoods
   - H0: Pet ownership status and home type are independent in the sampled city
   - H0: There is a strong association between pet ownership and home type

   *Why:* Correct, this correctly frames the null for an independence test for two variables from a single population.

## Calculating Expected Cell Counts

Every cell in your two-way table has an expected count representing the value you would observe if the null hypothesis was perfectly true. You never round expected counts to whole numbers, even if observed counts are integers, this is a common deduction point on the AP exam.

$$E = \frac{\text{(Row total for the cell)} \times \text{(Column total for the cell)}}{\text{Grand total of all observations}}$$

> **tip**
>
> As a sanity check, the sum of all expected counts across any single row must equal the original observed row total, and the sum across any column must equal the original observed column total.

**Worked example:** Calculate the expected count for the cell corresponding to row total 45, column total 62, grand total 180.

1. Plug values directly into the expected count formula
2. $$E = \frac{45 \times 62}{180} = \frac{2790}{180} = 15.5$$

## Verifying Validity Conditions

All three conditions must be explicitly stated and verified to earn full credit for a chi-square test setup on the AP exam. You cannot skip any of them, even if they are implied in the question prompt.

1. Random Condition: Data must come from a simple random sample from the population of interest, or from groups randomly assigned to treatments in an experiment.
2. Independence Condition: Individual observations must be independent, and 10% condition applies if sampling without replacement: the total sample size must be less than 10% of the full population size.
3. Large Counts Condition: All expected cell counts must be greater than or equal to 5. No observed counts are used for this check, only expected values.

**Worked example:** A chi-square test for independence uses a two-way table with 3 rows and 4 columns, grand total 220, all calculated expected counts are ≥ 7. The data comes from a random sample of 220 US adults. Verify all three conditions.

1. Random: Explicitly stated that data comes from a random sample of US adults, condition satisfied.
2. Independence: 220 is far less than 10% of the total US adult population (~250 million), so observations are independent, condition satisfied.
3. Large Counts: All 12 expected cells are ≥ 7, which is greater than 5, condition satisfied.

## Common pitfalls

- **Wrong:** Using observed cell counts to check the large counts condition
  - Why it fails: The large counts rule is explicitly defined for expected counts under the null, not observed values, leading to automatic deduction on AP rubrics.
  - Correct: Always reference your pre-calculated expected counts to confirm all are ≥5.
- **Wrong:** Stating the alternative hypothesis as 'all proportions are different'
  - Why it fails: The chi-square alternative only requires at least one cell to deviate from the null expectation, not every single proportion to differ.
  - Correct: Write 'at least one group's distribution differs' for homogeneity, or 'the two variables are associated' for independence.
- **Wrong:** Rounding expected counts to whole integers
  - Why it fails: Expected counts are theoretical averages, not real observed values, rounding them introduces unnecessary error in the final chi-square statistic.
  - Correct: Keep expected counts to at least 1 decimal place for all calculations.
- **Wrong:** Mixing up homogeneity and independence test scenarios
  - Why it fails: AP exam rubrics deduct points if you misidentify the test type even if all calculations are correct.
  - Correct: First confirm if you sampled from multiple separate populations (homogeneity) or one single population (independence) before proceeding.
- **Wrong:** Writing hypotheses that reference 'correlation' for categorical variables
  - Why it fails: Correlation is a statistic exclusively for two quantitative variables, not categorical data, this demonstrates conceptual misunderstanding.
  - Correct: Use terms like 'association' or 'dependence' to describe relationships between two categorical variables.

## Cheatsheet

| Checklist Item | Homogeneity Test | Independence Test |
| --- | --- | --- |
| Study Design | Sample from 2+ separate populations, 1 categorical variable | Sample from 1 population, 2 categorical variables measured |
| Null Hypothesis | Distribution of variable is identical across all groups | Two variables are independent, no association |
| Expected Count Formula | $E = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}}$ | $E = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}}$ |
| Required Conditions | Random, Independent, All E ≥5 | Random, Independent, All E ≥5 |

## What's next

Now that you have mastered the full setup workflow for chi-square tests, you are ready to calculate the chi-square test statistic, degrees of freedom, and p-value to complete your hypothesis test. These calculation steps are the next required component to earn full credit on AP exam free response questions that assess chi-square inference. You will also learn how to interpret the results of a significant chi-square test to identify which specific cells are driving the significant result, using individual component calculations. Mastering this setup step ensures you do not lose easy points on the first half of any chi-square FRQ, which accounts for roughly 10-15% of the total AP Statistics exam content weight.

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ap-statistics-u12-setting-up-a-chi-square/
