Carrying Out a Chi-Square Test
How to compute expected counts, the chi-square statistic and its degrees of freedom, find and interpret the p-value, and write a conclusion for a test of homogeneity or independence.
Find what H₀ predicts for every cell (the expected counts), then add up how far each observed count is from its prediction: \(\chi^2 = \sum (O - E)^2/E\). If H₀ is true, \(\chi^2\) follows a chi-square distribution with \((r - 1)(c - 1)\) degrees of freedom. The p-value is the area to the right of the observed \(\chi^2\).
1Expected counts and the chi-square statistic
The sum is taken over every cell of the table, not the totals. When H₀ is true, the statistic has a chi-square distribution with
Getting to school
Independent random samples of students at three schools gave the observed counts below (conditions were checked earlier). Compute the chi-square statistic and its degrees of freedom.
| Bus | Car | Walk or bike | Total | |
|---|---|---|---|---|
| School A | 60 | 54 | 36 | 150 |
| School B | 30 | 48 | 22 | 100 |
| School C | 60 | 48 | 42 | 150 |
| Total | 150 | 150 | 100 | 400 |
- 1Expected count = (row total)(column total) / table total. School A, Bus: \(150 \times 150/400 = 56.25\).
- 2Each cell: \((O - E)^2/E\). School A, Bus: \((60 - 56.25)^2/56.25 = 0.25\). School B, Car: \((48 - 37.5)^2/37.5 = 2.94\).
- 3Add all nine pieces (Figure 1): \(\chi^2 = 7.20\).
- 4\(df = (\text{rows} - 1)(\text{columns} - 1) = (3 - 1)(3 - 1) = 4\).
A 3 by 3 table has 9 cells but only \((3 - 1)(3 - 1) = 4\) degrees of freedom. Use the numbers of rows and columns of categories, leaving out the totals.
Totals are not cells. Adding a “piece” for the total row double counts the data and inflates \(\chi^2\).
2The p-value
The p-value comes from the chi-square distribution with the right degrees of freedom, using a table or technology. Large values of \(\chi^2\) are the evidence against H₀, so the p-value is always the area in the right tail.
Getting to school
Interpret the p-value of 0.126.
- 1State the assumption: H₀ in context.
- 2Then the result: a chi-square statistic of 7.20 or more, and the sample sizes.
“Assuming that there is no difference in the distributions of how students usually get to school at the three schools, there is a 0.126 probability of getting a chi-square statistic of 7.20 or more in random samples of 150, 100, and 150 students.”
Enter the observed counts (no totals) into matrix [A]. STAT, TESTS, χ²-Test, Observed: [A], Expected: [B], Calculate. The output shows χ² = 7.2, p = 0.1257, df = 4, and the calculator stores the expected counts in [B] so you can check the expected counts condition.
3The decision and the conclusion
Compare the p-value with α. If the p-value ≤ α, reject H₀; if the p-value \(\gt\) α, fail to reject H₀. State the conclusion in context, in terms of the alternative hypothesis, with non-definitive language, naming the population (independence) or populations (homogeneity).
Getting to school
Using \(\chi^2 = 7.20\) with df = 4, finish the test at \(\alpha = 0.05\).
- 1p-value \(= P(\chi^2_4 \ge 7.20) \approx 0.126\).
- 20.126 is greater than 0.05, so fail to reject \(H_0\).
A p-value of 0.126 means the school data are consistent with matching distributions, not that the distributions match. Write “there is not convincing evidence that the distributions differ.”
4A test for independence, start to finish
Grade and part-time jobs
A random sample of 240 students at a high school with 2,600 students found that 12 of 80 tenth graders, 22 of 80 eleventh graders, and 34 of 80 twelfth graders have a part-time job. Is there convincing evidence at \(\alpha = 0.05\) of an association between grade level and having a part-time job?
- 1State. H₀: There is no association between grade level and having a part-time job among students at the school. Hₐ: There is an association. \(\alpha = 0.05\).
- 2Plan. Chi-square test for independence. Randomization: one random sample. 10% condition: 240 ≤ 260. Expected counts: 22.67 with a job and 57.33 without in each grade, all at least 5.
- 3Do. Pieces with a job: 5.02, 0.02, 5.67. Pieces without: 1.98, 0.01, 2.24. \(\chi^2 \approx 14.94\), \(df = (3 - 1)(2 - 1) = 2\), p-value \(\approx 0.0006\).
- 4Conclude. Because the p-value of 0.0006 is less than \(\alpha = 0.05\), we reject H₀. There is convincing evidence of an association between grade level and having a part-time job among students at the school.
A test for independence uses one random sample and no assigned treatments. Convincing evidence of an association between grade and having a job does not show that being in a higher grade causes students to get jobs. Only a randomized experiment, analyzed with a test for homogeneity across treatments, supports a cause and effect conclusion.
“Because the p-value of 0.0006 is less than α = 0.05, we reject H₀. There is convincing evidence of an association between grade level and having a part-time job among students at the school.”
Quick reference
| Step | What to write |
|---|---|
| Expected counts | (row total)(column total) ÷ table total, for every cell |
| Statistic | \(\chi^2 = \sum (O - E)^2/E\) over all cells |
| Degrees of freedom | \((r - 1)(c - 1)\) |
| p-value | Right-tail area under the chi-square curve: \(P(\chi^2 \ge \text{observed})\) |
| Decision | p-value ≤ α: reject H₀; p-value \(\gt\) α: fail to reject H₀ |
| Conclusion | Convincing evidence (or not) for Hₐ in context, naming the population(s) |
| Calculator | χ²-Test with the observed counts in a matrix |