# Carrying Out a Chi-Square Test for Homogeneity or Independence

> AP Statistics · AP 2024-2026 Statistics
> Source: https://www.owlsprep.com/study/ap-statistics-u12-carrying-out-a-chi-square/

This module walks through the full step-by-step workflow for executing chi-square tests for homogeneity and independence, including condition checks, calculation, p-value interpretation, and context-rich conclusions aligned with AP scoring rubrics.

**Prerequisites:** [Two-way table construction for categorical data](https://www.owlsprep.com/study/ap-statistics-u12-two-way-tables/); [Core hypothesis testing logic for significance tests](https://www.owlsprep.com/study/ap-statistics-u11-intro-to-significance-tests/)

## Learning objectives

- Verify all required conditions to run a valid chi-square test for homogeneity or independence
- Calculate expected cell counts, chi-square test statistic, and correct degrees of freedom for two-way tables
- Find the appropriate right-tailed p-value and draw a context-aligned conclusion matching AP rubric requirements
- Identify small procedural differences between the two chi-square test types for categorical associations

## Condition Verification for Chi-Square Tests

All chi-square tests for two-way tables require three core conditions to be satisfied to produce reliable results: random sampling or random assignment, independent observations (10% condition if sampling without replacement), and the large counts condition.

**Large Counts Condition** — All expected cell counts in the two-way table must be greater than or equal to 5. This ensures the chi-square distribution is a valid approximation for the test statistic sampling distribution.

**Worked example:** A researcher surveys 200 randomly selected high school students across 3 grade levels to check if snack preference is associated with grade. The 3x3 two-way table has marginal totals of 70, 65, 65 for grades, and 80, 70, 50 for snack types. Verify all conditions for a chi-square test for independence.

1. 1. Random condition: Explicitly stated that 200 randomly selected students were surveyed, so this condition is satisfied.
2. 2. Independence condition: 200 is less than 10% of all high school students at the target school, so observations are independent.
3. 3. Large counts condition: The smallest expected count is (50 * 65)/200 = 16.25, which is far larger than 5, so this condition is satisfied.

**Check your understanding**

1. What is the minimum allowed value for any expected cell count to satisfy the large counts condition?

   - 3
   - 5
   - 10
   - 20

   *Why:* AP Statistics rubrics require all expected counts ≥5 to use the chi-square approximation.

## Calculating Expected Counts and the Chi-Square Test Statistic

Under the null hypothesis, the expected count for each cell is calculated using the corresponding row total, column total, and overall grand total of the two-way table. The test statistic sums the squared standardized difference between observed and expected counts across all cells.

$$E = \frac{(\text{Row Total}) \times (\text{Column Total})}{\text{Grand Total}}$$

$$\chi^2 = \sum \frac{(O - E)^2}{E}$$

**Worked example:** Calculate the chi-square test statistic for a 2x2 table with observed counts: 30, 20 in row 1, 25, 35 in row 2. Grand total is 110.

1. 1. Calculate marginal totals: Row 1 total = 50, Row 2 total = 60, Column 1 total = 55, Column 2 total = 55.
2. 2. Compute expected counts: E11 = (50*55)/110 = 25, E12 = 25, E21 = 30, E22 = 30.
3. 3. Sum squared standardized differences: (30-25)²/25 + (20-25)²/25 + (25-30)²/30 + (35-30)²/30 = 1 + 1 + 0.833 + 0.833 = 3.666

> **tip**
>
> AP graders will deduct points if you do not show at least one full expected count calculation explicitly in your free response, even if your final test statistic is correct.

## Degrees of Freedom and P-Value Calculation

Degrees of freedom for a two-way table chi-square test depends only on the number of rows and columns, not the total sample size. The p-value is always the right-tail probability above your calculated test statistic on the corresponding chi-square distribution.

$$df = (r - 1)(c - 1)$$

**Worked example:** Find the p-value for the earlier 2x2 table test statistic of 3.666.

1. 1. Calculate degrees of freedom: r=2, c=2, so df = (2-1)(2-1) = 1.
2. 2. Use a TI-84 χ²cdf function or chi-square table to find the right-tail probability above 3.666 for df=1.
3. 3. The resulting p-value is approximately 0.055, which is just above the standard α=0.05 significance threshold.

**Exam command terms**

AP exam questions use specific command terms that define your required work:

- **Show that the p-value is approximately 0.05** — You must explicitly state your calculated degrees of freedom before referencing the chi-square distribution

## Drawing Valid Conclusions in Context

Your conclusion must explicitly link the p-value comparison to your pre-stated null hypothesis, and avoid generic statements that do not reference the specific variables from the study. For homogeneity tests, reference distribution differences across groups; for independence tests, reference association between variables.

**Worked example:** Write a full AP-eligible conclusion for the earlier 2x2 test with p-value = 0.055, α=0.05.

1. 1. Compare p-value to alpha: 0.055 > 0.05, so we fail to reject the null hypothesis.
2. 2. State contextual result: There is not sufficient statistically significant evidence at the α=0.05 level to conclude there is an association between the two categorical variables in the target population.

## Common pitfalls

- **Wrong:** Using n-1 for degrees of freedom instead of (r-1)(c-1)
  - Why it fails: Confuses goodness-of-fit test degrees of freedom with two-way table chi-square degrees of freedom
  - Correct: Always subtract 1 from the number of rows and 1 from the number of columns, then multiply the two values to get df
- **Wrong:** Calculating expected counts as total sample size divided by number of cells
  - Why it fails: Ignores unequal marginal totals for rows and columns, leading to heavily biased expected values
  - Correct: Compute each expected count individually using the (row total * column total)/grand total formula
- **Wrong:** Claiming a statistically significant result proves a causal relationship between variables
  - Why it fails: Chi-square tests only detect statistical association, and cannot confirm causation for observational study data
  - Correct: Explicitly state that there is evidence of association, not causation, between the two variables
- **Wrong:** Skipping the large counts condition check entirely in your response
  - Why it fails: AP rubrics allocate a full independent point for verifying this condition, which you will lose if omitted
  - Correct: Confirm all expected counts are ≥5 and state this explicitly before proceeding to calculations
- **Wrong:** Using a two-tailed p-value for the chi-square test
  - Why it fails: The chi-square test statistic is always non-negative, so all p-values are right-tailed
  - Correct: Only calculate the probability that the chi-square distribution exceeds your observed test statistic

## Cheatsheet

| Step | Chi-Square Test for Homogeneity | Chi-Square Test for Independence |
| --- | --- | --- |
| Null Hypothesis | Distributions of the categorical variable are identical across all groups | No association exists between the two categorical variables |
| Expected Count Formula | E = (Row Total * Column Total) / Grand Total | Same formula as homogeneity test |
| Degrees of Freedom | df = (r-1)(c-1) | Same df formula as homogeneity test |
| Conclusion Framing | Compare distributions across separate populations/groups | Describe association (or lack thereof) in the single sampled population |

## What's next

Mastering the procedural workflow for chi-square tests for homogeneity and independence is a high-weight skill for the AP Statistics free-response section, where this topic appears in nearly 70% of recent exam administrations. You will now build on this foundation to learn how to distinguish between the two test types when presented with an unfamiliar study design, a common point of confusion that costs students multiple rubric points on exam day. You will also practice identifying when a chi-square goodness-of-fit test is the appropriate inference procedure instead of the two tests covered here, to avoid mixing up procedures in multi-part exam questions.

---

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-carrying-out-a-chi-square/
