Advanced maths

Mantel Haenszel stratified odds ratio calculator

Combine independent 2×2 strata into a Mantel–Haenszel common odds ratio and CMH association test, preserving zero cells and declared orientation.

Your numbers

Each row is [[a,b],[c,d]]: exposed/unexposed rows and event/no-event columns. 2–50 independent strata; nonnegative whole counts.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Stratified odds-ratio analysis combines binary associations while retaining a declared set of strata. The Mantel–Haenszel ratio weights cross-product contributions by stratum size instead of collapsing every person into a single crude table. The companion CMH test compares the total observed first-cell count with its expectation under no within-stratum association, conditional on row and column margins. This page keeps the ratio and test together and exposes each stratum contribution. It does not decide which variables should define strata or whether adjustment justifies a causal claim.

THE FORMULAOR_MH=Σ(aᵢdᵢ/nᵢ)/Σ(bᵢcᵢ/nᵢ); CMH χ²=(|Σ(aᵢ−Eᵢ)|−correction)₊²/ΣVᵢ.

A worked example

For stratum one, enter a=12,b=8,c=6,d=14; its odds ratio is 12×14/(8×6)=3.5. Stratum two is (18,12,9,21), which has the same ratio. Their Mantel–Haenszel numerator is 12×14/40+18×21/60=10.5, and the denominator is 8×6/40+12×9/60=3.0. The common ratio is therefore 3.5. Reversing only the exposed/unexposed row labels would reciprocate the ratio, so the fixed input orientation is part of the result.

Good to know

2–50 independent strata of nonnegative integer counts up to 1,000,000, each total at least two. No automatic pseudocount: zero, infinite and undefined pooled ratios remain explicit. CMH requires positive total null variance and uses asymptotic chi-square inference, with optional stated continuity correction. A meaningful common odds interpretation assumes suitable association homogeneity. No Breslow–Day heterogeneity test, exact conditional inference, regression adjustment, sampling-weight correction or causal guarantee.

Preserve row and column meaning across every stratum

Every table must use the same exposure and outcome orientation. An odds ratio above one refers to greater event odds in the first row only under that convention. Swapping rows or columns in just one stratum changes the direction of its association and invalidates the intended common interpretation. The output repeats the four entered cells and their cross-product contributions so that an accidental reversal can be checked.

The CMH expectation treats each stratum’s margins as fixed under the no-association null. Its variance includes the finite table-size correction. Strata with no conditional variation can contribute zero variance without being deleted from the ratio automatically. If the entire collection has zero test variance, inference is undefined and the calculator returns an error. The ratio and score test are related summaries, but their denominators are not the same mathematical quantity.

Two consistent stratum cross-product contributions give a common odds ratio of 3.5Stratum 1: 4.2 / 1.2Stratum 2: 6.3 / 1.8Sum numerator: 10.5Sum denominator: 3.0Common odds ratio: 10.5 / 3 = 3.5
Tables (12,8,6,14) and (18,12,9,21) contribute ad/n=4.2,6.3 and bc/n=1.2,1.8. The common ratio is (4.2+6.3)/(1.2+1.8)=3.5. Row/column orientations must agree; no cell pseudocount is added.

An adjusted common ratio is different from a crude pooled ratio

Adding cells across strata before computing ad/bc discards the stratum structure and can change the estimated association, including its apparent direction. Mantel–Haenszel pooling preserves separate cross-products with their size factors. It still relies on a coherent common-effect question: substantially different stratum-specific associations can make a single number unhelpful. The calculator does not infer homogeneity from the fact that a pooled estimate can be computed.

Adding 0.5 to zero cells is a modeling convention, not an invisible arithmetic repair. This page adds no pseudocount and reports an infinite or undefined common ratio when the relevant sums require it. The optional continuity correction applies to the CMH score, not to table cells or the ratio. The Fisher exact two by two calculator tests one table; it does not replace a stratified conditional comparison or resolve confounding merely by being exact.

A few questions, answered

Does the continuity selector add 0.5 to each cell?

No. It subtracts 0.5 from the absolute total CMH score, bounded below by zero, before squaring. The odds-ratio cell contributions remain unchanged.

Can I combine strata with opposite associations?

The arithmetic can run, but a common odds interpretation may be misleading. Inspect the scientific context and effect heterogeneity rather than treating the pooled result as an automatic summary.

Find your calculator

Start typing to explore the library.