These functions will create either odds for a given probability, probability for a given odds, calculate the odds ratio between two probabilities, or calculate effect size (raise a probability by theta)

prop2odds(p)

odds2prop(o)

effect.size(p, theta)

props2theta(p1, p2)

rr2theta(rr, p1, p2)

theta2rr(theta, p1, p2)

Arguments

p, p1, p2

Proportion vector.

o

Odds vector.

theta

Odds ratio vector.

rr

Relative risk vector (p1 / p2).

Value

A numeric vector.

Author

Paul W. Egeler, M.S.

Examples

# Convert proportions of 0 through 1 to odds
props <- seq(0,1,0.1)
prop2odds(props)
#>  [1] 0.0000000 0.1111111 0.2500000 0.4285714 0.6666667 1.0000000 1.5000000
#>  [8] 2.3333333 4.0000000 9.0000000       Inf

# Convert odds to proportions
odds2prop(1:3)
#> [1] 0.5000000 0.6666667 0.7500000

# Raise a proportion by an effect size theta
effect.size(0.5, 2)
#> [1] 0.6666667

# Find the odds ratio between two proportions
props2theta(0.75, 0.5)
#> [1] 3