Signature
N_1 = n1_1 + n2_1; N_2 = n1_2 + n2_2; M_1 = a_1 + c_1; M_2 = a_2 + c_2; E_1 = n1_1 * M_1 / N_1; E_2 = n1_2 * M_2 / N_2; V_1 = n1_1 * n2_1 * M_1 * (N_1 - M_1) / (N_1^2 * (N_1 - 1)); V_2 = n1_2 * n2_2 * M_2 * (N_2 - M_2) / (N_2^2 * (N_2 - 1)); D_MH = (a_1 - E_1) + (a_2 - E_2); V_MH = V_1 + V_2; chi2_MH = D_MH^2 / V_MH
| Inputs | Definition | Unit |
|---|---|---|
n1_1 | Patients in the new treatment arm of trial or stratum 1, above 0 | count |
n2_1 | Patients in the comparator arm of trial or stratum 1, above 0 | count |
n1_2 | Patients in the new treatment arm of trial or stratum 2, above 0 | count |
n2_2 | Patients in the comparator arm of trial or stratum 2, above 0 | count |
a_1 | Events in the new treatment arm of trial or stratum 1, at least 0 and at most the arm size | count |
c_1 | Events in the comparator arm of trial or stratum 1, at least 0 and at most the arm size | count |
a_2 | Events in the new treatment arm of trial or stratum 2, at least 0 and at most the arm size | count |
c_2 | Events in the comparator arm of trial or stratum 2, at least 0 and at most the arm size | count |
N_1 | Patients in trial or stratum 1, at least 2 | count |
|---|---|---|
N_2 | Patients in trial or stratum 2, at least 2 | count |
M_1 | Events in both arms of trial or stratum 1 | count |
M_2 | Events in both arms of trial or stratum 2 | count |
E_1 | Expected events in the new treatment arm of stratum 1 given the margins | count |
E_2 | Expected events in the new treatment arm of stratum 2 given the margins | count |
V_1 | Variance of a_1 given the margins of stratum 1 | squared count |
V_2 | Variance of a_2 given the margins of stratum 2 | squared count |
D_MH | Sum over strata of a minus E, negative when the new treatment arm has fewer events than expected | count |
V_MH | Sum over strata of V; must exceed 0 | squared count |
chi2_MH | Test statistic referred to a chi-square distribution on one degree of freedom | none |
Function
Mantel-Haenszel pooling and test of association across stratified two-by-two tables
Maps the cell counts of several two-by-two tables, one per trial or stratum, to a pooled odds ratio, risk ratio or risk difference with its standard error, and to a test of association, while keeping each comparison inside its own stratum. HE-FM-MHM-001 to HE-FM-MHM-003 give the estimators and HE-FM-MHM-004 the Cochran-Mantel-Haenszel statistic, each written out for two strata so that the calculator runs. Their Excel rows take any number of strata, and HE-CF-MHM-001 chains all four for three trials. Another common-effect weighting is the inverse-variance estimate HE-FM-ADMA-001, which HE-FM-PWMA-001 feeds for a risk ratio. The risk difference of one trial is HE-FM-ARR-001 with the sign reversed. Applying a pooled ratio to a baseline probability takes the form of HE-FM-NMA-004 for an odds ratio, written there for a network odds ratio, and is HE-FM-ARR-002 for a risk ratio. Notation follows the Mantel-Haenszel Method article.
Try this function
Implementations
Excel
Excel Cochran-Mantel-Haenszel statistic and p-value from one row per stratum
With the ranges TrialEventsNew, TrialSizeNew, TrialEventsComparator and TrialSizeComparator, one row per stratum, the formulas go in order into ObservedMinusExpectedMH, VarianceSumMH, MantelHaenszelChiSquare and MantelHaenszelPValue. A row left blank returns #DIV/0!, as does a stratum of one patient. No events in any stratum gives a VarianceSumMH of 0 and #DIV/0! in the statistic. HE-SR-CHISQ-005 documents CHISQ.DIST.RT.
=SUMPRODUCT(TrialEventsNew-TrialSizeNew*(TrialEventsNew+TrialEventsComparator)/(TrialSizeNew+TrialSizeComparator)); =SUMPRODUCT(TrialSizeNew*TrialSizeComparator*(TrialEventsNew+TrialEventsComparator)*(TrialSizeNew+TrialSizeComparator-TrialEventsNew-TrialEventsComparator)/((TrialSizeNew+TrialSizeComparator)^2*(TrialSizeNew+TrialSizeComparator-1))); =ObservedMinusExpectedMH^2/VarianceSumMH; =CHISQ.DIST.RT(MantelHaenszelChiSquare,1)
Assumptions
Independent strata with fixed margins for the Cochran-Mantel-Haenszel test
The SAS/STAT documentation states the assumption for the general statistic, that strata are independent and the marginal totals of each stratum are fixed, with a hypergeometric model under the null hypothesis. Each stratum holds at least 2 patients, since V divides by N minus 1. A stratum with no events, or with events in every patient, has V equal to 0 and a minus E equal to 0, so it adds nothing (derived). The statistic is undefined if V_MH is 0.
Large overall sample for the chi-square reference of the Cochran-Mantel-Haenszel test
The chi-square reference is asymptotic. The SAS/STAT documentation states that the statistic requires only a large overall sample size because of its single degree of freedom in this setting, whereas summing the Pearson statistics across strata requires a large sample in each stratum.
Worked examples
Cochran-Mantel-Haenszel statistic of the article's two illustrative trials
The expected drug arm events in the article's illustrative trials are 25 and 86.667, so observed minus expected is -5 and -6.667, with variances of 9.422 and 16.425. The statistic is 136.11 / 25.847 = 5.27, as in the article, with a p-value of about 0.022 on one degree of freedom. R's mantelhaen.test with correct = FALSE returns 5.266 and 0.02175.
a_1 = 20; n1_1 = 100; c_1 = 30; n2_1 = 100; a_2 = 80; n1_2 = 200; c_2 = 50; n2_2 = 100; N_1 = 200; N_2 = 300; M_1 = 50; M_2 = 130; E_1 = 25; E_2 = 86.6667; V_1 = 9.4221; V_2 = 16.4251; D_MH = -11.6667; V_MH = 25.8472; chi2_MH = 5.266
Limiting case of equal risks in both strata of a Cochran-Mantel-Haenszel test
Illustrative trials with a risk of 0.2 in both arms of both strata have observed events equal to expected events, 20 and 40, so the statistic is 0 with a variance sum still above 0. The case checks an implementation.
a_1 = 20; n1_1 = 100; c_1 = 20; n2_1 = 100; a_2 = 40; n1_2 = 200; c_2 = 20; n2_2 = 100; N_1 = 200; N_2 = 300; M_1 = 40; M_2 = 60; E_1 = 20; E_2 = 40; V_1 = 8.0402; V_2 = 10.7023; D_MH = 0; V_MH = 18.7425; chi2_MH = 0
Common errors
Reporting the continuity-corrected Cochran-Mantel-Haenszel statistic without saying so
R's mantelhaen.test has correct = TRUE by default. On the article's trials R then returns 4.8243 with p about 0.028, against 5.266 with p about 0.022 from the formula here. The value 4.8243 is what subtracting 0.5 from the absolute value of D_MH before squaring gives (checked here). A report states which version it used.
Using the Pearson statistic of the collapsed table in place of the stratified test
Collapsing the article's trials gives a Pearson statistic of 2.31 with p about 0.13 (derived), against 5.27 with p about 0.022 when the strata are kept, so the collapsed table misses the association that the stratified test finds.
Summing per-table Pearson statistics and reading them on one degree of freedom
The Pearson statistics of the article's trials, 2.667 and 2.715, add to 5.38 (derived), which the SAS/STAT documentation describes as a similar adjustment that needs a large sample in each stratum and has one degree of freedom per stratum in the two-by-two case. It also ignores direction, so it is not the statistic here even when the values look close.
Expecting the Cochran-Mantel-Haenszel test to detect effects in opposite directions
Observed minus expected counts are added before squaring, so opposing strata cancel. Illustrative trials of 20 of 100 against 30 of 100 and 30 of 100 against 20 of 100 give a minus E of -5 and +5, so D_MH and the statistic are 0, although each table alone gives 2.65 (derived). A low statistic does not show independence within each stratum, and the SAS/STAT documentation cautions that these statistics have low power when some strata show the opposite direction.
Sources
RevMan statistical algorithms for the hypergeometric mean and variance of a table
Deeks JJ, Higgins JPT. Statistical algorithms in Review Manager. Cochrane Statistical Methods Group; May 2022. Section Individual study estimates, dichotomous outcomes, subsection Peto odds ratio. It gives Z as a minus E, with E = n1 (a + c) / N, the expected number of events in the experimental group, and V = n1 n2 (a + c)(b + d) / (N squared (N minus 1)), the hypergeometric variance of a.
SAS/STAT documentation on Cochran-Mantel-Haenszel statistics
SAS Institute. SAS/STAT 13.2 User's Guide, The FREQ Procedure, section Cochran-Mantel-Haenszel Statistics. States the assumption of independent strata with fixed margins, the multiple hypergeometric model under the null hypothesis, low power when some strata show the opposite direction, the generalised statistic as a quadratic form in summed observed minus expected counts with variance multiplier n squared / (n minus 1), and, under General Association Statistic, the reduction to the Pearson chi-square times (n minus 1) / n for one stratum, the comparison with summing Pearson statistics, and the large overall sample size requirement. The form for 2 x 2 x K tables follows from this general statistic with the RevMan mean and variance (derived, and checked against R).
R documentation for mantelhaen.test
R Core Team. mantelhaen.test, Cochran-Mantel-Haenszel chi-squared test for count data, in the R stats package documentation. Describes the null hypothesis that two nominal variables are conditionally independent in each stratum, shows correct = TRUE in the usage line, and describes the argument as applying a continuity correction in the 2 by 2 by K case.
FDA guidance accepting Cochran-Mantel-Haenszel methods for binary endpoints
US Food and Drug Administration. Adjusting for covariates in randomized clinical trials for drugs and biological products. Guidance for industry; May 2023. States that Cochran-Mantel-Haenszel methods (Mantel and Haenszel 1959) are acceptable for binary endpoints if there is interest in estimating a conditional treatment effect assumed constant across subgroups defined by a covariate with a discrete number of levels.
Canonical Identity
Stable URI · Machine-readable · Resolvable · CC BY 4.0
