Add the squared gaps.
The campus table already has hypotheses and conditions. What it still needs is a number: the distance from the expected table to the observed one.
That distance is chi-square. Each cell gives a gap. You square the gap, divide by the expected count, and add every piece.
One cell, written as a distance
North students chose in person 74 times. If the three campuses shared one preference distribution, that cell would have been 57.6.
Square the gap so a shortfall and an overshoot both add distance. Divide by 57.6 so a gap of 16.4 is judged against the size of that cell: (16.4)2 / 57.6 = 4.67.
Expected counts come from the margins
E = (row total)(column total) / grand total
Expected counts keep the same row and column totals as the observed table. They are often not whole numbers. A table of tidy integers is a reason to recheck the arithmetic.
χ2 is the sum of every cell piece
χ2 = Σ (O − E)2 / E
The university table is 3 by 3. Nine gaps, nine squares, one total.
Leave a cell out and the distance is wrong. The largest squares sit in the online column: North far below its expected count, South far above.
The online column does most of the walking
Central’s online count sat almost on the expected value. The campuses differ mostly in how many students want online classes. The total 22.825 is already telling you that.
Degrees of freedom pick the curve
df = (rows − 1)(columns − 1) = (3 − 1)(3 − 1) = 4
Do not use n − 1, and do not use the number of cells. Those pick the wrong curve and the wrong p-value.
The p-value is the area to the right
Chi-square lives on the positive line and is skewed right. Larger totals mean a larger departure from the expected table, so evidence is always the right-hand tail.
Five percent of this curve already lies beyond 9.49. The observed 22.825 is farther still. Technology gives p-value = 0.0001.
The p-value is the probability of getting a χ2 at least as large as 22.825, assuming H₀ is true. It is not the probability that H₀ is true.
Finish the campus test in context
| Observed | In person | Hybrid | Online |
| North | 74 | 52 | 34 |
| Central | 46 | 58 | 46 |
| South | 60 | 50 | 80 |
| n = 500 | 180 | 160 | 160 |
| Expected | In person | Hybrid | Online |
| North | 57.6 | 51.2 | 51.2 |
| Central | 54.0 | 48.0 | 48.0 |
| South | 68.4 | 60.8 | 60.8 |
The smallest expected count is 48, so every cell is at least 5.
State. H₀: there is no difference in the distributions of preferred class format among students at the North, Central, and South campuses. Hₐ: there is a difference in those distributions.
Plan. Chi-square test for homogeneity. Independent random samples from each campus, and all nine expected counts are at least 5.
Do. χ2 = 22.825 with df = 4, and p-value = 0.0001.
Conclude. Because the p-value of 0.0001 is less than α = 0.05, we reject H₀. There is convincing statistical evidence that the distributions of preferred class format differ among the students at the North, Central, and South campuses.
Assuming preferred class format is distributed the same way at all three campuses, there is a probability of about 0.0001 of getting a value of χ2 at least as large as 22.825 in samples of these sizes.
Two decisions. Never a third.
p-value < α
Reject H₀. There is convincing evidence of a difference (or of an association) in context.
p-value > α
Fail to reject H₀. There is not convincing evidence of that difference or association.
A test never accepts H₀. Failing to reject says the table is not surprising under the null. It does not establish that the distributions are the same.
Rejection says the distributions differ, or that the two variables are associated. It does not name which campus is higher, and it does not say why.
Same arithmetic. A different sentence.
One random sample of 300 adults, classified by age group and streaming subscription, is a test of independence. The expected counts are 80 and 80 in the first row, 70 and 70 in the second. All are at least 5.
χ2 = 1.800 + 1.800 + 2.057 + 2.057 = 7.714 · df = 1 · p-value = 0.0055
Because the p-value of 0.0055 is less than α = 0.05, we reject H₀. There is convincing statistical evidence of an association between age group and streaming subscription among the adults in this city.
The sample was random, so that sentence generalizes to the city’s adults. It was not an experiment, so nothing here shows that being under 40 causes a person to subscribe.
Three errors that change the answer
-
Percents instead of counts
The statistic is built from observed and expected counts. Row percents change every term.
-
The wrong degrees of freedom
Use (r − 1)(c − 1). Nine cells is not 9 df, and 500 students is not 499 df.
-
Naming a winner
Chi-square reports that the distributions are not all the same. Which cells drive the result comes from the individual (O − E)2/E values, not from the largest observed count.
Try these
Independent random samples of 180 commuters in City A and 220 in City B are classified by primary commute mode. City A: 108 car, 48 transit, 24 bike or walk. City B: 110 car, 82 transit, 28 bike or walk.
-
Compute the expected count for the City A transit cell, showing the formula.
Show the expected count
Column total for transit is 48 + 82 = 130. Grand total is 400. E = (180)(130) / 400 = 58.5.
-
Give the degrees of freedom and verify the large-counts condition.
Show df and the check
df = (2 − 1)(3 − 1) = 2. The six expected counts are 98.1, 58.5, 23.4 for City A and 119.9, 71.5, 28.6 for City B. The smallest is 23.4, so every expected count is at least 5.
-
The chi-square statistic for this table is 5.271. Find the p-value and state the decision at α = 0.05.
Show the p-value and decision
With df = 2, the p-value is about 0.072. Because 0.072 is greater than α = 0.05, we fail to reject H₀.
-
Write a complete conclusion in context, then explain what the study may and may not claim about the two cities.
Show the conclusion
Because the p-value of 0.072 is greater than α = 0.05, we fail to reject H₀. There is not convincing evidence that the distributions of primary commute mode differ for commuters in City A and City B.
The samples were random, so the result can be generalized to commuters in the two cities. The study is not an experiment, so it does not show that living in one city causes a commute mode. Failing to reject H₀ does not accept the claim that the distributions are the same.
A χ2 of 5.271 with df = 2 and α = 0.05. Do you reject H₀, or fail to reject it? What sentence do you write about the two cities?