StatisticsChi-Square Tests for Categorical Data3 of 3
Chi-Square Tests for Categorical Data · 3

Chi-Square Test for Independence

When we measure two categorical variables on every individual in a single random sample, we need a way to test whether those two variables are associated in the population or just varying by random chance.

1

Independence vs. Homogeneity and Stating Hypotheses

Before we can test whether where a student sits in a large college lecture hall (Front Row, Middle Section, or Back Section) is associated with passing the class (Pass or Fail), we have to be sure which chi-square test our study calls for. A two-way table for a Chi-Square Test for Independence looks identical to one for a Chi-Square Test for Homogeneity. The difference is entirely in how the data was collected and which totals were fixed in advance.

Test for Independence\htmlClass{lc-ink}{\textbf{Test for Independence}}
(1 sample, 2 variables)\htmlClass{lc-ink}{\text{(1 sample, 2 variables)}}
population\htmlClass{lc-mute}{\text{population}}
300students\htmlClass{lc-ink}{300\enspace\text{students}}
fixed in advance\htmlClass{lc-ink}{\text{fixed in advance}}
Seat Location\htmlClass{lc-ink}{\text{Seat Location}}
Outcome\htmlClass{lc-ink}{\text{Outcome}}
Pass\htmlClass{lc-ink}{\text{Pass}}
Fail\htmlClass{lc-ink}{\text{Fail}}
Total\htmlClass{lc-ink}{\text{Total}}
Front\htmlClass{lc-ink}{\text{Front}}
Middle\htmlClass{lc-ink}{\text{Middle}}
Back\htmlClass{lc-ink}{\text{Back}}
Total\htmlClass{lc-ink}{\text{Total}}
50\htmlClass{lc-ink}{50}
150\htmlClass{lc-ink}{150}
100\htmlClass{lc-ink}{100}
180\htmlClass{lc-ink}{180}
120\htmlClass{lc-ink}{120}
300\htmlClass{lc-ink}{300}
discovered\htmlClass{lc-ink}{\text{discovered}}
after\htmlClass{lc-ink}{\text{after}}
sampling\htmlClass{lc-ink}{\text{sampling}}
discovered after sampling\htmlClass{lc-ink}{\text{discovered after sampling}}
Test for Homogeneity\htmlClass{lc-ink}{\textbf{Test for Homogeneity}}
(3 samples/groups, 1 variable)\htmlClass{lc-ink}{\text{(3 samples/groups, 1 variable)}}
Outcome\htmlClass{lc-ink}{\text{Outcome}}
Front\htmlClass{lc-ink}{\text{Front}}
Middle\htmlClass{lc-ink}{\text{Middle}}
Back\htmlClass{lc-ink}{\text{Back}}
Pass\htmlClass{lc-ink}{\text{Pass}}
Fail\htmlClass{lc-ink}{\text{Fail}}
Total\htmlClass{lc-ink}{\text{Total}}
Total\htmlClass{lc-ink}{\text{Total}}
50\htmlClass{lc-ink}{50}
150\htmlClass{lc-ink}{150}
100\htmlClass{lc-ink}{100}
180\htmlClass{lc-ink}{180}
120\htmlClass{lc-ink}{120}
fixed in\htmlClass{lc-ink}{\text{fixed in}}
advance\htmlClass{lc-ink}{\text{advance}}
discovered after sampling\htmlClass{lc-ink}{\text{discovered after sampling}}

In our study, a researcher takes one random sample of 300300 lecture-hall students and records both seat location and course outcome for each person.

