oddsratio {fmsb}R Documentation

Calculate odds ratio and its confidence intervals

Description

Calculate odds ratio and its confidence intervals based on approximation, followed by null-hypothesis (odds ratio equals to 1) testing.

Usage

 oddsratio(a, b, c, d, conf.level=0.95, p.calc.by.independence=TRUE) 

Arguments

a

A scalar or a matrix. If matrix, it has to be 2 by 2, which contains the number of individuals who both suffer from exposure and disease as [1, 1], the number of individuals who suffer from disesase but not exposed as [2, 1], the number of individuals who suffer from exposure but are healthy as [1, 2] and the number of individuals who neither suffered from exposure nor disease as [2, 2].

b

If a is a scalar, this has to be given as the number of individuals who suffer from disesase but not exposed. Otherwise, ignored.

c

If a is a scalar, this has to be given as the number of individuals who suffer from exposure but are healthy. Otherwise, ignored.

d

If a is a scalar, this has to be given as the number of individuals who neither suffered from exposure nor disease. Otherwise, ignored.

conf.level

Probability for confidence intervals. Default is 0.95.

p.calc.by.independence

Logical. If TRUE, calculating p-value by testing the null-hypothesis of independence between exposure and disease. Otherwise, calculating p-value by inverse-function of confidence intervals calculation (the result becomes the same as the vcd package). Default TRUE.

Value

estimate

Calculated point estimate of odds ratio.

conf.int

A numeric vector of length 2 to give upper/lower limit of confidence intervals.

p.value

The significant probability as the result of null-hypothesis testing.

Note

This function can also accept a matrix as argument, as suggested by Dr. Toshiaki Ara (toshiaki.ara@gmail.com). Thanks for a good suggestion.

Author(s)

Minato Nakazawa minato-nakazawa@people.kobe-u.ac.jp https://minato.sip21c.org/

References

Rothman KJ (2012) Epidemiology: An Introduction. 2nd Ed., Oxford University Press, Oxford.

Examples

 res <- oddsratio(5, 10, 85, 80)
 str(res)
 print(res)
 oddsratio(12, 5, 6, 12)
 oddsratio(12, 5, 6, 12, p.calc.by.independence=FALSE)
 DH <- sample(c("Disease", "Health"), 100, replace=TRUE)
 EN <- sample(c("Exposed", "Nonexposed"), 100, replace=TRUE)
 x <- table(EN, DH)
 oddsratio(x)
 # same as oddsratio(x[1,1], x[2,1], x[1,2], x[2,2])

[Package fmsb version 0.7.0 Index]