
Mantel-Haenszel test and confidence interval
Source:R/obs-exact-tests.R
epi_mantel_haenszel_test.RdCalculates the asymptotic Cochran-Mantel-Haenszel test for conditional
association between binary exposure and outcome given strata, together with
the Mantel-Haenszel common odds ratio and its approximate confidence interval.
correction=TRUE applies the continuity correction to the test statistic.
Assumes independent records and a sufficiently informative set of strata;
the common odds ratio is most interpretable when stratum odds ratios are
reasonably homogeneous. The test itself does not test homogeneity, adjust for
other confounders, or establish causality.
Usage
epi_mantel_haenszel_test(
.data,
exposure,
outcome,
strata,
correction = FALSE,
conf_level = 0.95
)Value
An epi_result tibble with common odds ratio, confidence limits,
chi-squared statistic, p-value and number of strata.
Examples
d <- data.frame(e = rep(c(0, 0, 1, 1), 2), y = rep(c(0, 1, 0, 1), 2), s = rep(1:2, each = 4))
epi_mantel_haenszel_test(d, e, y, s)
#> # A tibble: 1 × 8
#> measure estimate conf_low conf_high statistic p_value strata correction
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <int> <lgl>
#> 1 mantel_haensz… 1 0.0625 16.0 0 1 2 FALSE