epi: Epidemiological 2 by 2 Analysis

View source: R/epi.R View source: R/zzzz-r4vn-hierarchical-extra.R

epiR Documentation

Epidemiological 2 by 2 Analysis

Description

epii() analyzes typed 2 by 2 counts. epi() analyzes binary outcome and exposure variables. With by, stratum-specific estimates, a Mantel-Haenszel common odds ratio, a pooled risk ratio, homogeneity, and interaction tests are displayed. The stratified output also reports the crude-versus-Mantel-Haenszel OR difference as both 100*(ORcrude-ORMH)/ORMH and 100*(ORcrude-ORMH)/ORcrude. cci()/cc() and csi()/cs() are familiar aliases.

Usage

epi(
  outcome,
  exposure,
  by = NULL,
  data = NULL,
  event = NULL,
  exposed = NULL,
  level = 0.95,
  correction = 0.5,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

cc(
  outcome,
  exposure,
  by = NULL,
  data = NULL,
  event = NULL,
  exposed = NULL,
  level = 0.95,
  correction = 0.5,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

cs(
  outcome,
  exposure,
  by = NULL,
  data = NULL,
  event = NULL,
  exposed = NULL,
  level = 0.95,
  correction = 0.5,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

epii(
  a = NULL,
  b = NULL,
  c = NULL,
  d = NULL,
  by = NULL,
  level = 0.95,
  correction = 0.5,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

cci(a, b, c, d, ...)

csi(a, b, c, d, ...)

epi(
  outcome,
  exposure,
  by = NULL,
  data = NULL,
  event = NULL,
  exposed = NULL,
  level = 0.95,
  correction = 0.5,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE
)

Arguments

outcome

Binary outcome variable.

exposure

Binary exposure variable.

by

For epii(), a list of 2 by 2 tables or a 2 by 2 by K array. For epi(), an optional stratification variable. Hierarchical syntax is supported: by = vars(province, sex) repeats the epidemiological analysis within province and uses sex as the innermost Mantel-Haenszel stratum. With three or more variables, every variable before the final one is an ordered outer stratum and the final variable is the MH stratification variable.

data

Data frame. If NULL, active data is used.

event

Outcome event level; defaults to the last observed level.

exposed

Exposure level; defaults to the last observed level.

level

Confidence level.

correction

Continuity correction used for log-scale confidence intervals when a cell is zero.

digits, p_digits

Decimal places for estimates and p-values.

show

Logical; open the formatted result in the Viewer. Default TRUE.

console

Logical; also print the traditional text result in the Console. Default FALSE.

a, b, c, d

Cell counts of a 2 by 2 table. a may also be a 2 by 2 matrix.

...

Additional arguments passed to epii() by immediate aliases.

Details

The 2 by 2 layout is exposure by outcome: a exposed cases, b exposed noncases, c unexposed cases, and d unexposed noncases.

Value

Invisibly returns an object of class r4vn_stat.

Examples

epii(40, 10, 20, 30)
epii(by = list(
  Female = c(12, 18, 8, 32),
  Male = c(28, 12, 12, 18)
))

R4VN documentation built on Sept. 30, 2026, 5:13 p.m.