mantelhaen.test(x, y=NULL, z=NULL, correct=T)
Conversely, if 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 NAs and will be removed, but not those with Infs. 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.
Under the null hypothesis, the Mantel-Haenszel statistic has an asymptotic chi-square distribution with one degree of freedom.
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.
x # x, y and z are category objects
[1] 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2
attr(, "levels"):
[1] "No Response" "Response"
table(x,y,z) # table from Bishop, Fienberg, Holland, p. 148
, , Nodular
Male Female
No Response 1 2
Response 4 6
, , Diffuse
Male Female
No Response 12 3
Response 1 1
mantelhaen.test(x,y,z)
mantelhaen.test(table(x,y,z)) # same thing