mantelhaen.test(x, y=NULL, z=NULL, correct=T)
x
is an array, the
dim(x)[3]
subtables must each
have dimension 2 by 2, all elements of
x
must
be non-negative.
NA
s and
Inf
s are not allowed.
The elements of array
x
should be whole numbers,
as the test is based on counts; however, since all computations are
carried out to double precision accuracy where possible, the storage mode
of array
x
will be coerced to
"double"
. For restrictions on
x
when
it is a factor or category object, see argument
y
.
x
is an array,
y
and
z
are ignored. If
x
is
a factor or a category object,
y
and
z
are required and must have
the same length as
x
. Factors
x
and
y
must each
have exactly two levels.
NA
s in the factor/category index vectors
are allowed, but triplets
(x[i],y[i],z[i])
containing these will be removed.
Each element of the index vectors of
x
,
y
and
z
should give the membership
of that observation in one of the groups present in the
levels
attributes;
an
NA
in an index vector means that the observation is not in one of
the groups listed for that factor/category object.
Inf
s have no
meaning as indices, and should not be present.
x
,
y
or
z
is not a factor or a category object (and
x
is not an array), it will
be coerced to one implicitly. In this case triplets
(x[i],y[i],z[i])
containing
NA
s
and will be removed, but not those with
Inf
s. Coercion of
x
,
y
and
z
in this manner is intended for datasets of mode
numeric
, whose elements are
typically small integers; data in the form of
character vectors should first be made into either factors or category objects.
TRUE
,
a continuity correction will be applied, but only under certain
conditions. See section DETAILS.
"htest"
, containing the following components:
names
attribute
"Mantel-Haenszel chi-square"
. See section DETAILS for a definition.
statistic
. Component
parameters
has
names
attribute
"df"
.
x
, and of
y
and
z
if all three are factor or category
objects.
A typical application of the Mantel-Haenszel statistic is to test the
null hypothesis that there is no interaction between the variables
corresponding to the categories
x
and
y
at any of the levels of
z
.
This amounts to conditional independence of the
x
and
y
variables.
Bishop, Fienberg and Holland (1980) caution against using the
Mantel-Haenszel statistic
to test this hypothesis when the magnitude of the interaction
between
x
and
y
varies with
z
; it should first be established
that this three-way interaction is zero.
The returned
p.value
should be interpreted carefully. Its validity
depends on the assumption that certain sums of expected cell counts are at
least moderately large; see Fleiss (1981), p. 175
for guidelines. Even when cell counts are adequate, the
chi-square is only a large-sample approximation to the true distribution
of the Mantel-Haenszel statistic under the null hypothesis.
Some attention should also be given to the underlying sampling scheme;
see Fleiss (1981) and Bishop, Fienberg and Holland (1980) for examples.
Under the null hypothesis, the Mantel-Haenszel statistic has an asymptotic chi-square distribution with one degree of freedom.
Bishop, Y. M. M., Fienberg, S. J., and Holland, P. W. (1980).
Discrete Multivariate Analysis: Theory and Practice,
Cambridge, Mass.: The MIT Press.
Fleiss, J. L. (1981).
Statistical Methods for Rates and Proportions,
2nd ed. New York: Wiley.
Snedecor, G. W. and Cochran, W. G. (1980).
Statistical Methods,
7th ed. Ames, Iowa: Iowa State University Press.
# Data from Bishop, Fienberg, Holland, p. 148, response to chemotherapy x <- factor(rep(c(1,2,1,2), c(3,10,15,2)), labels=c("NoResponse", "Reponse")) y <- factor(rep(c(1,2,1,2,1,2,1,2), c(1,2,4,6,12,3,1,1)), labels=c("Male", "Female")) z <- factor(rep(c(1,2), c(13,17)), labels=c("Nodular", "Diffuse")) table(x,y,z) mantelhaen.test(x,y,z) mantelhaen.test(table(x,y,z)) # same thing