Ask Mallard

Chi-square and Fisher's exact test

A chi-square test compares the counts observed in a contingency table with the counts expected if the two variables were unrelated.

What question does this help answer?

Whether the distribution of a categorical outcome differs across categories of another variable, for instance whether complication rates differ between two techniques.

Which test

  • Pearson chi-square: independent groups, adequate expected counts.
  • Fisher's exact test: small expected counts, where the chi-square approximation is unreliable. The old rule of thumb is an expected count under 5 in any cell.
  • McNemar's test: PAIRED binary data, such as the same patients tested twice or matched pairs. It uses only the discordant pairs, which is precisely the information the ordinary chi-square discards.
  • Chi-square test for trend: an ordered exposure, where treating the categories as unordered wastes the ordering.

The test is the beginning, not the answer

Report a risk difference, a risk ratio or an odds ratio with a confidence interval alongside the p-value. For a single proportion use a Wilson or Clopper-Pearson interval rather than the normal approximation, which behaves badly near 0 and 1 and can produce a bound outside the possible range.

Why Mallard may recommend it

Mallard may name a chi-square test for a simple comparison of proportions, and will move to logistic regression as soon as adjustment for other variables is needed.

What to watch out for

These tests answer whether an association exists and say nothing about its size or direction, so a table reported with a p-value and no risk difference or ratio has withheld the clinically useful part. Fisher's exact test is not simply the small-sample upgrade it is usually described as: it is conservative, and its exactness is conditional on the margins. And paired categorical data need McNemar's test, not the ordinary chi-square, which treats the paired observations as independent.

Larger tables

A significant test on a table bigger than 2x2 says only that the table is not uniform. Standardised residuals show WHERE the departure is, and a prespecified partition of the table is more interpretable than scanning all the cells afterwards.

Clinical example

Question: Does wound infection differ between two skin preparations? Analysis: Chi-square for the test, reported with the risk difference and its confidence interval, since a two percentage point difference and a twenty point difference can share a p-value.

Code for this method
Loading…
Recent studies that used this
Searching PubMed…
Related Learn pages
Sources & further reading
  1. The chi-square test of independence (opens in a new tab) · Biochem Med (Zagreb) · doi 10.11613/bm.2013.018
  2. Nonparametric statistical tests for the continuous data: the basic concept and the practical use (opens in a new tab) · Korean J Anesthesiol · doi 10.4097/kjae.2016.69.1.8
Last source review: 2026-09-06
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.