Unit 3 · Topic 3.15 Beta

Carrying Out a Chi-Square Test for Homogeneity or Independence

Carrying out a chi-square test: find each expected count, add the components ((O − E)²)/E to get χ² , use the chi-square distribution with (r − 1)(c − 1) degrees of freedom for the right-tail p-value, compare it with α , and conclude about the association or the distributions in context.

Practice 3: Analyze DataPractice 4: Interpret Results

Part 1 · Hook

Why this matters

Of 300 randomly chosen students, those who keep a phone in the bedroom seem to sleep less: 35% of them sleep under 7 hours, against 20% of the others. The expected counts are ready. Now one number, χ2\chi^2, has to sum up how far the whole table is from "no association", and a new distribution has to say whether that number is surprising.

Part 2 · Before you start

What this builds on

Part 3 · Prerequisite check

Quick check before you start

1. Row total 200, column total 90, grand total 300. What is the expected count?

  1. 6060
  2. 9090
  3. 66.766.7
  4. 4545
Show the answer

200×90300=60\frac{200 \times 90}{300} = 60.

  • Correct: 6060:
  • 9090:
  • 66.766.7:
  • 4545:

2. A test gives a p-value of 0.016 at α=0.05\alpha = 0.05. The decision is

  1. reject H0H_0
  2. fail to reject H0H_0
  3. accept H0H_0
  4. accept HaH_a as proven
Show the answer

0.016<0.050.016 < 0.05, so reject H0H_0.

  • Correct: reject H0H_0:
  • fail to reject H0H_0:
  • accept H0H_0:
  • accept HaH_a as proven:

Part 4 · See it

See it first

Right-skewed chi-square density curve with 2 degrees of freedom; a dashed line marks the observed statistic 8.21 and the thin shaded tail to its right is the p-value, 0.0165.
The chi-square distribution with 2 degrees of freedom. The observed χ2=8.21\chi^2 = 8.21 cuts off a right tail of area 0.0165, the p-value. LevlPrep original diagram.

Part 5 · Step by step

How it works, step by step

  1. For each cell, compare the observed count with the expected countthe term (O−E)2E\frac{(O - E)^2}{E} is that cell's contribution: large where the table departs from H0H_0
  2. Add the terms over every cellχ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E}, which is 0 when the table matches H0H_0 and grows as it departs
  3. If H0H_0 is true, χ2\chi^2 follows a chi-square distribution with df=(r−1)(c−1)\text{df} = (r - 1)(c - 1)the p-value is the area to the right of the observed χ2\chi^2 under that curve
  4. Compare the p-value with α\alphaconclude about an association (or a difference in distributions) in context, then describe it from the largest terms

Part 6 · Key ideas

Key ideas

  • χ2=∑(O−E)2E\chi^2 = \sum \frac{(O - E)^2}{E} over every cell; each term is a chi-square component.
  • Degrees of freedom: df\text{df}=(rows−1)(columns−1)= (\text{rows} - 1)(\text{columns} - 1).
  • The p-value is always the right-tail area: only large χ2\chi^2 values are evidence against H0H_0.
  • Conclude: "There is (is not) convincing evidence of an association between ... and ... for ..." (independence) or "that the distribution of ... differs among ..." (homogeneity).

Part 7 · Misconception

A common mistake

The wrong idea: The cell with the largest observed count contributes the most to χ2\chi^2.

What actually happens: What matters is the gap between observed and expected, relative to expected: (O−E)2E\frac{(O - E)^2}{E}. A big count close to its expected count adds almost nothing.

Part 8 · Check yourself

Check yourself

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

Table

Phones in the bedroom and sleep

A random sample of 300 students at a large high school is asked whether they keep their phone in the bedroom at night and how many hours they usually sleep. A chi-square test for independence is planned at α=0.05\alpha = 0.05; the conditions are met. (Invented data.)
Observed counts: phone in bedroom by usual sleep
Phone in bedroomUnder 7 hours7 to 8 hoursOver 8 hoursTotal
Yes709040200
No205030100
Total9014070300

