A {gtsummary} wrapper function that takes a dataframe and produces crude, stratified and Cochran-Mantel-Haenszel estimates.

tbl_cmh(
  data,
  case,
  exposure,
  strata,
  measure,
  obstime = NULL,
  conf.level = 0.95
)

Arguments

data

A data frame

case

Name of a variable as your outcome of interest

exposure

Names of variables as exposures of interest. Can be multiple variables using tidyselect syntax.

strata

Name of a variable to be used for stratifying results. This gives you a table of crude measure, measures for each strata and the mantel-haeszel adjusted measure for each exposure variable

measure

Specify what you would like to calculated, options are "OR", "RR" or "IRR". Default is "OR". If "OR or "RR" are specified then a woolf test for homogeneity p-value is produced. This tests whether there is a significant difference in the estimates between strata.

obstime

A numeric variable containing the observation time for each individual

conf.level

Confidence level for confidence intervals (default 0.95)

Value

A gtsummary table of class "tbl_cmh" (and "gtsummary", "tbl_stack") containing:

  • Crude estimates of association (odds ratios, risk ratios, or rate ratios)

  • Stratified estimates for each level of the stratification variable

  • Cochran–Mantel–Haenszel (CMH) adjusted estimates with 95\

  • Woolf test p-values for assessing homogeneity across strata (when applicable)

References

Inspired by Daniel Sjoberg, see gtsummary github repo