1. Home
  2. CMHTEST procedure

CMHTEST procedure

Performs the Cochran-Mantel-Haenszel test (D.A. Murray).


PRINT = string token Controls printed output (test); default test
CLASSIFICATION = factors Classifying factors for a DATA variate or classifying factors for the R×C tables in a DATA table
CONTINUITY = string token Continuity correction for 2×2×K Mantel-Haenszel test (correct, none); default corr
CIPROBABILITY = scalar Size of confidence interval for common odds ratio in 2×2×K tables; default 0.95


DATA = tables or variates Data values
STATISTIC = scalars Save the test statistic
PROBABILITY = scalars Save the probability for the test
ODDSRATIO = scalars Save the common odds ratio for the 2×2×K table case
LOWER = scalars Save lower limit of the confidence interval of odds ratio
UPPER = scalars Save upper limit of the confidence interval of odds ratio


CMHTEST performs the Cochran-Mantel-Haenszel test for average partial association between two nominal variables adjusting for control variables. The data are represented by a series of K (R×C) contingency tables, where K represents the strata for the control variables. If there are two or more control variables then these are combined to form a single factor (K) with a level for every combination of the control factors. For the case where there are two dichotomous variables of interest, i.e. a series of K (2×2) tables, CMHTEST calculates the Mantel-Haenszel chi-square statistic, and an overall estimate of relative risk as described in Mantel & Haenszel (1959). Otherwise the Generalized Cochran-Mantel-Haenszel test is used, as in Landis et al. (1978).

The data can be supplied as a table using the DATA parameter where the first two classifying factors of the table indicate the variables of interest, and the remaining factors are combined to form a factor with a level for every combination of the remaining factors. If the first two classifying factors are not the ones of interest, then the CLASSIFICATION option can be used to supply the names of the classifying factors to use. The data can also be supplied in variates, with the CLASSIFICATION option set to the classifying factors and the first two factors in the list indicating the variables of interest. For a series of K (2×2) tables the CONTINUITY option can be used to control whether to apply a continuity correction to the Mantel-Haenszel chi-square test.

The PRINT option controls printed output, with settings:

    test the test statistic and probability, also the common odds ratio and confidence interval when there are K (2×2) tables

A 95% confidence interval is calculated for the common odds ratio, but this can be changed by setting the CIPROBABILITY option to the required value (between 0 and 1).

The test statistic can be saved using the STATISTIC parameter, and the probability can be saved using the PROBABILITY parameter. For a series of K (2×2) tables the odds ratio, lower and upper odds-ratio confidence interval can be saved with the ODDSRATIO, LOWER and UPPER parameters respectively.




For each table i, i = 1…K

ai bi n1i
ci di n2i
m1i m2i Ni

the Mantel-Haenszel Test is calculated by:

MH = ( |( ∑ ai – ∑((n1i × m1i) / Ni) )| – 0.5 )2

/ ∑( (n1i × n2i × m1i × m2i) / (Ni2 × (Ni– 1)) )

where the continuity correction (0.5) is used if option CONTINUITY=correct. The common odds-ratio is calculated by

OR = ∑i=1 to K Ri / ∑i=1 to K Si


Ri = (ai × di) / Ni

Si = (bi × ci) / Ni

The variance for the odds-ratio is estimated using the method outlined in Robins et al. (1986).

The Generalized Cochran-Mantel-Haenszel test is calculated using the method of Landis et al. (1978).

Action with RESTRICT

If a parameter is restricted the statistics will be calculated using only those units included in the restriction.


Landis J,L., Heyman, E,R. & Koch, G.G. (1978). Average Partial Association in Three-way Contingency Tables: a Review and Discussion of Alternative Tests. International Statistical Review, 46, 237-254.

Mantel N. & Haenszel W. (1959). Statistical Aspects of the Analysis of Data From Retrospective Studies of Disease. Journal National Cancer Institute, 22(4), 719-748.

Robins J, Breslow N, & Greenland S. (1986). Estimators of the Mantel-Haenszel variance consistent in both sparse data and large-strata limiting models. Biometrics, 42, 311-323.

See also


Commands for: Basic and nonparametric statistics, Regression analysis.


CAPTION 'CMHTEST example 1',\
        !t('Data from Mantel & Haenszel (1959) Study of women',\
        'with epidermoid and undifferentiated pulmonary carcinoma');\
FACTOR  [LEVELS=2; LABELS=!t('Pulmonary carinoma','Controls')] cases
FACTOR  [LEVELS=2; LABELS=!t('Smoker','Nonsmoker')] Smoke
FACTOR  [LEVELS=4; LABELS=!t('under 45','45-54','55-64','over 65')] Age
FACTOR  [LEVELS=3; LABELS=!t('Housewives','White-collar','Other')] Occupation
TABLE   [CLASS=cases,Smoke,Age,Occupation; MARGINS=no] pulmonary
READ    pulmonary
0 3 1 2 2 4 3 2 0 0 0 1 2 0 0 5 2 1 6 4 6 11 6 3 0 2 3 1 2 1 0 2 1 0 1 0 7 6
10 24 18 12 49 23 19 42 11 15 :
CMHTEST pulmonary
CAPTION 'CMHTEST example 2',\
     !t('Data from Landis, Heyman & Koch (1978) Deaths from leukemia (LD)',\
        'observed at Atomic Bomb Casualty Commission'); STYLE=meta,plain
FACTOR  [NVALUES=60; LEVELS=5; LABELS=!t('0-9','10-19','20-34','35-49',\
        '50+')] Ages; !(12(1...5))
FACTOR  [NVALUES=60; LEVELS=2; LABELS=!t('LD','NLD')] Status; !((6(1,2))5)
FACTOR  [NVALUES=60; LEVELS=6; LABELS=!t('Not in city','0-9','10-49','50-99',\
        '100-199','200+')] Dose; !((1...6)10)
VARIATE [NVALUES=60] Deaths ; !(0,7,3,1,4,11,5015,10752,2989,694,418,387,5,4,\
CMHTEST [CLASS=Dose,Status,Ages] Deaths
Updated on March 8, 2019

Was this article helpful?