# Cochran–Mantel–Haenszel statistics

In statistics, the Cochran–Mantel–Haenszel test (CMH) is a test used in the analysis of stratified or matched categorical data. It allows an investigator to test the association between a binary predictor or treatment and a binary outcome such as case or control status while taking into account the stratification. Unlike the McNemar test, which can only handle pairs, the CMH test handles arbitrary strata sizes. It is named after William G. Cochran, Nathan Mantel and William Haenszel. Extensions of this test to a categorical response and/or to several groups are commonly called Cochran–Mantel–Haenszel statistics. It is often used in observational studies in which random assignment of subjects to different treatments cannot be controlled but confounding covariates can be measured.

## Definition

We consider a binary outcome variable such as case status (e.g. lung cancer) and a binary predictor such as treatment status (e.g. smoking). The observations are grouped in strata. The stratified data are summarized in a series of 2 × 2 contingency tables, one for each stratum. The i-th such contingency table is:
| | Treatment | No treatment | Row total |
| Case | A$_i$ | B$_i$ | N$_{1i}$ |
| Controls | C$_i$ | D$_i$ | N$_{2i}$ |
| Column total | M$_{1i}$ | M$_{2i}$ | T$_i$ |
The common odds-ratio of the K contingency tables is defined as:
    $R={{\sum _{i=1}^{K}{\frac {A_{i}D_{i}}{T_{i}}}} \over {\sum _{i=1}^{K}{B_{i}C_{i} \over T_{i}}}},$
The null hypothesis is that there is no association between the treatment and the outcome. More precisely, the null hypothesis is $H_{0}:R=1$ and the alternative hypothesis is $H_{1}:R\neq 1$. The test statistic is:
    $\xi _{\text{CMH}}={\frac {\left[\sum _{i=1}^{K}\left(A_{i}-{\frac {N_{1i}M_{1i}}{T_{i}}}\right)\right]^{2}}{\sum _{i=1}^{K}{N_{1i}N_{2i}M_{1i}M_{2i} \over T_{i}^{2}(T_{i}-1)}}}.$
It follows a chi-squared distribution asymptotically with 1 degree of freedom under the null hypothesis.

## Subset stability

The standard odds- or risk ratio of all strata could be calculated, giving risk ratios $r_{1},r_{2},\dots ,r_{n}$, where $n$ is the number of strata. If the stratification were removed, there would be one aggregate risk ratio of the collapsed table; let this be $R$.
One generally expects the risk of an event unconditional on the stratification to be bounded between the highest and lowest risk within the strata (or identically with odds ratios). It is easy to construct examples where this is not the case, and $R$ is larger or smaller than all of $r_{i}$ for $i\in 1,\dots ,n$. This is comparable but not identical to Simpson's paradox, and as with Simpson's paradox, it is difficult to interpret the statistic and decide policy based upon it.
Klemens defines a statistic to be subset stable iff $R$ is bounded between $\min(r_{i})$ and $\max(r_{i})$, and a well-behaved statistic as being infinitely differentiable and not dependent on the order of the strata. Then the CMH statistic is the unique well-behaved statistic satisfying subset stability.

## Related tests

* The McNemar test can only handle pairs. The CMH test is a generalization of the McNemar test as their test statistics are identical when each stratum shows a pair.
* Conditional logistic regression is more general than the CMH test as it can handle continuous variable and perform multivariate analysis. When the CMH test can be applied, the CMH test statistic and the score test statistic of the conditional logistic regression are identical.
* Breslow–Day test for homogeneous association. The CMH test supposes that the effect of the treatment is homogeneous in all strata. The Breslow-Day test allows to test this assumption. This is not a concern if the strata are small e.g. pairs.