Independence vs. Homogeneity and Stating Hypotheses
300students\htmlClass{lc-ink}{300\enspace\text{students}}
Pass\htmlClass{lc-ink}{\text{Pass}}
Fail\htmlClass{lc-ink}{\text{Fail}}
Total\htmlClass{lc-ink}{\text{Total}}
Front\htmlClass{lc-ink}{\text{Front}}
Middle\htmlClass{lc-ink}{\text{Middle}}
Back\htmlClass{lc-ink}{\text{Back}}
Total\htmlClass{lc-ink}{\text{Total}}
Independence or Homogeneity?\htmlClass{lc-ink}{\text{Independence or Homogeneity?}}
Text solution
Identify the study design from the fixed totalsBecause we took one random sample of 300300 students and measured two categorical variables on each person, neither the row totals (50,150,10050, 150, 100) nor the column totals (180,120180, 120) were known beforehand. Only the grand total of 300300 was fixed in advance, which calls for a Chi-Square Test for Independence.
PassFailRowTotalFrontRow42850MiddleSection8466150BackSection5446100ColumnTotal180120300⏟only totalfixed inadvance\displaystyle \begin{array}{l|cc|c} & \text{Pass} & \text{Fail} & \begin{gathered} \text{Row} \\ \text{Total} \end{gathered} \\ \hline \begin{aligned} & \text{Front} \\[-0.3em] & \text{Row} \end{aligned} & \observed{42} & \observed{8} & 50 \\[1em] \begin{aligned} & \text{Middle} \\[-0.3em] & \text{Section} \end{aligned} & \observed{84} & \observed{66} & 150 \\[1em] \begin{aligned} & \text{Back} \\[-0.3em] & \text{Section} \end{aligned} & \observed{54} & \observed{46} & 100 \\ \hline \begin{aligned} & \text{Column} \\[-0.3em] & \text{Total} \end{aligned} & 180 & 120 & \underbrace{300}_{\begin{gathered} \scriptstyle \text{only total} \\ \scriptstyle \text{fixed in} \\ \scriptstyle \text{advance} \end{gathered}} \end{array}
State the hypotheses in terms of independence in the populationWe test whether knowing a student's seat location tells us anything about their chances of passing in the population of lecture-hall students.
H0:Seat location and courseoutcome are independent(not associated) in thispopulation of students.Ha:Seat location and courseoutcome are not independent(are associated) in thispopulation of students.\displaystyle \begin{aligned} H_0 &: \text{Seat location and course} \\ & \quad \text{outcome are independent} \\ & \quad \text{(not associated) in this} \\ & \quad \text{population of students.} \\ H_a &: \text{Seat location and course} \\ & \quad \text{outcome are not independent} \\ & \quad \text{(are associated) in this} \\ & \quad \text{population of students.} \end{aligned}
2

Conditions, Expected Counts, and the Chi-Square Statistic

Even if seat location and passing are completely independent in the population, a random sample of 300300 students will not split into exact 60%\share{60\%} pass and 40%\share{40\%} fail proportions in every row. We want to find the χ2\stat{\chi^2} statistic, which measures how far the counts across the whole table are from the expected counts, and its p\share{p}-value, which measures how unlikely it would be to get differences as large as ours by random chance alone.

Once the counts are in the table, the math works the exact same way as in the Test for Homogeneity.

