## Understanding the SAS conception of CMH test

Solved
Occasional Contributor
Posts: 7

# Understanding the SAS conception of CMH test

Hello everyone,

I've been asked to compute a Cochran-Mantel-Haenszel (CMH) Test on 2 variables. Both variables are usual values (columns) for a high number of observations (lines).

Based on the little Wikipedia page and the Biostat Handbook, I tried to understand what the CMH test is and here is what I understood :

Cochran–Mantel–Haenszel test for repeated tests of independence : Use the Cochran–Mantel–Haenszel test when you have data from 2×2 tables that you've repeated at different times or locations.

Then it seems it should be done over 3 factors : lines, cols and stratas :

There are three nominal variables: the two variables of the 2×2 test of independence, and the third nominal variable that identifies the repeats.

Indeed, in R, the `mantelhaen.test{stats}` function needs 3 factors or a 3 dimensions array which makes sense.

On the other hand, in SAS, you can easily write a 2 factors CMH test :

``PROC FREQ data=MY_DATA;    TABLE VAR1 * VAR2 /CMH; /*or /CHISQ, which give the first MH pvalue too*/    RUN;``

The SAS documentation is not crystal clear about it, and examples are maid over 3 factors, but this 2 dimensions test runs normally and give you 3 statistics and p-values, including a "correlation" one. All stats and pvalues are different from a standard chisquare test.

This SAS doc link gives another definition of the CMH (sorry no anchor, search for "Mantel-Haenszel"), which is not what I understood from wikipedia. It states that :

The Mantel-Haenszel chi-square statistic tests the alternative hypothesis that there is a linear association between the row variable and the column variable. Both variables must lie on an ordinal scale.

But actually, I can run a proc freq with CMH option on 2 character variables with no error. Is it normal ?

I have to compute the CMH test with both R and SAS but I want to know what I am doing.

What is the difference between SAS and common conception of the CMH test ?

Thanks for helping.

Accepted Solutions
Solution
‎02-13-2018 05:03 AM
SAS Employee
Posts: 372

## Re: Understanding the SAS conception of CMH test

The CMH tests provided by PROC FREQ are the same as the CMH tests defined in the statistical literature. The CMH tests generally test for association within a set of tables, where each table represents a stratum.  However, there is no requirement that there is more than one stratum, so it can just as well be used with a single table. In the case of a single table, the CMH correlation test is the same as the Mantel-Haenszel test which is provided by the CHISQ option. The three CMH tests allow for the row and column variables defining each table to have nominal or ordinal scale so that an appropriate hypothesis can be tested. See this note for more on that.

All Replies
Solution
‎02-13-2018 05:03 AM
SAS Employee
Posts: 372

## Re: Understanding the SAS conception of CMH test

The CMH tests provided by PROC FREQ are the same as the CMH tests defined in the statistical literature. The CMH tests generally test for association within a set of tables, where each table represents a stratum.  However, there is no requirement that there is more than one stratum, so it can just as well be used with a single table. In the case of a single table, the CMH correlation test is the same as the Mantel-Haenszel test which is provided by the CHISQ option. The three CMH tests allow for the row and column variables defining each table to have nominal or ordinal scale so that an appropriate hypothesis can be tested. See this note for more on that.

Occasional Contributor
Posts: 7

## Re: Understanding the SAS conception of CMH test

Your note was very interesting, but still the SAS doc talks about linear association, which doesn't make a lot of sense to me with unordered categorical variable. Could you explain a little more please ?
SAS Employee
Posts: 372

## Re: Understanding the SAS conception of CMH test

As shown in the note I referred you to, the row and column variables in each stratum table can be ordinal (ordered levels) or nominal (unordered). If both the row and column variables have multiple possible values, and are ordered (such as low, medium, high), then you might be particularly interested to test whether the column variable increases as the row variable increases. The correlation CMH statistic tests this linear association hypothesis. Obviously, the linear association hypothesis is not of interest if both variables are unordered. In that case you would use the third CMH statistic - the general association statistic.

Highlighted
Super User
Posts: 23,311

## Re: Understanding the SAS conception of CMH test

DanCh wrote:
Your note was very interesting, but still the SAS doc talks about linear association, which doesn't make a lot of sense to me with unordered categorical variable. Could you explain a little more please ?

and the SAS 9.4 Documentation.

The alternative hypothesis for the correlation statistic is that there is a linear association between `X` and `Y` in at least one stratum. If either `X` or `Y` does not lie on an ordinal (or interval) scale, this statistic is not meaningful.

Super User
Posts: 23,311

## Re: Understanding the SAS conception of CMH test

That documentation reference is about twenty years old.

See the latest version which aligns fairly well with what you're stating:

http://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.2&docsetId=procstat&docsetTarget=proc...

Unless you're using SAS 8 for some reason?

Occasional Contributor
Posts: 7

## Re: Understanding the SAS conception of CMH test

Ok I didn't see the version was different (curious though that the test changed over versions). I think I get it now, thank to you two.
Super User
Posts: 23,311

## Re: Understanding the SAS conception of CMH test

I don't think the test changed, I think the documentation did.

And SAS 8 was initially released in 1999.

☑ This topic is solved.

Discussion stats
• 7 replies
• 165 views
• 0 likes
• 3 in conversation