shhs = array(c(52, 29, 898, 678, 33, 48, 923, 1722), dim=c(2,2,2))
dimnames(shhs) = list(Residence = c("Rented", "Owner"),
CHD = c("Yes", "No"),
Smoker = c("Yes", "No"))
shhs
## , , Smoker = Yes
##
## CHD
## Residence Yes No
## Rented 52 898
## Owner 29 678
##
## , , Smoker = No
##
## CHD
## Residence Yes No
## Rented 33 923
## Owner 48 1722
mantelhaen.test(shhs, correct=FALSE)
##
## Mantel-Haenszel chi-squared test without continuity correction
##
## data: shhs
## Mantel-Haenszel X-squared = 2.8049, df = 1, p-value = 0.09398
## alternative hypothesis: true common odds ratio is not equal to 1
## 95 percent confidence interval:
## 0.9537528 1.8203312
## sample estimates:
## common odds ratio
## 1.317629
From the note of R documents for mantelhaen.test()
:
“The asymptotic distribution is only valid if there is no three-way interaction. In the classical 2 by 2 by K case, this is equivalent to the conditional odds ratios in each stratum being identical. Currently, no inference on homogeneity of the odds ratios is performed.”