FreeStatisticalTools.com
Lesson 8 of 11 · 15 min

Analyse categorical data with the chi-square test

Test the association between two categorical variables, check expected counts, read adjusted residuals and report Cramér’s V.

When both variables are categorical, means make no sense. The question becomes whether the distribution of one variable differs across the categories of the other. The chi-square (χ²) test of independence answers it by comparing the counts you observed in each cell of a crosstab with the counts you would expect if the two variables were unrelated.

RQ3: is gender associated with using counselling?

Try it in the tool

Is gender associated with using the counselling service?

  1. Rows Gender, columns Counselling, raw data mode.
  2. Check the note under the crosstab: no expected count is below 5.
  3. χ²(1, N = 240) = 8.77, p = .003, Cramér’s V = .19; then read the adjusted residuals.

Step 1: the crosstab

GenderNo counsellingUsed counsellingTotal
Female78 (88.8)56 (45.2)134
Male81 (70.2)25 (35.8)106
Total15981240

Expected counts are in parentheses. They are what the cell would contain if counselling use were the same in both groups: for example, 134 × 81 / 240 = 45.2 female students would have used counselling. In fact 56 did. Converting to row percentages makes the pattern clear: 41.8% of female students (56 of 134) and 23.6% of male students (25 of 106) used counselling.

Step 2: check the assumption

The chi-square test is a large-sample approximation. It needs expected counts of at least 5 in (nearly) every cell: no more than 20% of cells below 5 and none below 1. The tool checks this for you; here the smallest expected count is 35.8, so the assumption is comfortably met. With small expected counts in a 2 × 2 table, use Fisher’s exact test instead.

Step 3: the test and the effect size

Pearson χ²(1, N = 240) = 8.77, p = .003. Gender and counselling use are associated. The degrees of freedom are (rows − 1) × (columns − 1) = 1. The Yates continuity correction (χ² = 7.98, p = .005) is a more conservative version for 2 × 2 tables; most researchers now report the uncorrected Pearson value, but the conclusion is the same.

The effect size for chi-square is Cramér’s V (equal to φ in a 2 × 2 table), which runs from 0 to 1. V = .19 is a small-to-moderate association: for a 2 × 2 table, .10 is small, .30 medium and .50 large. In practical terms, the difference of 18 percentage points between female and male students is substantial for a service planner, even though the association is statistically modest.

Step 4: where is the association?

In larger tables, the overall test does not tell you which cells drive the result. Adjusted standardised residuals do: values beyond ±1.96 mark cells with significantly more (positive) or fewer (negative) cases than expected. Here, female students who used counselling have a residual of +2.96, and male students who used counselling −2.96. In a 2 × 2 table the residuals mirror each other, but in a 4 × 3 table they pinpoint the interesting cells.

Common mistakes

  • Running chi-square on percentages or means instead of counts. The test needs raw frequencies.
  • Counting the same person in several cells, for example with multiple-answer questions. Each case must appear in exactly one cell.
  • Interpreting the association as causal. The design is correlational: women may use counselling more because they experience more stress, because they are more willing to seek help, or for other reasons.
  • Forgetting the effect size. With very large samples, tiny associations become significant.

Writing it up

A chi-square test of independence showed a significant association between gender and counselling use, χ²(1, N = 240) = 8.77, p = .003, Cramér’s V = .19. Female students were more likely to have used the counselling service (41.8%) than male students (23.6%).

Related tests

For a single categorical variable compared with expected proportions (for example, whether the faculty mix matches the university’s), use the chi-square goodness-of-fit test. For two paired categorical measurements (before and after, yes/no), use McNemar’s test. For an ordered outcome with several predictors, consider ordinal logistic regression.

Key takeaways

  • Chi-square compares observed and expected counts in a crosstab.
  • Check that expected counts are at least 5; otherwise use Fisher’s exact test.
  • Report χ²(df, N = …), p and Cramér’s V, and describe the pattern with percentages.
  • Use adjusted residuals beyond ±1.96 to locate the association in larger tables.

Check your understanding

Answer each question to see the explanation. Finishing the quiz marks this lesson as complete.

Q1What does an expected count represent in a chi-square test?
Q2What are the degrees of freedom for a 4 × 3 crosstab?
Q3In a 2 × 2 table, two cells have expected counts below 5. What should you do?
Q4Which statistic expresses the strength of the association?