Tools › Statistics › Health Statistics › Epidemiology Tables › Method
Epidemiology Tables: Method
Open the free Epidemiology 2x2 Tables (Risk and Odds Ratios)
Epidemiology Tables: Risk Ratios, Odds Ratios and Mantel-Haenszel Pooling
The tool takes the four cells of a 2×2 table (exposed and unexposed people, with and without an outcome) and gives the risk ratio, the odds ratio and the risk difference with their confidence intervals and tests. Given one table per stratum (age group, sex, severity), it also pools the strata by the Mantel-Haenszel method and sets the pooled figure beside the crude one, with every sum shown.
The idea: compare like with like
A 2×2 table compares how often an outcome occurs in two groups. If the groups differ in something else that also drives the outcome, the comparison mixes the two effects. Stratifying splits the people into layers that are alike in that other respect, compares exposed with unexposed inside each layer, and then averages the layer-by-layer comparisons. Adding all layers into one table first gives the crude figure; averaging the comparisons made within layers gives the pooled or adjusted figure.

In the figure the exposed group has the higher risk in every stratum, yet the lower risk overall, because most exposed people sit in the low-risk stratum and most unexposed people in the high-risk one. A crude ratio on the other side of 1 from the stratum ratios is called Simpson's paradox. The tool prints the two figures and where the groups sit; whether the stratifying variable ought to be adjusted for is a question about the study (a variable that lies on the path from exposure to outcome, for example, is not adjusted for), and no arithmetic answers it.
The table and the kinds of data
The cells are named as in CDC's Principles of Epidemiology: a = exposed with the outcome, b = exposed without it, c = unexposed with the outcome, d = unexposed without it; N is their sum.
- Cohort study or trial, counts. People are followed and counted: risks, risk ratio, risk difference and odds ratio are all defined.
- Cohort study, person-time. b and d hold the time at risk of each group. The measures are rates, the rate ratio and the rate difference.
- Case-control study. a and c are the cases, b and d the controls. The investigator chooses how many controls to enroll, so a ÷ (a + b) is not a risk. Only the odds ratio is meaningful; when the outcome is rare in the source population it approximates the risk ratio.
- Cross-sectional study. The cohort arithmetic, with prevalence at one moment in place of risk over a follow-up.
The equations: one table
| Quantity | Formula | Note |
|---|---|---|
| Risk (or prevalence) | p1 = a ÷ (a + b), p0 = c ÷ (c + d) | exposed and unexposed |
| Risk ratio | RR = p1 ÷ p0 | 1 means equal risk |
| Its interval | RR × exp(± z √(1/a − 1/(a + b) + 1/c − 1/(c + d))) | normal approximation on the logarithmic scale (Katz et al., 1978); z = 1.960 at 95 % |
| Odds ratio | OR = (a × d) ÷ (b × c) | the cross-product ratio |
| Woolf interval | OR × exp(± z √(1/a + 1/b + 1/c + 1/d)) | needs all four cells above zero |
| Exact interval | the two odds ratios at which the observed a is the α/2 point of the upper and of the lower tail of the conditional distribution of a | margins fixed; two one-sided Fisher tests inverted |
| Cornfield interval | the odds ratios of the two fitted tables whose cell x satisfies |a − x| − ½ = z √(1 ÷ (1/x + 1/(a + b − x) + 1/(a + c − x) + 1/(d − a + x))) | with continuity correction; the interval quoted in CDC's Lesson 6 |
| Risk difference | RD = p1 − p0, interval RD ± z √(p1(1 − p1)/(a + b) + p0(1 − p0)/(c + d)) | in percentage points on the page |
| Number needed to treat or harm | 1 ÷ |RD|, interval 1 ÷ the limits of RD | cohort counts only (Altman, 1998) |
| Attributable fraction, exposed | (RR − 1) ÷ RR for RR above 1 | CDC's attributable proportion |
| Prevented fraction, exposed | 1 − RR for RR under 1 | vaccine effectiveness is this figure |
| Attributable fraction, whole group | (risk of all − p0) ÷ risk of all | equals the share of cases exposed × the fraction among the exposed |
| Chi-square (Pearson) | N (ad − bc)² ÷ ((a + b)(c + d)(a + c)(b + d)) | 1 degree of freedom; Yates: (|ad − bc| − N/2)²; Mantel-Haenszel: × (N − 1)/N |
| Fisher's exact test | sum of the hypergeometric probabilities of all tables with the same margins that are no more probable than the observed one | two-sided |
| Rate, rate ratio | a ÷ b and c ÷ d; IRR = (a ÷ b) ÷ (c ÷ d); interval IRR × exp(± z √(1/a + 1/c)) | person-time data |
| Rate difference | a/b − c/d ± z √(a/b² + c/d²) | person-time data |
The equations: strata pooled
Each stratum i has its own cells and its own Ni. All sums run over the strata.
| Quantity | Formula | Source |
|---|---|---|
| Pooled risk ratio | Σ[a (c + d)/N] ÷ Σ[c (a + b)/N] | Mantel-Haenszel form |
| SE of its logarithm | √(Σ[((a + c)(a + b)(c + d) − a c N)/N²] ÷ (Σ[a (c + d)/N] × Σ[c (a + b)/N])) | Greenland and Robins (1985) |
| Pooled odds ratio | Σ(a d/N) ÷ Σ(b c/N) | Mantel and Haenszel (1959) |
| SE of its logarithm | √(ΣPR/(2(ΣR)²) + Σ(PS + QR)/(2 ΣR ΣS) + ΣQS/(2(ΣS)²)), with P = (a + d)/N, Q = (b + c)/N, R = ad/N, S = bc/N | Robins, Breslow and Greenland (1986) |
| Pooled risk difference | Σ[w (p1 − p0)] ÷ Σw, with w = (a + b)(c + d)/N | Greenland and Robins (1985) |
| Its SE | √(Σ[(a b (c + d)³ + c d (a + b)³) ÷ ((a + b)(c + d) N²)]) ÷ Σw | as given by Deeks and Higgins (2010) |
| Pooled rate ratio | Σ(a d/T) ÷ Σ(c b/T), T = b + d; SE of ln: √(Σ[(a + c) b d/T²] ÷ (Σ(a d/T) × Σ(c b/T))) | Greenland and Robins (1985) |
| Cochran-Mantel-Haenszel test | (Σa − Σ[(a + b)(a + c)/N])² ÷ Σ[(a + b)(c + d)(a + c)(b + d) ÷ (N²(N − 1))] | 1 degree of freedom, no continuity correction |
| Breslow-Day statistic | Σ(a − A)² ÷ V, where A is the cell expected in the stratum under the pooled odds ratio with the margins fixed, and V = 1 ÷ (1/A + 1/B + 1/C + 1/D) of that fitted table | Breslow and Day (1980); strata − 1 degrees of freedom |
| Tarone's correction | Breslow-Day − (Σa − ΣA)² ÷ ΣV | Tarone (1985) |
| Weighted chi-square | Σ(θi − θMH)² ÷ var(θi), θ the logarithm of a ratio or a difference | strata − 1 degrees of freedom |
Why Mantel-Haenszel. The pooled ratio is a weighted average of the stratum ratios whose weights (c (a + b)/N for the risk ratio, b c/N for the odds ratio) need no division by a cell, so a stratum with a zero cell still contributes and many small strata do not break the estimate. Inverse-variance pooling, the other common choice, needs every stratum to be large.
Homogeneity. A pooled figure is a fair summary only if the strata share one underlying value. The tests ask whether the stratum estimates scatter more than chance allows. The answer depends on the measure: risks of 3 % against 2 % and of 30 % against 20 % have the same ratio and very different differences. With few or small strata the tests seldom reach a small p even when the strata truly differ, so the stratum estimates themselves, which the forest plot shows, are part of the result.
Zero cells. With c = 0 the ratio would divide by zero; with a = 0 it is zero and has no logarithm. The page then prints the difference, the exact interval of the odds ratio, the exact tests and the pooled estimates, which need no correction. As an option it adds 0.5 to each cell of such a table before computing that table's ratios, a common convention that pulls the ratio toward 1; results obtained this way are marked.
What it assumes
- Each person is counted once and people are independent of one another. Clustered data (households, classrooms, repeated visits) vary more than these intervals allow.
- Exposure and outcome are classified correctly, and equally well in both groups.
- Within a stratum the exposed and the unexposed are comparable in everything else that drives the outcome. Stratifying controls only the variable entered, and only as finely as the strata are cut.
- For person-time data the rate is constant within each group and stratum over the time observed.
- The logarithmic intervals and chi-square tests are large-sample approximations. The exact methods remove that approximation and keep every other assumption.
When it misleads
- When the crude table is read alone and the groups differ in age, severity or another strong driver of the outcome.
- When a pooled ratio is quoted although the stratum ratios differ: the single number then hides the fact that the association depends on the stratum.
- When an odds ratio is read as a risk ratio although the outcome is common: the odds ratio lies further from 1 (CDC's tuberculosis example: risk ratio 6.1, odds ratio 7.2).
- When strata are cut after looking at the data, or many exposures are tested, and the smallest p-values are reported.
- When a number needed to treat is carried to a setting with a different baseline risk: it is the inverse of a difference, and differences change with the baseline.
- When the stratifying variable is a consequence of the exposure. Adjusting for it removes part of the effect being measured.
Common mistakes
- Entering the table sideways. The exposed group is one row of the form (cells a and b), not a column. Swapping exposure and outcome leaves the odds ratio unchanged and changes the risk ratio.
- Computing a risk ratio from case-control data.
- Adding the strata and calling the result adjusted, or averaging the stratum ratios without weights.
- Reading a wide interval that includes 1 as evidence of no association. It says the data are compatible with no association and with a large one.
- Using the chi-square test when an expected count is under about 5 (the page prints the smallest expected count beside the exact test).
- Forgetting that 1 ÷ 0.039 = 26 needs the difference as a proportion, not in percentage points (1 ÷ 3.9 = 0.26 is wrong).
- Quoting an attributable fraction as the share of cases "caused" by the exposure without the assumption behind it: that the groups differ in nothing else.
Related tools
This tool adds stratified 2×2 analysis, crude against Mantel-Haenszel, to the site's other health statistics tools: Meta-Analysis pools estimates across separate studies, where this page pools across the strata of one study; Age-Adjusted Rates standardizes rates to a reference age distribution; Diagnostic Accuracy and Agreement reads a 2×2 table as test against truth; Hypothesis Tests covers tests of proportions and tables in general; and Logistic Regression and Classification adjusts an odds ratio for several variables at once.
The page describes associations in the entered counts. It is not medical advice.
Open the free Epidemiology 2x2 Tables (Risk and Odds Ratios)