From the free course AP Statistics on Lykke

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

Key concepts: Chi-square statistic — total mismatch between observed and expected counts · Chi-square distributions — positive, right-skewed, shaped by df · Degrees of freedom = (rows − 1)(columns − 1) · Homogeneity — H₀ of identical distributions across populations · Independence — H₀ of no association between two variables · Conditions — random data, 10% rule, expected counts at least 5

The Chi-Square ($\chi^2$) test family provides the mathematical framework for analyzing the relationship between two categorical variables or comparing the distributions of a single categorical variable across multiple populations.

The Chi-Square ($\chi^2$) test family provides the mathematical framework for analyzing the relationship between two categorical variables or comparing the distributions of a single categorical variable across multiple populations. While previous methods focused on the difference between exactly two proportions, these procedures allow for "multi-way" comparisons, such as checking if four different age groups have the same distribution of preferred news sources.

The Chi-Square Distribution and Statistic

The chi-square statistic measures the cumulative "mismatch" between what we observe in a two-way table and what we would expect to see if the null hypothesis were true. It is calculated by summing the squared differences between observed and expected counts, scaled by the expected counts. This ensures that the statistic is always non-negative; a value of zero would indicate a perfect match between observed and expected data.

Chi-Square Distribution (4.C): A family of density curves that are strictly positive and skewed to the right. The specific shape of a chi-square distribution is determined by its degrees of freedom ($df$).

Feature Description
Skewness Heavily skewed right at low $df$; becomes more symmetric and approaches a Normal shape as $df$ increases.
Domain All values are $\ge 0$ because the statistic is based on squared differences.
Degrees of Freedom For a two-way table with $r$ rows and $c$ columns, $df = (r - 1)(c - 1)$.

Choosing the Appropriate Test (2.C)

The most critical step in setting up the inference procedure is distinguishing between a Chi-Square Test for Homogeneity and a Chi-Square Test for Independence. Although the calculation of the test statistic is identical for both, the investigative question and the data collection method dictate which test is appropriate.

Chi-Square Test for Homogeneity

This test is used when we want to determine if the distribution of a single categorical variable is the same across two or more independent populations or treatment groups.

  • Data Collection: Samples are taken from multiple distinct populations (e.g., a sample of urban residents and a sample of rural residents).
  • Goal: Compare "sameness" (homogeneity) of distributions.

Chi-Square Test for Independence

This test is used when we want to determine if there is an association between two categorical variables for a single population.

  • Data Collection: A single random sample is taken from one population, and two different variables are recorded for each individual (e.g., one sample of students, recording both their "Major" and their "Preferred Study Time").
  • Goal: Determine if the variables are "independent" (no association) or "dependent" (associated).

Identifying Hypotheses (2.E)

Hypotheses for chi-square tests are typically written in words rather than symbols to ensure the context of the populations and variables is clear.

Test Type Null Hypothesis ($H_0$) Alternative Hypothesis ($H_a$)
Homogeneity There is no difference in the distribution of [variable] for [populations]. There is a difference in the distribution of [variable] for [populations].
Independence There is no association between [variable A] and [variable B] in the [population]. There is an association between [variable A] and [variable B] in the [population].

Verifying Conditions for Inference (4.E)

Before proceeding with the chi-square test, three conditions must be met to ensure the sampling distribution of the test statistic approximately follows the chi-square distribution.

  1. Random: The data must come from independent random samples or a randomized experiment.
  2. 10% Condition: When sampling without replacement from a finite population, the sample size(s) should be less than 10% of the population(s). (This applies to observational studies, not experiments).
  3. Large Counts: All expected counts must be at least 5. It is a common error to check the observed counts; the condition specifically requires the calculated expected values to be 5 or greater in every cell of the table.

Misconception Check: Independence vs. Homogeneity

A common mistake is assuming that "multiple groups" always means homogeneity. If you take one sample of 200 people and then split them into "Male" and "Female" to look at their "Political Affiliation," you are performing a test for independence because you only took one sample. If you specifically recruited 100 Males and 100 Females as two separate groups, you are performing a test for homogeneity.

Interpretation Check

A researcher selects a single random sample of 500 electric vehicle (EV) owners and records their "Region" (North, South, East, West) and their "Primary Charging Location" (Home, Work, Public).

  1. Which chi-square test is appropriate?
  2. What are the degrees of freedom for this test?

Check your reasoning:

  1. Independence. There is one population (EV owners) and two variables (Region and Charging Location).
  2. $df = 6$. There are 4 regions (rows) and 3 locations (columns). $(4-1) \times (3-1) = 3 \times 2 = 6$.
3.14 Setting Up a Chi-Square Test for Homogeneity or Independence - AP Statistics - image 1
3.14 Setting Up a Chi-Square Test for Homogeneity or Independence - AP Statistics - image 1
3.14 Setting Up a Chi-Square Test for Homogeneity or Independence - AP Statistics - diagram 1
3.14 Setting Up a Chi-Square Test for Homogeneity or Independence - AP Statistics - diagram 1

Source Materials

The whole course on Lykke · Browse all public course wikis