Two-Way Tables: The Full Four-Step Test

AP Statistics · Unit 3 — Inference for Categorical Data: Proportions

State — in words

For a two-way table the hypotheses are written in words, not symbols. Independence: "$H_0$: there is no association between [variable 1] and [variable 2] in the population; $H_a$: there is an association." Homogeneity: "$H_0$: the distribution of [variable] is the same for all [groups]; $H_a$: it is not the same for all groups." Choose by asking how the data were collected — one sample with two variables, or several samples of one variable.

Plan — expected counts and conditions

Under $H_0$ every cell's expected count is

$$\text{expected}=\frac{\text{row total}\times\text{column total}}{\text{grand total}}$$

Conditions: random sample(s) or random assignment; $10\%$ condition for each sample; and all expected counts at least $5$. Say which condition each check satisfies and quote the smallest expected count.

Do and conclude

$\chi^2=\sum\frac{(\text{observed}-\text{expected})^2}{\text{expected}}$ with $df=(r-1)(c-1)$; the P-value is always the upper tail. Example: $50$ boys and $50$ girls asked whether they prefer morning classes; $30$ boys and $20$ girls say yes. Every expected count is $25$, each of the four cells contributes $(5^2)/25=1$, so $\chi^2=4{,}0$ with $df=1$ and P-value $\approx0{,}046$. Conclude in context at the stated $\alpha$, then do the follow-up graders reward: name the cells with the largest components and say in which direction the observed count departs from the expected — that is what "there is an association" actually means.

Worked example: test of independence from a two-way table

A random survey of $200$ students in a city asks how they get to school (bus / bicycle / family motorbike) by school level (middle school / high school). Observed table: middle school: $45,\,35,\,20$; high school: $35,\,25,\,40$. At $\alpha=0.05$, is there an association between school level and mode of transport?

Solution

State: $H_0$: there is no association between school level and how students in this city get to school; $H_a$: there is an association. One sample, two variables: test of independence.

Check: random sample; $200$ is under $10\%$ of the city's students. Row totals $100$ and $100$; column totals $80,\,60,\,60$. Expected count in each cell: $40,\,30,\,30$ in both rows; the smallest is $30\ge5$.

Calculate:

$$\chi^2=\frac{5^2}{40}+\frac{5^2}{30}+\frac{10^2}{30}+\frac{5^2}{40}+\frac{5^2}{30}+\frac{10^2}{30}=0.625+0.833+3.333+0.625+0.833+3.333\approx9.58$$

$df=(2-1)(3-1)=2$; $P\approx0.008$.

Conclusion: $0.008\lt0.05$, reject $H_0$. There is convincing evidence that school level and mode of transport are associated. Follow-up: the two "family motorbike" cells contribute $3.33$ each, the largest: high school students ride a family motorbike more than expected ($40$ versus $30$), middle school students less ($20$ versus $30$).

Common mistake

Writing $H_0:p_1=p_2=p_3$ for a two-way table is the wrong template — it must be in words. Do not round expected counts to whole numbers ($37.5$ stays $37.5$). The conclusion "reject, so school level causes the choice of transport" is wrong: an observational survey gives only an association. And do not forget the upper tail: the chi-square $P$-value is never doubled.

Key takeaway

Hypotheses in words; expected $=$ row total $\times$ column total $/$ grand total; every expected count $\ge5$; $df=(r-1)(c-1)$; $P$ in the upper tail. Conclude in context, then point out the cell that contributes most and the direction of its deviation.

← The Chi-Square Statistic · All AP Statistics lessons · Practice AP Statistics questions (free, instant scoring) · Choosing Among the Three Tests →