Conditions, Expected Counts, and the Chi-Square Statistic
population\htmlClass{lc-mute}{\text{population}}
300\htmlClass{lc-ink}{300}
χ2=?\stat{\chi^2} = {?}
p=?\share{p} = {?}
Text solution
Check the conditions for a single random sampleThe data comes from one random sample of 300300 students, that single sample is at most 10%10\% of a population of at least 3,0003{,}000 lecture-hall students, and every cell's expected count must be at least 55.
N=300≤10% of population  ⟹  Population≥3,000,all E≥5\displaystyle \begin{aligned} & N = 300 \le 10\% \text{ of population} \\ & \implies \text{Population} \ge 3{,}000, \\ & \text{all } \expected{E} \ge 5 \end{aligned}
Apply the overall column proportions to each row totalMultiply each row total by the overall pass rate (180300=60%\tfrac{180}{300} = \share{60\%}) and fail rate (120300=40%\tfrac{120}{300} = \share{40\%}) to find the expected counts E\expected{E} under H0H_0. The smallest expected count is 20≥5\expected{20} \ge 5, so the Large Counts condition is met.
E=Row Total×Column TotalGrand Total⏟expected count under H0  ⟹  {Front (50): EPass=50×180300=30,EFail=50×120300=20Middle (150): EPass=150×180300=90,EFail=150×120300=60Back (100): EPass=100×180300=60,EFail=100×120300=40\displaystyle \begin{aligned} & \underbrace{\expected{E} = \frac{\begin{gathered} \text{Row Total} \times {} \\ \text{Column Total} \end{gathered}}{\text{Grand Total}}}_{\text{expected count under } H_0} \\ & \implies \begin{cases} \text{Front (50): } \\ \begin{aligned} \expected{E_{\text{Pass}}} &= \frac{50 \times 180}{300} = \expected{30}, \\ \expected{E_{\text{Fail}}} &= \frac{50 \times 120}{300} = \expected{20} \end{aligned} \\[0.5em] \text{Middle (150): } \\ \begin{aligned} \expected{E_{\text{Pass}}} &= \frac{150 \times 180}{300} = \expected{90}, \\ \expected{E_{\text{Fail}}} &= \frac{150 \times 120}{300} = \expected{60} \end{aligned} \\[0.5em] \text{Back (100): } \\ \begin{aligned} \expected{E_{\text{Pass}}} &= \frac{100 \times 180}{300} = \expected{60}, \\ \expected{E_{\text{Fail}}} &= \frac{100 \times 120}{300} = \expected{40} \end{aligned} \end{cases} \end{aligned}
Compare each squared gap to its expected countSubtract O−E\gap{\observed{O} - \expected{E}}, square the difference so positive and negative gaps do not cancel, and divide by E\expected{E} so a gap of 6\gap{6} students counts for more in a cell with a smaller expected count than in one with a larger expected count.
(O−E)2E⏟cell component  ⟹  {Front: (42−30)230=14430=4.8,(8−20)220=14420=7.2Middle: (84−90)290=3690=0.4,(66−60)260=3660=0.6Back: (54−60)260=3660=0.6,(46−40)240=3640=0.9\displaystyle \begin{aligned} & \underbrace{\frac{\gap{(\observed{O} - \expected{E})^2}}{\expected{E}}}_{\text{cell component}} \\ \implies & \begin{cases} \text{Front: } \\ \begin{aligned} \frac{\gap{(\observed{42} - \expected{30})^2}}{\expected{30}} &= \frac{\gap{144}}{\expected{30}} = \gap{4.8}, \\ \frac{\gap{(\observed{8} - \expected{20})^2}}{\expected{20}} &= \frac{\gap{144}}{\expected{20}} = \gap{7.2} \end{aligned} \\[0.5em] \text{Middle: } \\ \begin{aligned} \frac{\gap{(\observed{84} - \expected{90})^2}}{\expected{90}} &= \frac{\gap{36}}{\expected{90}} = \gap{0.4}, \\ \frac{\gap{(\observed{66} - \expected{60})^2}}{\expected{60}} &= \frac{\gap{36}}{\expected{60}} = \gap{0.6} \end{aligned} \\[0.5em] \text{Back: } \\ \begin{aligned} \frac{\gap{(\observed{54} - \expected{60})^2}}{\expected{60}} &= \frac{\gap{36}}{\expected{60}} = \gap{0.6}, \\ \frac{\gap{(\observed{46} - \expected{40})^2}}{\expected{40}} &= \frac{\gap{36}}{\expected{40}} = \gap{0.9} \end{aligned} \end{cases} \end{aligned}
Sum the six components and find the tail areaAdd the components across all cells and compare the total against the χ2\chi^2 distribution whose degrees of freedom are the number of cells we can freely fill before the row and column totals lock in the rest.
χ2=∑(O−E)2E=4.8+7.2+0.4+0.6+0.6+0.9=14.5,df=(3−1)(2−1)=2  ⟹  p=0.0007\displaystyle \begin{aligned} \stat{\chi^2} &= \sum \frac{\gap{(\observed{O} - \expected{E})^2}}{\expected{E}} \\ &= \gap{4.8} + \gap{7.2} + \gap{0.4} \\ &\quad + \gap{0.6} + \gap{0.6} + \gap{0.9} = \stat{14.5}, \\ df &= (3 - 1)(2 - 1) = 2 \\ &\implies \share{p} = \share{0.0007} \end{aligned}
0\htmlClass{lc-ink}{0}
4\htmlClass{lc-ink}{4}
10\htmlClass{lc-ink}{10}
12\htmlClass{lc-ink}{12}
2\htmlClass{lc-violet}{2}
χ2\htmlClass{lc-ink}{\chi^2}
df=2\htmlClass{lc-ink}{\text{df} = 2}
95%\htmlClass{lc-green}{95\%}
5.99\htmlClass{lc-orange}{5.99}
14.5\htmlClass{lc-blue}{14.5}
12\htmlClass{lc-mute}{12}
16\htmlClass{lc-mute}{16}
14.5\htmlClass{lc-blue}{14.5}
heights×200\htmlClass{lc-mute}{\text{heights} \times 200}
p=0.0007\htmlClass{lc-green}{p = 0.0007}

Because p=0.0007<α=0.05\share{p} = \share{0.0007} < \alphalevel{\alpha} = \alphalevel{0.05}, we reject H0H_0: there is convincing statistical evidence of an association between seat location and passing the class in this population of students.

3

Where Is the Association? Standardized Residuals

When a table is larger than 2×22 \times 2, rejecting H0H_0 only tells us that the variables are associated somewhere in the table. It does not tell us whether the Back Section is actually failing at an unusually high rate or whether a single row is causing the whole result. To see which cells differ from independence, we compute each cell's standardized residual (or Pearson residual), which acts roughly like a zz-score, measuring how far the observed count sits above or below its expected count in units of E\noise{\sqrt{\expected{E}}}.

Let's see what happens when we turn our six cell components into standardized residuals.

Where Is the Association? Standardized Residuals
χ2=14.5p=0.0007<α=0.05\stat{\chi^2 = 14.5}\qquad \share{p = 0.0007} < \alphalevel{\alpha = 0.05}
Pass\htmlClass{lc-ink}{\text{Pass}}
Fail\htmlClass{lc-ink}{\text{Fail}}
Front\htmlClass{lc-ink}{\text{Front}}
Middle\htmlClass{lc-ink}{\text{Middle}}
Back\htmlClass{lc-ink}{\text{Back}}
42\observed{42}
30\expected{30}
4.8\gap{4.8}
z=?\gap{z} = {?}
84\observed{84}
90\expected{90}
0.4\gap{0.4}
z=?\gap{z} = {?}
54\observed{54}
60\expected{60}
0.6\gap{0.6}
z=?\gap{z} = {?}
8\observed{8}
20\expected{20}
7.2\gap{7.2}
z=?\gap{z} = {?}
66\observed{66}
60\expected{60}
0.6\gap{0.6}
z=?\gap{z} = {?}
46\observed{46}
40\expected{40}
0.9\gap{0.9}
z=?\gap{z} = {?}
Text solution
Take the signed square root of each cell componentUndo the squaring in (O−E)2E\frac{\gap{(\observed{O} - \expected{E})^2}}{\expected{E}} and put back the sign of O−E\gap{\observed{O} - \expected{E}} so the residual shows both how far the cell is from expectation and whether it is above (++) or below (−-) expected.
z=O−EE⏟standardized residual\displaystyle \underbrace{\gap{z} = \frac{\gap{\observed{O} - \expected{E}}}{\noise{\sqrt{\expected{E}}}}}_{\text{standardized residual}} =±Component\displaystyle = \gap{\pm\sqrt{\text{Component}}}
Compare each cell's residual with the ±2\noise{\pm 2} random-noise cutoffAt the 95%\share{95\%} level, a zz-score is significantly unusual when it goes past roughly ±2\noise{\pm 2} (specifically ±1.96\noise{\pm 1.96}, which corresponds to a cell component greater than 22=4\noise{2^2} = \noise{4}).
Front Row:zPass=42−3030=+4.8=+2.19,zFail=8−2020=−7.2=−2.68Middle Section:zPass=84−9090=−0.4=−0.63,zFail=66−6060=+0.6=+0.77Back Section:zPass=54−6060=−0.6=−0.77,zFail=46−4040=+0.9=+0.95\displaystyle \begin{aligned} & \text{Front Row:} \\ & \begin{aligned} \gap{z_{\text{Pass}}} &= \frac{\gap{\observed{42} - \expected{30}}}{\noise{\sqrt{\expected{30}}}} = \gap{+\sqrt{4.8}} \\ &= \gap{+2.19}, \\ \gap{z_{\text{Fail}}} &= \frac{\gap{\observed{8} - \expected{20}}}{\noise{\sqrt{\expected{20}}}} = \gap{-\sqrt{7.2}} \\ &= \gap{-2.68} \end{aligned} \\[0.5em] & \text{Middle Section:} \\ & \begin{aligned} \gap{z_{\text{Pass}}} &= \frac{\gap{\observed{84} - \expected{90}}}{\noise{\sqrt{\expected{90}}}} = \gap{-\sqrt{0.4}} \\ &= \gap{-0.63}, \\ \gap{z_{\text{Fail}}} &= \frac{\gap{\observed{66} - \expected{60}}}{\noise{\sqrt{\expected{60}}}} = \gap{+\sqrt{0.6}} \\ &= \gap{+0.77} \end{aligned} \\[0.5em] & \text{Back Section:} \\ & \begin{aligned} \gap{z_{\text{Pass}}} &= \frac{\gap{\observed{54} - \expected{60}}}{\noise{\sqrt{\expected{60}}}} = \gap{-\sqrt{0.6}} \\ &= \gap{-0.77}, \\ \gap{z_{\text{Fail}}} &= \frac{\gap{\observed{46} - \expected{40}}}{\noise{\sqrt{\expected{40}}}} = \gap{+\sqrt{0.9}} \\ &= \gap{+0.95} \end{aligned} \end{aligned}

Only the Front Row crosses ±2\noise{\pm 2}, meaning the entire significant association comes from front-row students passing more (+2.19\gap{+2.19}) and failing less (−2.68\gap{-2.68}) than expected, while the Middle and Back sections lie well inside the −2\noise{-2} to +2\noise{+2} random-noise range. (Statistical software often prints an Adjusted Standardized Residual that divides by a smaller number to account for the row and column proportions, giving ±3.80\gap{\pm 3.80} for Front, ±1.41\gap{\pm 1.41} for Middle, and ±1.50\gap{\pm 1.50} for Back. This points to the exact same cells, though by hand you compute O−EE\frac{\gap{\observed{O} - \expected{E}}}{\noise{\sqrt{\expected{E}}}}.)

Notice how the same gap O−E\gap{\observed{O} - \expected{E}} gives a much larger standardized residual in the 5050-seat Front Row than in the 150150-seat Middle Section, because we divide by a smaller E\noise{\sqrt{\expected{E}}}.

A cell stands out from random noise only when its residual goes past two, and the same student gap creates a much bigger residual in a small section than in a large one.
4

Strength of Association: Cramér's V and Causation

Knowing that an association is statistically significant (p=0.0007\share{p} = \share{0.0007}) and where it is (the Front Row) still leaves one question open: how strong is the association overall? We cannot use χ2=14.5\stat{\chi^2} = \stat{14.5} to measure strength because, with the same proportion in every cell, χ2\stat{\chi^2} grows proportionally with the sample size NN. Instead, we compute Cramér's V\stat{V}, an effect size that divides out sample size and table dimensions to measure the strength of association on a scale from 00 (completely independent) to 11 (perfectly associated).

Let's calculate Cramér's V\stat{V} for our lecture hall and see what our study design allows us to conclude about cause and effect.

Strength of Association: Cramér's V and Causation
N=300\htmlClass{lc-ink}{N = 300}
Pass\htmlClass{lc-ink}{\text{Pass}}
Fail\htmlClass{lc-ink}{\text{Fail}}
Total\htmlClass{lc-ink}{\text{Total}}
Front\htmlClass{lc-ink}{\text{Front}}
Middle\htmlClass{lc-ink}{\text{Middle}}
Back\htmlClass{lc-ink}{\text{Back}}
Total\htmlClass{lc-ink}{\text{Total}}
42\observed{42}
(30)\expected{(30)}
84\observed{84}
(90)\expected{(90)}
54\observed{54}
(60)\expected{(60)}
180\htmlClass{lc-ink}{180}
8\observed{8}
(20)\expected{(20)}
66\observed{66}
(60)\expected{(60)}
46\observed{46}
(40)\expected{(40)}
120\htmlClass{lc-ink}{120}
50\htmlClass{lc-ink}{50}
150\htmlClass{lc-ink}{150}
100\htmlClass{lc-ink}{100}
300\htmlClass{lc-ink}{300}
χ2=14.5\stat{\chi^2 = 14.5}
V=?\stat{V} = {?}
Text solution
Divide out the sample size NN and the smaller table dimension minus 11Dividing χ2\stat{\chi^2} by N=300N = 300 removes the effect of sample size, and dividing by min⁡(R−1,C−1)=min⁡(3−1,2−1)=1\min(R - 1, C - 1) = \min(3 - 1, 2 - 1) = 1 scales the maximum possible value to 11.
χ2N⋅min⁡(R−1,C−1)\displaystyle \frac{\stat{\chi^2}}{N \cdot \min(R - 1, C - 1)} =14.5300×1\displaystyle = \frac{\stat{14.5}}{300 \times 1} =0.0483\displaystyle = 0.0483
Take the square root to return to unsquared unitsTaking the square root undoes the squaring in χ2\stat{\chi^2} and gives Cramér's V\stat{V}.
V=χ2N⋅min⁡(R−1,C−1)⏟Crameˊr’s V (0 to 1 scale)\displaystyle \underbrace{\stat{V} = \sqrt{\frac{\stat{\chi^2}}{N \cdot \min(R - 1, C - 1)}}}_{\text{Cramér's } \stat{V} \text{ (0 to 1 scale)}} =0.0483≈0.22\displaystyle = \sqrt{0.0483} \approx \stat{0.22}

When min⁡(R−1,C−1)=1\min(R - 1, C - 1) = 1, benchmarks of 0.100.10 (small), 0.300.30 (medium), and 0.500.50 (large) tell us that V=0.22\stat{V} = \stat{0.22} is a small-to-moderate association. And because this was an observational study where students chose their own seats rather than being randomly assigned, the test shows an association in the population, not that moving to the front row causes higher grades.

Let's see what happens to χ2\stat{\chi^2} and Cramér's V\stat{V} when we scale up the sample size NN while keeping the proportion of students in every cell the same.

Copying the exact same lecture hall makes χ2\stat{\chi^2} grow right along with sample size NN, while Cramér's V\stat{V} stays at 0.22\stat{0.22}.

Key concepts

When you see a two-way table, start by checking how the data was collected before writing a single hypothesis. If the researcher took one random sample from a population and recorded two categorical variables on each individual, so only the grand total NN was fixed in advance (like surveying 300300 students on seat location and passing), use the Chi-Square Test for Independence to test whether the two variables are associated in the population (H0:H_0: independent vs. Ha:H_a: not independent / associated). Do not use the Test for Independence when a researcher samples separate groups with fixed group totals in advance (5050 front, 150150 middle, 100100 back) or randomly assigns subjects to treatments; that design calls for the Chi-Square Test for Homogeneity.

Once the design is set, check that the data comes from one random sample of at most 10%10\% of the population (N≤0.10×PopulationN \le 0.10 \times \text{Population}) and that all expected counts E=Row Total×Column TotalGrand Total\expected{E} = \frac{\text{Row Total} \times \text{Column Total}}{\text{Grand Total}} are at least 55 (checking the smallest row and smallest column first, such as 50×120300=20≥5\frac{50 \times 120}{300} = \expected{20} \ge 5). Add the cell components χ2=∑(O−E)2E\stat{\chi^2} = \sum \frac{\gap{(\observed{O} - \expected{E})^2}}{\expected{E}} and compare against df=(R−1)(C−1)df = (R - 1)(C - 1).

If p<α\share{p} < \alphalevel{\alpha} in a table larger than 2×22 \times 2, follow up to find where and how strong the association is (if p≥α\share{p} \ge \alphalevel{\alpha}, stop, because there is no significant association to break down):

Where (Standardized Residuals)

z=O−EE=±Component\gap{z} = \frac{\gap{\observed{O} - \expected{E}}}{\noise{\sqrt{\expected{E}}}} = \gap{\pm\sqrt{\text{Component}}} turns each cell into a zz-score. Only cells beyond ±2\noise{\pm 2} (cell components above 4\noise{4}, like Front Pass z=+4.8=+2.19\gap{z} = \gap{+\sqrt{4.8}} = \gap{+2.19} and Front Fail z=−7.2=−2.68\gap{z} = \gap{-\sqrt{7.2}} = \gap{-2.68}) differ significantly from independence at the 95%\share{95\%} level; cells inside −2\noise{-2} to +2\noise{+2} (like Back Fail z=+0.9=+0.95\gap{z} = \gap{+\sqrt{0.9}} = \gap{+0.95}) could easily be random sampling noise.

How Strong (Cramér's V\stat{V}) and Why

Because scaling a sample by kk multiplies χ2\stat{\chi^2} by kk, divide out NN and the smaller dimension minus 11: V=χ2N⋅min⁡(R−1,C−1)\stat{V} = \sqrt{\frac{\stat{\chi^2}}{N \cdot \min(R - 1, C - 1)}} (for our 3×23 \times 2 table, V=14.5300×1≈0.22\stat{V} = \sqrt{\frac{\stat{14.5}}{300 \times 1}} \approx \stat{0.22}, a small-to-moderate association). And because a single-sample survey is observational, even a tiny p\share{p}-value and a large V\stat{V} show association, never causation.

5

Practice

1

Two researchers each build a 33-by-22 table relating commute method (Walk, Bus, Drive) and arrival status (On Time, Late) for 400400 workers. Researcher A takes one random sample of 400400 workers at a downtown office complex and records both commute method and arrival status for each person. Researcher B takes separate random samples of 100100 walkers, 150150 bus riders, and 150150 drivers and records whether each worker arrived on time or late. Which study calls for a Chi-Square Test for Independence, which totals in its table were fixed before data collection, and what are its null and alternative hypotheses?

Ask which researcher knew the row totals (100,150,150100, 150, 150) before surveying a single worker, and which researcher only knew the grand total (400400).

Researcher A measured two categorical variables on one random sample of 400400 workers, so Researcher A's study calls for a Chi-Square Test for Independence, with only the grand total of 400400 fixed before data collection. (A common mistake is to pick Researcher B or say the row totals of 100,150,100, 150, and 150150 are fixed in an independence test. Fixing group totals across separate samples is what makes Researcher B's study a Test for Homogeneity.) For Researcher A:
H0H_0: Commute method and arrival status are independent (not associated) in this population of office workers.
HaH_a: Commute method and arrival status are not independent (are associated) in this population of office workers.
(Watch out for stating the hypotheses as "the proportions of on-time arrivals are equal across groups". That phrasing belongs to Homogeneity rather than Independence.)
2

A hospital takes one random sample of 250250 emergency-room patients and records arrival shift (Day, Evening, Overnight) and outcome (Admitted, Discharged). In the sample, 4040 arrived during the Day, 110110 in the Evening, and 100100 Overnight; overall, 5050 patients were Admitted and 200200 were Discharged. Find the expected counts for the Day row, determine whether the Large Counts condition is met for the entire table, and find the minimum number of emergency-room patients in the hospital's population required to satisfy the 10%10\% condition.

Find the overall percentage of patients who were Admitted and Discharged out of 250250, apply those percentages to the 4040 Day patients, and check why the Day and Admitted cell is the only one that could possibly fail the ≥5\ge 5 check.

Overall, 50250=20%\frac{50}{250} = \share{20\%} of patients were Admitted and 200250=80%\frac{200}{250} = \share{80\%} were Discharged. Applying those proportions to the 4040 Day patients:
EDay, Admitted=40×50250=8,EDay, Discharged=40×200250=32\displaystyle \begin{aligned} \expected{E_{\text{Day, Admitted}}} &= \frac{40 \times 50}{250} = \expected{8}, \\ \expected{E_{\text{Day, Discharged}}} &= \frac{40 \times 200}{250} = \expected{32} \end{aligned}
Because Day is the smallest row (4040) and Admitted is the smaller column (5050), E=8\expected{E} = \expected{8} is the smallest expected count in the entire table (Evening expected counts are 22\expected{22} and 88\expected{88}; Overnight expected counts are 20\expected{20} and 80\expected{80}). Since all six expected counts are at least 55, the Large Counts condition is met. For the 10%10\% condition, the single random sample of 250250 must be at most 10%10\% of the population (a common mistake is to multiply each row total by 1010 separately and require 400400 Day, 1,1001{,}100 Evening, and 1,0001{,}000 Overnight patients as if there were three separate samples, or to check observed counts instead of expected counts for the ≥5\ge 5 rule):
250≤0.10×Population  ⟹  Minimum population=2,500 patients\displaystyle \begin{aligned} & 250 \le 0.10 \times \text{Population} \\ \implies & \text{Minimum population} \\ & = 2{,}500\text{ patients} \end{aligned}
3

A grocery store surveys one random sample of 200200 shoppers and records payment method (Cash, Card, Mobile Pay) and coupon use (Used Coupon, No Coupon). Overall, 8080 shoppers used a coupon (40%\share{40\%}) and 120120 did not (60%\share{60\%}). The observed counts are: Cash (5050 shoppers): 26\observed{26} Used Coupon, 24\observed{24} No Coupon; Card (100100 shoppers): 28\observed{28} Used Coupon, 72\observed{72} No Coupon; Mobile Pay (5050 shoppers): 26\observed{26} Used Coupon, 24\observed{24} No Coupon. Given expected counts of (20,30)(\expected{20}, \expected{30}) for Cash, (40,60)(\expected{40}, \expected{60}) for Card, and (20,30)(\expected{20}, \expected{30}) for Mobile Pay, calculate all six cell components, the χ2\stat{\chi^2} statistic, and the degrees of freedom, and state the conclusion at α=0.05\alphalevel{\alpha} = \alphalevel{0.05} given p=0.0025\share{p} = \share{0.0025}.

After squaring each difference (O−E)2\gap{(\observed{O} - \expected{E})^2}, be sure to divide each cell by its own expected count E\expected{E} before adding the six components, and use the number of rows and columns, not N−1N - 1, for the degrees of freedom.

First find the differences O−E\gap{\observed{O} - \expected{E}}: (+6,−6)(\gap{+6}, \gap{-6}) for Cash, (−12,+12)(\gap{-12}, \gap{+12}) for Card, and (+6,−6)(\gap{+6}, \gap{-6}) for Mobile Pay. Dividing each squared difference (O−E)2\gap{(\observed{O} - \expected{E})^2} by its expected count E\expected{E} (be careful not to divide by the observed count O\observed{O}, which would give 3626+3624+⋯=12.91\tfrac{36}{26} + \tfrac{36}{24} + \dots = 12.91, or forget to divide by E\expected{E} altogether, which would give 36+36+144+144+36+36=43236 + 36 + 144 + 144 + 36 + 36 = 432):
Cash: 6220=3620=1.8,(−6)230=3630=1.2Card: (−12)240=14440=3.6,12260=14460=2.4Mobile Pay: 6220=3620=1.8,(−6)230=3630=1.2\displaystyle \begin{aligned} \text{Cash: } \frac{\gap{6^2}}{\expected{20}} &= \frac{\gap{36}}{\expected{20}} = \gap{1.8}, \\ \frac{\gap{(-6)^2}}{\expected{30}} &= \frac{\gap{36}}{\expected{30}} = \gap{1.2} \\ \text{Card: } \frac{\gap{(-12)^2}}{\expected{40}} &= \frac{\gap{144}}{\expected{40}} = \gap{3.6}, \\ \frac{\gap{12^2}}{\expected{60}} &= \frac{\gap{144}}{\expected{60}} = \gap{2.4} \\ \text{Mobile Pay: } \frac{\gap{6^2}}{\expected{20}} &= \frac{\gap{36}}{\expected{20}} = \gap{1.8}, \\ \frac{\gap{(-6)^2}}{\expected{30}} &= \frac{\gap{36}}{\expected{30}} = \gap{1.2} \end{aligned}
Summing the six components and finding the degrees of freedom (watch out for using df=R×C=6df = R \times C = 6 or N−1=199N - 1 = 199 instead of (R−1)(C−1)(R - 1)(C - 1)):
χ2=1.8+1.2+3.6+2.4+1.8+1.2=12.0,df=(3−1)(2−1)=2\displaystyle \begin{aligned} \stat{\chi^2} &= \gap{1.8} + \gap{1.2} + \gap{3.6} \\ &\quad + \gap{2.4} + \gap{1.8} + \gap{1.2} = \stat{12.0}, \\ df &= (3 - 1)(2 - 1) = 2 \end{aligned}
Since p=0.0025<α=0.05\share{p} = \share{0.0025} < \alphalevel{\alpha} = \alphalevel{0.05}, we reject H0H_0 and conclude there is convincing statistical evidence of an association between payment method and coupon use in this population of shoppers.
4

In a follow-up analysis to a significant Chi-Square Test for Independence, two cells in different rows both have an observed count that is 10\gap{10} below expected (O−E=−10\gap{\observed{O} - \expected{E}} = \gap{-10}): Cell A has an expected count of E=100\expected{E} = \expected{100}, and Cell B has an expected count of E=16\expected{E} = \expected{16}. Find the standardized residual and the χ2\chi^2 component for each cell, and explain which cell shows a statistically significant departure from independence at the 95%\share{95\%} level.

Divide O−E\gap{\observed{O} - \expected{E}} by E\noise{\sqrt{\expected{E}}} (keeping the negative sign) for the standardized residual, divide (O−E)2\gap{(\observed{O} - \expected{E})^2} by E\expected{E} for the component, and check which cell crosses the ±2\noise{\pm 2} (or component >4> \noise{4}) cutoff.

For Cell A (E=100\expected{E} = \expected{100}) and Cell B (E=16\expected{E} = \expected{16}) (watch out for dividing O−E\gap{\observed{O} - \expected{E}} by E\expected{E} instead of E\noise{\sqrt{\expected{E}}}, which would give −0.10-0.10 and −0.625-0.625, or dropping the minus sign when taking the square root of the component):
Cell A: z=−10100=−1.00,Component=(−10)2100=1.00Cell B: z=−1016=−2.50,Component=(−10)216=6.25\displaystyle \begin{aligned} \text{Cell A: } \gap{z} &= \frac{\gap{-10}}{\noise{\sqrt{\expected{100}}}} = \gap{-1.00}, \\ \gap{\text{Component}} &= \frac{\gap{(-10)^2}}{\expected{100}} = \gap{1.00} \\ \text{Cell B: } \gap{z} &= \frac{\gap{-10}}{\noise{\sqrt{\expected{16}}}} = \gap{-2.50}, \\ \gap{\text{Component}} &= \frac{\gap{(-10)^2}}{\expected{16}} = \gap{6.25} \end{aligned}
Only Cell B shows a statistically significant departure from independence at the 95%\share{95\%} levelbecause its standardized residual of −2.50\gap{-2.50} goes beyond ±2\noise{\pm 2} (specifically ±1.96\noise{\pm 1.96}, or a component above 4\noise{4}), whereas Cell A's residual of −1.00\gap{-1.00} lies well inside the −2\noise{-2} to +2\noise{+2} random sampling noise range.
5

A university surveys one random sample of N=500N = 500 students on class year (44 categories) and housing type (33 categories) and gets χ2=40.0\stat{\chi^2} = \stat{40.0} (p<0.0001\share{p} < \share{0.0001}). (a) Calculate Cramér's V\stat{V} for this 44-by-33 table. (b) If a second university had the exact same proportions in every cell of its 44-by-33 table across a sample of N=2,000N = 2{,}000 students (44 times as large), what would its χ2\stat{\chi^2} statistic and Cramér's V\stat{V} be? (c) Does this result prove that a student's housing type causes changes in retention across class years?

For (a), notice that the table is 44-by-33, so min⁡(R−1,C−1)\min(R - 1, C - 1) is not 11. For (b), trace what multiplying every count by 44 does to (O−E)2E\tfrac{\gap{(\observed{O} - \expected{E})^2}}{\expected{E}} versus V\stat{V}.

(a)The smaller dimension minus 11 is min⁡(4−1,3−1)=min⁡(3,2)=2\min(4 - 1, 3 - 1) = \min(3, 2) = 2 (the most common mistake here is assuming min⁡(R−1,C−1)\min(R - 1, C - 1) is always 11 as in a 3×23 \times 2 table, which gives 40500≈0.283\sqrt{\tfrac{40}{500}} \approx 0.283, or dividing by the full degrees of freedom df=3×2=6df = 3 \times 2 = 6, which gives 403,000≈0.115\sqrt{\tfrac{40}{3{,}000}} \approx 0.115):
V\displaystyle \stat{V} =40.0500×2\displaystyle = \sqrt{\frac{\stat{40.0}}{500 \times 2}} =40.01,000\displaystyle = \sqrt{\frac{\stat{40.0}}{1{,}000}} =0.04\displaystyle = \sqrt{0.04} =0.20\displaystyle = \stat{0.20}
(b)Multiplying every observed and expected count by 44 multiplies (O−E)2\gap{(\observed{O} - \expected{E})^2} by 42=164^2 = 16 and E\expected{E} by 44 (avoid multiplying χ2\stat{\chi^2} by 42=164^2 = 16 to get 640640, or assuming χ2\stat{\chi^2} stays at 40.040.0), so χ2\stat{\chi^2} increases by a factor of 164=4\frac{16}{4} = 4 to χ2=160.0\stat{\chi^2} = \stat{160.0}, while Cramér's V\stat{V} divides out the sample size and stays unchanged at V=0.20\stat{V} = \stat{0.20}. (c) No; because the data comes from a single-sample observational survey where students were not randomly assigned to housing types, the test shows an association in the population, not causation.