Unit 3 · Topic 3.14 Beta

Setting Up a Chi-Square Test for Homogeneity or Independence

A chi-square test compares a two-way table of observed counts with the counts expected if H_0 were true.

Practice 2: Collect DataPractice 3: Analyze DataPractice 4: Interpret Results

Part 1 · Hook

Why this matters

A poll of 400 adults finds that 62 of the 120 youngest get their news mostly from social media, but only 23 of the 140 oldest do. Is that a real link between age and news habits, or could chance produce a table like this? Comparing more than two groups on a variable with more than two categories needs a new tool: the chi-square test.

Part 2 · Before you start

What this builds on

Part 3 · Prerequisite check

Quick check before you start

1. In a two-way table, 130 of 400 adults use social media for news. What proportion is that?

  1. 0.3250.325
  2. 0.130.13
  3. 0.300.30
  4. 3.083.08
Show the answer

130400=0.325\frac{130}{400} = 0.325, a marginal relative frequency.

  • Correct: 0.3250.325:
  • 0.130.13:
  • 0.300.30:
  • 3.083.08:

2. Two categorical variables are associated when

  1. the conditional distributions differ across groups
  2. the counts are all large
  3. the row totals are equal
  4. one variable has more categories
Show the answer

Association means the distribution of one variable changes with the other.

  • Correct: the conditional distributions differ across groups:
  • the counts are all large:
  • the row totals are equal:
  • one variable has more categories:

3. Which is a correct null hypothesis?

  1. A statement of no effect or no difference about the population
  2. A statement about the sample results
  3. The claim the researcher hopes to prove
  4. A statement that the p-value is small
Show the answer

The null hypothesis is the "nothing going on" claim about parameters.

  • Correct: A statement of no effect or no difference about the population:
  • A statement about the sample results:
  • The claim the researcher hopes to prove:
  • A statement that the p-value is small:

Part 4 · See it

See it first

Two-way table of 400 adults by age group and main news source showing each observed count with its expected count in parentheses, for example 72 observed and 45.5 expected for adults 55 and older who use TV, found as 140 times 130 divided by 400.
Observed counts with the expected counts under H0H_0 beside them, each found as row total times column total over the grand total. LevlPrep original diagram.

Part 5 · Step by step

How it works, step by step

  1. Ask whether two categorical variables are related, or whether groups share one distributionuse a chi-square test: independence for one sample and two variables, homogeneity for several samples or groups and one variable
  2. H0H_0 says no association (or the same distribution in every group)under H0H_0, every row has the same column proportions as the whole table
  3. Apply the overall column proportion to each rowexpected count =row total×column totalgrand total= \frac{\text{row total} \times \text{column total}}{\text{grand total}}
  4. Compare each observed count with its expected countχ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E} is large when the table is far from what H0H_0 predicts, after checking random, 10% and expected counts at least 5

Part 6 · Key ideas

Key ideas

  • Independence: one random sample, two categorical variables. H0H_0: no association between them in the population.
  • Homogeneity: separate random samples or randomly assigned groups, one categorical variable. H0H_0: the distribution is the same in every population.
  • Expected count =row total×column totalgrand total= \frac{\text{row total} \times \text{column total}}{\text{grand total}}; do not round expected counts.
  • Conditions: random; 10% for each sample; every expected count at least 5.

Part 7 · Misconception

A common mistake

The wrong idea: The large counts condition for a chi-square test is that every observed count is at least 10.

What actually happens: The condition is about expected counts, the counts H0H_0 predicts, and the threshold is 5: every expected count must be at least 5.

Part 8 · Check yourself

Check yourself

Exam-style questions. Anything you miss goes into your review queue.

Table

Age and main news source

A polling firm asks a random sample of 400 adults in a large city for their age group and the source they use most for news. (Invented data.)
Observed counts: age group by main news source
Age groupSocial mediaTVNews websitesTotal
18 to 34621840120
35 to 54454055140
55 and older237245140
Total130130140400

1. Which test fits the firm's question of whether age group and main news source are related?

  1. A two-sample z test for p1−p2p_1 - p_2
  2. A chi-square test for independence
  3. A one-proportion z test for the share who use TV
  4. A chi-square test for homogeneity
Show the answer

One sample, two categorical variables: independence.

  • A two-sample z test for p1−p2p_1 - p_2: That compares two proportions. Here each variable has three categories.
  • Correct: A chi-square test for independence: Right: one random sample, two categorical variables recorded on each person.
  • A one-proportion z test for the share who use TV: That looks at one category of one variable and ignores age.
  • A chi-square test for homogeneity: Homogeneity compares one variable across separate samples or groups. Here one sample is classified two ways.

