unspurious.calculators

Categorical data · Exact 2×2 tests

Fisher's Exact & McNemar Test Calculator

Two exact tests for a 2×2 table. Fisher's exact test compares two independent groups when the counts are too small for chi-square; McNemar's test compares paired before/after data. Both give an exact p-value — no large-sample approximation required.

A 2×2 table of counts: each row is a group, each column an outcome.

Result

In plain English

Both tests ask the same kind of question — is there a real association in this 2×2 table? — but they're exact: instead of leaning on the chi-square approximation (which gets shaky when counts are small), they count the actual probability of tables as lopsided as yours.

Fisher's exact test
Compares two independent groups. It fixes the row and column totals and works out, from the hypergeometric distribution, how often a table this extreme would arise by chance. Valid at any sample size.
two-sided vs one-sided
Two-sided asks “a difference in either direction”; one-sided asks about a specific direction only. Use two-sided unless you have a pre-specified reason not to.
odds ratio
How many times higher the odds of the outcome are in one group than the other. 1 = no association.
McNemar's test
For paired data — the same people before and after, or two raters on the same items. It looks only at the pairs that changed (the discordant cells b and c) and asks whether changes ran one way more than the other.
discordant pairs
The cases that switched: + → − (b) and − → + (c). The cases that stayed the same (a and d) carry no information about change and are ignored.
exact binomial p
For McNemar with few discordant pairs, the honest p-value: the chance of a split this uneven if each change were a coin flip.

Frequently asked

When should I use Fisher's exact test instead of chi-square?

When any expected cell count is small (the usual rule is below 5), where the chi-square approximation is unreliable. Fisher's test computes an exact p-value from the hypergeometric distribution, so it's valid at any size — for large tables it just costs more computation for essentially the same answer.

What's the difference between Fisher's and McNemar's test?

Fisher's compares two independent groups (a standard 2×2). McNemar's is for paired data — the same subjects measured twice, or two raters scoring the same items — and tests only the pairs that changed (the discordant cells).

Why does the odds ratio here differ from R's fisher.test?

This shows the sample odds ratio, (a·d)/(b·c). R's fisher.test reports the conditional maximum-likelihood estimate, which differs slightly — most visibly in small or sparse tables. Both describe the same association; the p-value is unaffected.

What is a 2×2 contingency table?

A 2×2 table cross-classifies items by two yes/no variables — say treatment (yes/no) against outcome (yes/no) — counting how many fall in each of the four cells. It is the smallest table that can show an association between two categorical variables, and it is the input these exact tests are built on, as well as risk ratios, odds ratios and the diagnostic measures of sensitivity and specificity.