For when your data are categories, not numbers.
Every test you've learned — t, r, F — needs a mean. But some of the most interesting variables have no mean at all: diet, major, yes-or-no, on-campus vs. off. You can't average "vegan." What you can do is count — and the chi-square (χ²) test is the tool built for counts. This bonus unit adds the last piece to your toolkit: one test for "do these counts match a claim?" and one for "are these two category variables related?" Same hypothesis-testing rhythm you already know; brand-new kind of data.
Look back at what every test in this course has eaten for breakfast: means. The t-tests compared means. ANOVA compared means. Even correlation needed two columns of numbers you could average. That works because sleep hours, stress scores, and compassion ratings are quantitative — averaging them makes sense.
But plenty of variables are nominal — pure categories, straight from Unit 1: diet (omnivore / vegetarian / vegan), gender, class year, commuter vs. resident, "did they choose the plant-based option — yes or no?" There is no such thing as the mean diet. All you can do with a nominal variable is count how many people land in each box — and it turns out that's enough. The chi-square test asks one question, in two flavors:
No means? Count the boxes. Chi-square compares the counts you got to the counts you'd expect if nothing interesting were going on — and asks whether the mismatch is bigger than chance.
Here's a real question about our own class. National surveys put the U.S. adult diet mix at roughly 90% omnivore, 7% vegetarian, 3% vegan. Our SJNY Student Life dataset has 200 students. If our class were just a miniature copy of the nation, the 200 students should split about the same way. Do they?
| Diet | Observed (our class) | National claim |
|---|---|---|
| Omnivore | 136 | 90% |
| Vegetarian | 46 | 7% |
| Vegan | 18 | 3% |
That's the goodness-of-fit setup: one categorical variable, a set of observed counts, and a claimed distribution to test them against. The null hypothesis is that the claim is true — our class fits the national mix, and any mismatch is sampling noise. The alternative: the class genuinely differs from the claim.
To compare counts to a claim, first turn the claim into counts. Each expected count is just the claimed percentage applied to your N:
E = (claimed proportion) × N
Omnivore: .90 × 200 = 180
Vegetarian: .07 × 200 = 14
Vegan: .03 × 200 = 6
Line them up and the drama is already visible — we observed 46 vegetarians where the nation predicts 14, and 18 vegans where it predicts 6:
| Diet | Observed (O) | Expected (E) |
|---|---|---|
| Omnivore | 136 | 180 |
| Vegetarian | 46 | 14 |
| Vegan | 18 | 6 |
First, expected counts don't have to be whole numbers — an E of 14.5 people is fine; it's a long-run average, not a head count. Second, the E's must add to the same N as the O's (180 + 14 + 6 = 200 ✓). If they don't, your percentages were off before the test even started.
Now one number measures how badly the observed counts miss the expected ones. For each category: take the miss (O − E), square it (so misses in either direction count, and big misses count a lot), and divide by E (a miss of 10 matters more when you expected 6 than when you expected 180). Then add up the categories:
χ² = Σ (O − E)² ÷ E
Worth pausing on why that's plausible rather than alarming: a psychology statistics course at a New York college is not a random draw of American adults. Selection tells the story — and the test just told us, precisely, that selection is real here. To the extent that your sample isn't drawn like the claim's population, goodness of fit will notice.
Chi-square's df comes from categories, not people — a common trip-up. With the totals fixed, only so many cells are free to vary:
| Test | Formula | Our examples |
|---|---|---|
| Goodness of fit | df = k − 1 | 3 diets → df = 2 |
| Independence | df = (rows − 1)(cols − 1) | 2×2 table → df = 1 |
The decision works exactly like F: χ² can't go below zero (every term is squared), so all the action is in the upper tail. Small χ² = counts near expectations = nothing to report. Big χ² = counts far from expectations = reject. The usual critical values you'll bump into: 3.84 for df = 1 and 5.99 for df = 2, at α = .05. And say it the way you've said it all semester: "fail to reject," never "accept."
Chi-square is trustworthy when every expected count is at least about 5. (Observed counts can be anything — it's the E's that matter.) Small expected counts make the χ² approximation shaky — the fix is bigger samples or merged categories. Our vegan E of exactly 6 squeaks by; the calculators below flag any violation for you. And one more habit: chi-square needs raw counts, never percentages — feeding it "68%" instead of "136 of 200" breaks the arithmetic.
The second flavor crosses two categorical variables. Here's a question with a stereotype riding on it: is diet related to gender? Pop culture says yes — meat is coded masculine (remember Unit 6's masculinity × meat_commitment correlation of +.35), so you might expect the women in our class to be likelier than the men to skip meat. Count everyone into a 2×2 contingency table (diet collapsed to omnivore vs. "veg" — vegetarian or vegan; the 20 non-binary students form too small a group for stable expected counts here, so we compare the 180 men and women):
| Observed | Omnivore | Veg (any) | Total |
|---|---|---|---|
| Man | 54 | 26 | 80 |
| Woman | 68 | 32 | 100 |
| Total | 122 | 58 | 180 |
The null hypothesis: the two variables are independent — knowing someone's gender tells you nothing about their diet. Independence makes a precise prediction for every cell, built from the margins: E = (row total × column total) ÷ N. Men-omnivore: 80 × 122 ÷ 180 ≈ 54.2. Compare that to the observed 54… and you can already feel where this is going. Every observed count sits almost exactly on its expected count:
χ²(1, N = 180) = 0.01, p = .94
Fail to reject. In our class, diet and gender are as close to perfectly independent as real data ever get — men and women skip meat at essentially the same rate (32.5% vs. 32.0%). The stereotype made a testable prediction; the counts shrugged. That's the discipline working exactly as designed: a non-significant result is informative when it contradicts a confident cultural claim. (One class of 200 isn't the last word — but notice that "everyone knows" wasn't evidence.)
Both flavors, live on the page. Hit Load class data in each to reproduce this unit's two examples — the diet mix that crushed the national claim, and the gender × diet table that didn't budge.
Unit 15. Do your observed counts match a claimed distribution? Demo: our class's diet mix vs. the national 90/7/3 split.
Unit 15. Are two categorical variables related? Demo: gender × diet in our class data.
Chi-square's APA (7th ed.) sentence has one twist: because the df alone doesn't reveal the sample size (it comes from categories, remember), the N rides inside the parentheses:
χ²(df, N = total) = value, p = value
"The class's diet distribution differed significantly from the national distribution, χ²(2, N = 200) = 107.90, p < .001, with vegetarians and vegans overrepresented relative to national rates."
"Diet was not significantly related to gender, χ²(1, N = 180) = 0.01, p = .943."
Same house rules as Units 10–14: italicized letters, two decimals on the statistic, no leading zero on p, "< .001" instead of "= .000," and a plain-English clause saying what the numbers mean — overrepresented where, related to what. A statistics sentence with no story attached is only half a result.
Sheets speaks fluent chi-square. Get your observed counts with COUNTIF, build the expected counts with plain arithmetic, and one function returns the p-value:
=COUNTIF(X2:X201, "Vegan") → observed count per category
=0.03 * 200 → expected count per category (claim × N)
=CHISQ.TEST(obs_range, exp_range) → the p-value, directly
For the test of independence, lay out the 2×2 observed table, build the matching expected table with = row_total * col_total / N in each cell, and point CHISQ.TEST at both ranges. If you have the χ² statistic and want the p (or vice versa):
=CHISQ.DIST.RT(107.9, 2) → p for a given χ² and df
=CHISQ.INV.RT(0.05, 2) → the critical χ² (5.99 for df = 2)
(SPSS note for your future research-methods self: Analyze ▸ Descriptive Statistics ▸ Crosstabs, tick Chi-square under Statistics — the whole independence test, expected counts included, in one dialog.)
Counts, never percentages or means — chi-square eats whole-number tallies of people in categories. df comes from categories, not people: k − 1 for goodness of fit, (r − 1)(c − 1) for independence — and the N goes inside the APA parentheses precisely because df won't reveal it. Check the rule of 5 on the expected counts. χ² is never negative, so it's always an upper-tail test. A significant independence test says the variables are related — it doesn't say which direction or how strongly, and (chorus, everyone) it doesn't say why: relatedness isn't causation. And when χ² comes up small, say "fail to reject" — the counts matching the claim is not proof the claim is true.
Ten quick true/false items with instant explanations. Real practice — this bonus unit won't appear on Exam 4, but these ideas turn up constantly in published research.