When you want to know whether two categorical variables are associated — gender and brand preference, education level and voting behavior, location and customer satisfaction — the chi-square test is the right tool. Here's the methodology with a concrete example.
In surveys we often collect categorical data — gender, age group, education level, brand preference, voting choice, place of residence. The obvious question in analysis is often: are two of these variables associated? Do men really prefer Brand A more often than women? Does place of residence correlate with voting preference? This is where the chi-square test comes in.
Unlike the t-test, which compares means, the chi-square test examines frequencies. If you've collected two variables each in categories, you can use a crosstab to calculate whether the observed frequency distributions deviate from statistical chance.
What does the chi-square test examine?
The logic is surprisingly simple: you count how often each combination of two variables actually occurs, and compare these actual frequencies with the frequencies you'd expect if the two variables were completely independent of each other. If the deviations are small, the variables are probably independent. If they're large, there's an association.
The chi-square value quantifies exactly this deviation. The larger it is, the more the observed frequencies deviate from the expected ones — and the less likely it is that this deviation arose purely by chance.
Eligibility
Before you calculate, check three points. First, both variables must be categorical (nominal or ordinal — for continuous variables, use the t-test or correlation). Second, the observations must be independent: a person may appear only once in the table. Third, no cell may have an expected frequency below 5 — otherwise, with small samples or many categories, the test becomes unreliable. Rule of thumb: at most 20% of cells may have expected values below 5, and none may be at zero or below.
If the last requirement is violated, there are fallback options: combine categories (two sparsely populated age classes become one), exact tests (Fisher's exact test for 2×2 tables), or other methods.
Step 1: Set up the crosstab
Imagine this: in a customer survey you asked 200 people whether they prefer our brand (Brand A) or the competitor brand (Brand B) — broken down by gender. The data look like this:
| Beobachtet | Männer | Frauen | Zeilensumme |
|---|---|---|---|
| Marke A | 52 | 38 | 90 |
| Marke B | 48 | 62 | 110 |
| Spaltensumme | 100 | 100 | 200 |
At first glance it looks as if men prefer Brand A and women prefer Brand B. But is this distribution systematic or simply sampling variation?
Step 2: Calculate the expected frequencies
If gender and brand preference were actually independent, the frequencies would have to split proportionally to the overall distribution. 90 of 200 respondents prefer Brand A overall — that's 45%. If gender plays no role, 45% in each gender group would have to prefer Brand A.
Here Rᵢ is the row total of the cell, Cⱼ the column total, and N the grand total. For the men–Brand-A cell: (90 × 100) ÷ 200 = 45.
The complete table of expected frequencies looks like this:
| Erwartet (bei Unabhängigkeit) | Männer | Frauen |
|---|---|---|
| Marke A | 45 | 45 |
| Marke B | 55 | 55 |
Step 3: Calculate the chi-square value
For each cell you calculate the squared deviation of the observed from the expected frequency, divided by the expected frequency. Then you sum over all cells.
Here O stands for the observed and E for the expected frequency per cell. In our example: (52−45)² ÷ 45 + (38−45)² ÷ 45 + (48−55)² ÷ 55 + (62−55)² ÷ 55 = 1.089 + 1.089 + 0.891 + 0.891 ≈ 3.96.
Step 4: Degrees of freedom and significance level
The calculated chi-square value alone is not yet meaningful — it must be compared with a critical value that takes two reference quantities into account.
Degrees of freedom. For a crosstab they are calculated as (number of rows − 1) × (number of columns − 1). For a 2×2 table like ours: (2−1) × (2−1) = 1 degree of freedom. For a 3×4 table it would be 6.
Significance level. Usually 5% (that is, α = 0.05), and in particularly sensitive studies 1%. This is the accepted probability of error for wrongly rejecting the independence hypothesis.
In our example: 1 degree of freedom, α = 0.05 → critical value 3.841. Our calculated chi-square value of 3.96 lies just above it. The null hypothesis "gender and brand preference are independent" is rejected. There is a statistically significant association.
Step 5: Assess the strength of the association
Statistical significance only tells you whether an association exists — not how strong it is. With large samples, even very small effects become significant. For the effect size, you use complementary measures:
Phi coefficient (for 2×2 tables) or Cramér's V (for larger tables). Values around 0.1 count as a weak association, around 0.3 as moderate, and from 0.5 on as strong. In our example, Cramér's V is roughly 0.14 — a weak association that, despite significance, should not lead to a marketing about-face.
When the chi-square test doesn't fit
The chi-square test is limited to two categorical variables. As soon as you want to examine more than two variables at once (gender × age group × brand preference), you need log-linear models. If one of the variables is ordinal and you want to factor in the ordering (rather than ignore it), consider the Mantel-Haenszel test or ordinal regression.
And as mentioned above: with small expected frequencies, switch to Fisher's exact test. It's mathematically more elegant, but computationally more demanding to analyze — modern statistics packages handle this automatically.
Conclusion
The chi-square test is the standard tool for analyzing associations between categorical variables. It's methodologically simple, intuitively understandable, and available in any statistics software. What matters is not to treat it as the endpoint: significance alone says nothing about practical relevance. Only with a complementary effect size (phi, Cramér's V) does a complete picture emerge.
In QUESTIONSTAR you create crosstabs with two clicks right in the analysis view — the chi-square value, the p-value, and Cramér's V are calculated and displayed automatically.
Sources
- Bortz, Jürgen, and Nicola Döring: Forschungsmethoden und Evaluation für Human- und Sozialwissenschaftler. 4th edition. Springer, 2006.
- Agresti, Alan: An Introduction to Categorical Data Analysis. 3rd Edition. Wiley, 2018.
- Field, Andy: Discovering Statistics Using IBM SPSS Statistics. 5th Edition. SAGE, 2018.