1. What is the value of the chi-square statistic? Give two decimal places.

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

Show the answer

Expected counts: 60, 93.3, 46.7 (yes) and 30, 46.7, 23.3 (no). χ2\chi^2=(70−60)260= \frac{(70 - 60)^2}{60}+(90−93.3)293.3+ \frac{(90 - 93.3)^2}{93.3}+…+ \dots+(30−23.3)223.3+ \frac{(30 - 23.3)^2}{23.3}=8.21= 8.21.

  • Answer: 8.21

2. How many degrees of freedom does the test have?

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

Show the answer

df=(2−1)(3−1)=2\text{df} = (2 - 1)(3 - 1) = 2.

  • Answer: 2

3. What is the p-value? Give four decimal places.

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

Show the answer

P(χ2≥8.21)P(\chi^2 \ge 8.21) with df=2\text{df} = 2 is 0.0165, the area in the right tail.

  • Answer: 0.0165

4. State the conclusion of the test in context.

Write the conclusion in context.

Show the answer

Reject H0H_0: convincing evidence of an association, in context, for the population sampled.

  • A full-credit answer: Because the p-value of 0.0165 is less than 0.05, we reject the null hypothesis. There is convincing evidence of an association between keeping a phone in the bedroom and usual hours of sleep for students at the school.

5. Which cell contributes most to the chi-square statistic, and what does it show?

  1. No phone, under 7 hours: 20 observed, 30 expected
  2. Phone, 7 to 8 hours: the largest observed count in the table, 90
  3. Phone, under 7 hours: 70 observed against 60 expected
  4. No phone, over 8 hours: 30 observed against 23.3 expected
Show the answer

Each cell's term (O−E)2E\frac{(O - E)^2}{E} shows where the table departs most from H0H_0.

  • Correct: No phone, under 7 hours: 20 observed, 30 expected: Right: its term is (20−30)230=3.33\frac{(20 - 30)^2}{30} = 3.33, the largest of the six.
  • Phone, 7 to 8 hours: the largest observed count in the table, 90: A large count is not the same as a large gap. Here 90 is close to the expected 93.3, a term of only 0.12.
  • Phone, under 7 hours: 70 observed against 60 expected: This term is (70−60)260=1.67\frac{(70 - 60)^2}{60} = 1.67. The same gap of 10 counts for more where only 30 were expected.
  • No phone, over 8 hours: 30 observed against 23.3 expected: This term is 1.90, second largest. The no phone, under 7 hours cell is larger.

6. In one cell of a two-way table, the observed count is 30 and the expected count is 22.4. Write the expression for this cell's contribution to χ2\chi^2, then give its value to two decimal places.

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

Show the answer

(30−22.4)222.4\frac{(30 - 22.4)^2}{22.4}=57.7622.4= \frac{57.76}{22.4}=2.58= 2.58.

  • Answer: (30−22.4)222.4\frac{(30 - 22.4)^{2}}{22.4}

7. A two-way table classifies students by class year (4 categories) and favorite lunch option (5 categories). How many degrees of freedom does a chi-square test for independence have?

  1. 19
  2. 7
  3. 20
  4. 12
Show the answer

df=(r−1)(c−1)\text{df} = (r - 1)(c - 1).

  • 19: That is the number of cells minus 1. Use (r−1)(c−1)(r - 1)(c - 1).
  • 7: That adds (4−1)+(5−1)(4 - 1) + (5 - 1). Multiply instead.
  • 20: That is the number of cells.
  • Correct: 12: Right: (4−1)(5−1)(4 - 1)(5 - 1)=3×4= 3 \times 4=12= 12.

Part 9 · Summary

Summary

Carrying out a chi-square test: find each expected count, add the components (O−E)2E\frac{(O - E)^2}{E} to get χ2\chi^2, use the chi-square distribution with (r−1)(c−1)(r - 1)(c - 1) degrees of freedom for the right-tail p-value, compare it with α\alpha, and conclude about the association or the distributions in context. The largest components show where the association lies.

Part 10 · Up next

What comes next

Part 11 · Connections

Connections