Generalized Cochran-Mantel-Haenszel Tests
Provides generalized Cochran-Mantel-Haenszel tests of association of two possibly ordered factors,
optionally stratified other factor(s). With strata, CMHtest
calculates these tests for
each level of the statifying variables and also provides overall tests controlling for the
strata.
For ordinal factors, more powerful tests than the test for general association (independence) are obtained by assigning scores to the row and columm categories.
CMHtest(x, ...) ## S3 method for class 'formula' CMHtest(formula, data = NULL, subset = NULL, na.action = NULL, ...) ## Default S3 method: CMHtest(x, strata = NULL, rscores = 1:R, cscores = 1:C, types = c("cor", "rmeans", "cmeans", "general"), overall=FALSE, details=overall, ...) ## S3 method for class 'CMHtest' print(x, digits = max(getOption("digits") - 2, 3), ...)
x |
A 2+ way contingency table in array form, or a class |
formula |
a formula specifying the variables used to create a contingency table from |
data |
either a data frame, or an object of class |
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when the data contain |
strata |
For a 3- or higher-way table, the names or numbers of the factors to be treated as strata. By default, the first 2 factors are treated as the main table variables, and all others considered stratifying factors. |
rscores |
Row scores. Either a set of numbers (typically integers, |
cscores |
Column scores. Same as for row scores. |
types |
Types of CMH tests to compute: Any one or more of
|
overall |
logical. Whether to calculate overall tests, controlling for the stratifying factors. |
details |
logical. Whether to include computational details in the result |
... |
Other arguments passed to default method. |
digits |
Digits to print. |
The standard χ^2 tests for association in a two-way table treat both table factors as nominal (unordered) categories. When one or both factors of a two-way table are quantitative or ordinal, more powerful tests of association may be obtained by taking ordinality into account using row and or column scores to test for linear trends or differences in row or column means.
The CMH analysis for a two-way table produces generalized Cochran-Mantel-Haenszel statistics (Landis etal., 1978).
These include the CMH correlation statistic ("cor"
),
treating both factors as ordered.
For a given statum, with equally spaced row and column scores,
this CMH statistic reduces to (n-1) r^2,
where r is the Pearson correlation between X and Y.
With "midrank"
scores, this CMH statistic is analogous
to (n-1) r_S^2, using the Spearman rank correlation.
The ANOVA (row mean scores and column mean scores) statistics,
treat the columns and rows respectively as ordinal,
and are sensitive to mean shifts over columns or rows.
These are transforms of the F statistics from one-way ANOVAs
with equally spaced scores and to Kruskal-Wallis tests with
"midrank"
scores.
The CMH general association statistic treat both factors as unordered,
and give a test closely related to the Pearson χ^2 test.
When there is more than one stratum, the overall general CMH statistic
gives a stratum-adjusted Pearson χ^2,
equivalent to what is calculated by mantelhaen.test
.
For a 3+ way table, one table of CMH tests is produced for each
combination of the factors identified as strata
.
If overall=TRUE
, an additional table is calculated for
the same two primary variables, controlling for (pooling over)
the strata
variables.
These overall tests implicitly assume no interactions between the primary variables and the strata and they will have low power in the presence of interactions.
An object of class "CMHtest"
, a list with the following 4 components:
table |
A matrix containing the test statistics, with columns
|
names |
The names of the table row and column variables |
rscore |
Row scores |
cscore |
Column scores |
If details==TRUE
, additional components are included.
If there are strata, the result is a list of "CMHtest"
objects.
If overall=TRUE
another component, labeled ALL
is appended to the list.
Michael Friendly
Stokes, M. E. & Davis, C. S. & Koch, G., (2000). Categorical Data Analysis using the SAS System, 2nd Ed., Cary, NC: SAS Institute, pp 74-75, 92-101, 124-129. Details of the computation are given at: http://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_freq_a0000000648.htm
Cochran, W. G. (1954), Some Methods for Strengthening the Common χ^2 Tests, Biometrics, 10, 417-451.
Landis, R. J., Heyman, E. R., and 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. (1963), Chi-square Tests with One Degree of Freedom: Extensions of the Mantel-Haenszel Procedure," Journal of the American Statistical Association, 58, 690-700.
mantelhaen.test
provides the overall general
Cochran-Mantel-Haenszel chi-squared test of the null that two nominal variables are conditionally independent
in each stratum, assuming that there is no three-way interaction
data(JobSat, package="vcdExtra") CMHtest(JobSat) CMHtest(JobSat, rscores="midrank", cscores="midrank") # formula interface CMHtest(~ ., data=JobSat) # A 3-way table (both factors ordinal) data(MSPatients, package="vcd") CMHtest(MSPatients) # also calculate overall tests, controlling for Patient CMHtest(MSPatients, overall=TRUE) # compare with mantelhaen.test mantelhaen.test(MSPatients) # formula interface CMHtest(~ ., data=MSPatients, overall=TRUE) # using a frequency data.frame CMHtest(xtabs(Freq~ses+mental, data=Mental)) # or, more simply CMHtest(Freq~ses+mental, data=Mental) # conditioning formulae CMHtest(Freq~right+left|gender, data=VisualAcuity) CMHtest(Freq ~ attitude+memory|education+age, data=Punishment) # Stokes etal, Table 5.1, p 92: two unordered factors parties <- matrix( c(221, 160, 360, 140, 200, 291, 160, 311, 208, 106, 316, 97), nrow=3, ncol=4, byrow=TRUE) dimnames(parties) <- list(party=c("Dem", "Indep", "Rep"), neighborhood=c("Bayside", "Highland", "Longview", "Sheffield")) CMHtest(parties, rscores=NULL, cscores=NULL) # compare with Pearson chisquare chisq.test(parties)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.