2. Which hypotheses fit this test?

  1. H0H_0: there is an association; HaH_a: there is no association
  2. H0H_0: older adults in the city prefer TV news; HaH_a: older adults in the city do not prefer TV news
  3. H0H_0: age group and news source are not associated among the city's adults; HaH_a: they are associated
  4. H0H_0: the proportions of adults in the three age groups are equal; HaH_a: they are not
Show the answer

H0H_0: the variables are independent (no association) in the population; HaH_a: they are associated.

  • H0H_0: there is an association; HaH_a: there is no association: These are reversed. The null hypothesis is "no association".
  • H0H_0: older adults in the city prefer TV news; HaH_a: older adults in the city do not prefer TV news: The hypotheses are about the whole relationship, not one cell, and H0H_0 is the "no association" claim.
  • Correct: H0H_0: age group and news source are not associated among the city's adults; HaH_a: they are associated: Right: independence hypotheses are about the relationship between the two variables in the population.
  • H0H_0: the proportions of adults in the three age groups are equal; HaH_a: they are not: That is about one variable only. The question is whether the two variables are related.

3. If H0H_0 is true, what is the expected count of adults aged 55 and older whose main source is TV?

Type a number. A table answer and a calculator answer are both accepted.

Show the answer

Expected =140×130400=45.5= \frac{140 \times 130}{400} = 45.5.

  • Answer: 45.5

4. Write the expression for the expected count of adults aged 18 to 34 whose main source is news websites, then give its value.

Type the expression as on the exam, with the values substituted.

Show the answer

Expected =row total×column totalgrand total= \frac{\text{row total} \times \text{column total}}{\text{grand total}}=120×140400= \frac{120 \times 140}{400}=42= 42.

  • Answer: 120⋅140400\frac{120 \cdot 140}{400}

5. Which statement correctly checks the large counts condition for this chi-square test?

  1. The sample of 400 is at least 30
  2. The smallest expected count is 39, so every expected count is at least 5
  3. The expected counts add up to 400, the sample size
  4. The smallest observed count is 18, so the observed counts are at least 10
Show the answer

Large counts for chi-square: all expected counts at least 5.

  • The sample of 400 is at least 30: Comparing nn with 30 is a rule for means.
  • Correct: The smallest expected count is 39, so every expected count is at least 5: Right: a chi-square test needs every expected count to be at least 5.
  • The expected counts add up to 400, the sample size: They always add to the grand total, so this checks nothing.
  • The smallest observed count is 18, so the observed counts are at least 10: The condition is about expected counts, and the chi-square threshold is 5.

6. A vet randomly assigns 150 dogs to three diets and records whether each dog's coat improves, stays the same or gets worse. Which test fits?

  1. Homogeneity: compare the three diet groups' outcome distributions
  2. A one-proportion z test for the share of dogs that improve
  3. A chi-square test for independence, since the dogs form one group
  4. A two-sample z test, since there are two variables
Show the answer

Groups made by random assignment, one categorical response: homogeneity.

  • Correct: Homogeneity: compare the three diet groups' outcome distributions: Right: randomly assigned groups are treated like separate samples, and one categorical outcome is compared across them.
  • A one-proportion z test for the share of dogs that improve: That ignores the diets, the point of the study.
  • A chi-square test for independence, since the dogs form one group: The vet created three groups by random assignment; comparing their outcome distributions is homogeneity.
  • A two-sample z test, since there are two variables: A two-sample z test compares two proportions. Here there are three groups and three outcomes.

7. Which study calls for a chi-square test for independence rather than homogeneity?

  1. Patients randomly assigned to three treatments, with the outcome recorded as better, same or worse
  2. One random sample of 500 voters, each classified by party and by view on a ballot measure
  3. Random samples of 100 students at four schools, asked their favorite subject
  4. Separate random samples of 200 voters from each of three parties, asked their view on a measure
Show the answer

Independence: one sample, two variables. Homogeneity: several samples or groups, one variable.

  • Patients randomly assigned to three treatments, with the outcome recorded as better, same or worse: Groups made by assignment, one outcome compared: homogeneity.
  • Correct: One random sample of 500 voters, each classified by party and by view on a ballot measure: Right: one sample, two variables recorded on each voter.
  • Random samples of 100 students at four schools, asked their favorite subject: Several samples, one variable: homogeneity.
  • Separate random samples of 200 voters from each of three parties, asked their view on a measure: Separate samples from each party, one variable compared: homogeneity.

Part 9 · Summary

Summary

A chi-square test compares a two-way table of observed counts with the counts expected if H0H_0 were true. Choose independence (one sample, two variables) or homogeneity (several samples or groups, one variable), state H0H_0 and HaH_a in context, find each expected count as row total times column total over the grand total, and check random, 10% and expected counts at least 5.

Part 10 · Up next

What comes next

Part 11 · Connections

Connections