contingency: Measures of association from two by two contingency tables...

View source: R/epi_functions.R

contingencyR Documentation

Measures of association from two by two contingency tables (formula).

Description

contingency is a wrap that calls epi.2by2 from package epiR.

Usage

contingency(
  object = NULL,
  formula = NULL,
  data = NULL,
  method = "cohort.count",
  ...
)

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

formula

A formula with shape: outcome ~ exposure.

data

A data frame where the variables in the formula can be found.

method

A character string with options: "cohort.count", "cohort.time", "case.control", or "cross.sectional".

...

Further arguments passed to epi.2by2.

Details

contingency uses a formula as a way to input variables.

contingency displays the contingency table as a way for the user to check that the reference levels in the categorical variables (outcome and exposure) are correct. Then displays measures of association (table from epi.2by2). It also reports either chi-squared test or exact Fisher's test; contingency checks which one of the tests two is appropriate.

See Also

epi.2by2.

Examples

## A case-control study on the effect of alcohol on oesophageal cancer.
Freq <- c(386, 29, 389, 171)
status <- gl(2, 1, 4, labels = c("Control", "Case"))
alcohol <- gl(2, 2, labels = c("0-39", "40+"))
cancer <- data.frame(Freq, status, alcohol)
cancer <- expand_df(cancer)
contingency(status ~ alcohol, data = cancer, method = "case.control")

data(Oncho)
require(dplyr, quietly = TRUE)

Oncho %>%
  select(mf, area) %>%
  cross_tbl(by = "mf") %>%
  theme_pubh(2)

Oncho %>%
  contingency(mf ~ area)

josie-athens/pubh documentation built on Feb. 3, 2024, 4:32 a.m.