Skip to main content

Unit 3 · Topic 3.14

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

Chi-square tests handle categorical variables with more than two categories, or more than two groups, laid out in a two-way table. This topic covers the χ² distribution, choosing between the test for homogeneity and the test for independence, writing hypotheses and checking conditions.

Key terms

  • chi-square distribution
  • degrees of freedom (df)
  • test for homogeneity
  • test for independence
  • expected counts condition

The chi-square statistic and distribution

A χ² statistic measures how far the observed counts are from the counts you'd expect if H₀ were true, relative to those expected counts. If the observed and expected counts match closely, χ² is small; big gaps make it large.

χ² distributions take only nonnegative values and are skewed right. Each one is set by its degrees of freedom (df). As df increases, the distribution's center moves right (its mean equals df) and it becomes less skewed.

Homogeneity or independence?

Both tests use a two-way table and the same arithmetic. The difference is how the data were collected:

  • Test for homogeneity: separate random samples from two or more populations (or two or more treatment groups in an experiment), with one categorical variable measured. Question: is the distribution of the variable the same in every population?
  • Test for independence: one random sample from one population, with two categorical variables measured on each unit. Question: are the two variables associated in that population?

Why a two-way table again?

Use a chi-square test instead of a two-sample z-test when there are more than two groups, more than two response categories, or both. With exactly two groups and two categories, either test works for a two-sided question (see 3.15).

These tests formalize what you did by eye in topic 2.2. There, you compared conditional distributions and judged whether they looked different. A chi-square test asks whether the differences are bigger than random sampling or random assignment would usually produce.

Hypotheses

Homogeneity: H₀: there is no difference in the distribution of [variable] among [populations or treatments]. Hₐ: there is a difference in the distribution of [variable] among [populations or treatments].

Independence: H₀: there is no association between [variable 1] and [variable 2] among [population] (they are independent). Hₐ: there is an association between [variable 1] and [variable 2] among [population].

Chi-square hypotheses are written in words, not symbols. The alternative has no direction.

Conditions

Check these three conditions. (You won't be tested on the chi-square goodness-of-fit test, which compares one categorical variable with a claimed distribution. It was removed from the course.)

  • Random: for independence, one random sample. For homogeneity, independent random samples or a randomized experiment.
  • 10%: when sampling without replacement, each sample is at most 10% of its population (not needed for an experiment).
  • Large expected counts: every expected count is greater than 5. Many textbooks say at least 5; either way, check the expected counts, not the observed ones.

Worked examples

Try each one yourself first, then open the solution.

  1. Example 1Calculator allowed

    Identify the test and set it up

    A researcher takes separate random samples of 50 students from each of three large high schools and asks whether each student belongs to at least one club. Results: School A 30 yes / 20 no, School B 25 / 25, School C 15 / 35. Identify the test, state hypotheses and check conditions.

    Show the solution
    1. Step 1: Three separate samples from three populations, one categorical variable (club membership): chi-square test for homogeneity.
    2. Step 2: H₀: the distribution of club membership (yes/no) is the same for all students at the three schools. Hₐ: the distribution of club membership differs among the three schools.
    3. Step 3: Random: separate random samples from each school. 10%: 50 is less than 10% of each large school's students.
    4. Step 4: Expected counts: row total × column total ÷ table total. Yes column total = 70, no = 80, table total = 150, each row total = 50. Expected yes = 50 × 70/150 ≈ 23.3 for each school; expected no = 50 × 80/150 ≈ 26.7. All are greater than 5.

    Answer: Chi-square test for homogeneity. H₀: club membership has the same distribution at all three schools; Hₐ: it differs. Conditions met (random samples, 10%, all expected counts about 23.3 or 26.7).

  2. Example 2Calculator allowed

    Trap: which test?

    A random sample of 400 adults in a state is asked their age group and their main news source. A student says this is a test for homogeneity because it compares age groups. Is that right?

    Show the solution
    1. Step 1: There was one random sample from one population, and two variables (age group, news source) were recorded for each person.
    2. Step 2: That's the setting for a test for independence.
    3. Step 3: Homogeneity would require separate samples taken from each age group.

    Answer: No. One sample with two variables is a chi-square test for independence (association between age group and news source among adults in the state).

Common mistakes

  • Choosing homogeneity vs. independence by the question's wording instead of by how the data were collected.
  • Checking that observed counts (not expected counts) are large.
  • Writing chi-square hypotheses with p or with a direction.
  • Writing H₀ as "the variables are associated" (that's Hₐ).

On the exam

  • Name the test fully ("chi-square test for independence") and refer to the variables and population(s) in context in the hypotheses.
  • When checking conditions, show at least the smallest expected count, or list them all, to prove they're greater than 5.

Connected topics

Videos

  • AP Statistics: Topic 8.5 Setting up a Chi Square Test for Homogeneity or Independence

    Michael Porinchak - AP Statistics & AP PrecalculusWatch on YouTube (opens in a new tab)

  • AP Stats 3.B.4 - Chi-Square Test for Homogeneity

    Skew The ScriptWatch on YouTube (opens in a new tab)

  • Introduction to the chi-square test for homogeneity | AP Statistics | Khan Academy

    Khan AcademyWatch on YouTube (opens in a new tab)

  • An Introduction to the Chi-Square Distribution

    jbstatisticsWatch on YouTube (opens in a new tab)

  • AP Statistics The Chi-Square Distribution – The Chi-Square Test for Homogeneity

    Goldie's Math EmporiumWatch on YouTube (opens in a new tab)

Check yourself

4 questions on 3.14 Setting Up a Chi-Square Test for Homogeneity or Independence. Pick an answer to see if you got it, and why.

Question 1 of 4Calculator allowed

Researchers randomly assign 150 people with back pain to three treatments: physical therapy, medication or rest. After 6 weeks, each person rates their pain as better, the same or worse. Which test should be used to see whether the distribution of outcomes differs among the treatments?

Question 2 of 4Calculator allowed

Random samples of students are taken from three high schools and asked whether they prefer morning, afternoon or evening study sessions. Which null hypothesis is correct for a chi-square test for homogeneity?

Question 3 of 4Calculator allowed

Which statement about chi-square distributions is true?

Question 4 of 4Calculator allowed

A chi-square test for independence uses a 2 × 4 table from a random sample. Which result means the expected counts condition is NOT met?

0 of 4 answered