zepid.calc.utils.odds_ratio¶
-
zepid.calc.utils.
odds_ratio
(a, b, c, d, alpha=0.05)¶ Calculates the odds ratio and confidence interval from count data
Odds ratio is calculated from
\[OR = \frac{a}{b} / \frac{c}{d}\]Odds ratio standard error is
\[SE = \left(\frac{1}{a} + \frac{1}{b} + \frac{1}{c} + \frac{1}{d}\right)^{\frac{1}{2}}\]Parameters: - a (integer, float) – Count of exposed individuals with outcome
- b (integer, float) – Count of unexposed individuals with outcome
- c (integer, float) – Count of exposed individuals without outcome
- d (integer, float) – Count of unexposed individuals without outcome
- alpha (float, optional) – Alpha value to calculate two-sided Wald confidence intervals. Default is 95% confidence interval
Returns: Tuple of OR, lower CL, upper CL, SE
Return type: tuple
Examples
Estimate the odds ratio, standard error, and confidence intervals
>>> from zepid.calc import odds_ratio >>> odr = odds_ratio(45, 55, 21, 79)
Extracting the estimated odds ratio
>>> odr.point_estimate
Extracting the lower and upper confidence intervals, respectively
>>> odr.lower_bound >>> odr.upper_bound
Extracting the standard error
>>> odr.standard_error