DescTools (version 0.99.8.1)

OddsRatio: Odds Ratio Estimation and Confidence Intervals

Description

Calculates odds ratio by unconditional maximum likelihood estimation (wald), conditional maximum likelihood estimation (mle) and median-unbiased estimation (midp). Confidence intervals are calculated using normal approximation (wald) and exact methods (midp, mle).

Usage

OddsRatio(x, y = NULL, conf.level = NA, method = c("wald", "mle", "midp"),
          interval = c(0, 1000), ...)

Arguments

x
a numeric vector or a 2x2 numeric matrix, resp. table.
y
NULL (default) or a vector with compatible dimensions to x. If y is provided, table(x, y, ...) will be calculated.
method
method for calculating odds ratio and confidence interval. Can be one out of "wald", "mle", "midp". Default is "wald" (not because it is the best, but because it is the most commonly used.)
conf.level
confidence level. Default is NA, meaning no confidence intervals will be reported.
interval
interval for the uniroot that finds the odds ratio median-unbiased estimate and mid-p exact confidence interval.
...
further arguments are passed to the function table, allowing i.e. to set useNA. This refers only to the vector interface.

Value

  • If conf.level is not NA then the result will be a vector with 3 elements for estimate, lower confidence intervall and upper for the upper one. Else the odds ratio will be reported as a single value.

Details

If a 2x2 table is provided the following table structure is preferred: disease=0 disease=1 exposed=0 (ref) n00 n01 exposed=1 n10 n11 however, for odds ratios from 2x2 tables, the following table is equivalent: disease=1 disease=0 exposed=1 n11 n10 exposed=0 n01 n00 If the table to be provided to this function is not in the preferred form, just use the function Rev() to "reverse" the table rows, -columns, or both. If a data.frame is provided the odds ratios are calculated pairwise and returned as numeric square matrix with the dimension of ncol(data.frame).

References

Kenneth J. Rothman and Sander Greenland (1998): Modern Epidemiology, Lippincott-Raven Publishers Kenneth J. Rothman (2002): Epidemiology: An Introduction, Oxford University Press Nicolas P. Jewell (2004): Statistics for Epidemiology, 1st Edition, 2004, Chapman & Hall, pp. 73-81

See Also

RelRisk

Examples

Run this code
# Case-control study assessing whether exposure to tap water
#   is associated with cryptosporidiosis among AIDS patients

tab <- matrix(c(2, 29, 35, 64, 12, 6), 3, 2, byrow=TRUE)
dimnames(tab) <- list("Tap water exposure" = c("Lowest", "Intermediate", "Highest"), 
                      "Outcome" = c("Case", "Control"))
tab <- Rev(tab, direction="column")

OddsRatio(tab[1:2,])
OddsRatio(tab[c(1,3),])

OddsRatio(tab[1:2,], method="mle")
OddsRatio(tab[1:2,], method="midp")
OddsRatio(tab[1:2,], method="wald", conf.level=0.95)

Run the code above in your browser using DataCamp Workspace