Chi-square test (r × c table)
Compares a category or yes/no outcome across three or more independent groups.
Clinical example
Whether the proportion of patients with a wound infection differs between three hospitals.
When to use it
- The outcome is a category or yes/no, one per patient.
- You compare three or more independent groups.
- You don't need to adjust for other variables.
Assumptions to check
Independent observations
Each patient appears in the table once.
Expected counts are not too small
Look at the expected counts per cell. With many small counts, use an exact test (Fisher–Freeman–Halton).
Use the order of ordered groups
If the groups have a natural order, a chi-square test for trend has more power than the general test.
What to report
- n (%) per group
Common mistakes
Ignoring the order of ordered groups, which costs power
A chi-square test on a large table with many small expected counts
Alternatives
| If your situation is… | Use |
|---|---|
| Only two independent groups | Chi-square test |
In your software
# R
tab <- table(d$hospital, d$infection)
chisq.test(tab)
# Small expected counts: exact test
fisher.test(tab) # add simulate.p.value = TRUE for large tables
# Ordered groups: test for trend (events and totals per group)
prop.trend.test(x = c(5, 12, 20), n = c(100, 100, 100))
CROSSTABS
/TABLES=hospital BY infection
/STATISTICS=CHISQ
/CELLS=COUNT EXPECTED ROW.