Mantel-Haenszel's test

A test for k strata of 2x2 tables.
Updated 23 Dec 2010

View License

Performs Mantel-Haenszel's test for k strata of 2x2 tables.
Mantel and Haenszel proposed this asymptotic test based on the chi-2 distribution. Assuming no three-way interaction (k independent strata).

Ref.: DeltaProt toolbox at

X: data matrix (size 2x2xK) of the observed frequency cells, (a,b,c,d) for each stratum k.
tail: desired test ('lt' or 'gt': one-tail; 'ne': two-tailed(default)).


Use: P = MantelHaenTest(Observed,'ne')

Each stratum k must be a 2x2 table design such as:

S Non-S
Sample-1: a b
Sample-2: c d
(S=success; Non-S=failure).

The test has low power for small strata sizes, and one should limit the use to situations where expected cell counts of at least 5 in most of the cells in each stratum (Reis et al. 1999).

The null hypothesis specifies that the success probabilities are equal from stratum to stratum.
In each stratum the two rows can be viewed as data from two independent binomial distributions. If these two probabilities goes in one direction in one strata, and in the oposite direction in other strata, the test will have less power (less ability to detect a false null hypothesis).

Please, use the following reference:
Thorvaldsen, S. , Flå, T. and Willassen, N.P. (2010) DeltaProt: a software toolbox for comparative genomics. BMC Bioinformatics 2010, Vol 11:573.

Other references:
Mantel, N. and Haenszel, W. (1959): Statistical aspects of the analysis of data from retrospective studies of disease. J. National Cancer Inst., 22:719-748.
Hollander, M. and Wolfe, D.A. (1999): Nonparametric Statistical Methods. John Wiley & Sons.
Reis, I.M et al. (1999): Exact and asymptotic tests for homogenity in several 2x2 tables. Statistics in Medicine, 18, p. 893-906.

Cite As

Steinar Thorvaldsen (2024). Mantel-Haenszel's test (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R14SP3
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Genomics and Next Generation Sequencing in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

added new tag