# zepid.base.OddsRatio¶

class zepid.base.OddsRatio(reference=0, alpha=0.05)

Estimates of Odds Ratio with a (1-alpha)*100% Confidence interval. Missing data is ignored

Odds ratio is calculated from

$OR = \frac{\Pr(Y|A=1)}{1 - \Pr(Y|A=1)} / \frac{\Pr(Y|A=0)}{1 - \Pr(Y|A=0)}$

Odds ratio standard error is

$SE = \left(\frac{1}{a} + \frac{1}{b} + \frac{1}{c} + \frac{1}{d}\right)^{\frac{1}{2}}$

Note

Outcome must be coded as (1: yes, 0:no). Only works for binary outcomes

Parameters: reference (integer, optional) – Reference category for comparisons. Default reference category is 0 alpha (float, optional) – Alpha value to calculate two-sided Wald confidence intervals. Default is 95% confidence interval

Examples

Calculate the odds ratio in a data set

>>> from zepid import OddsRatio, load_sample_data
>>> df = load_sample_data(False)
>>> ort = OddsRatio()
>>> ort.fit(df, exposure='art', outcome='dead')
>>> ort.summary()

Calculate the odds ratio with exposure of ‘1’ as the reference category

>>> ort = OddsRatio(reference=1)
>>> ort.fit(df, exposure='art', outcome='dead')
>>> ort.summary()

Generate a plot of the calculated odds ratio(s)

>>> import matplotlib.pyplot as plt
>>> ort = OddsRatio()
>>> ort.fit(df, exposure='art', outcome='dead')
>>> ort.plot()
>>> plt.show()
__init__(reference=0, alpha=0.05)

Initialize self. See help(type(self)) for accurate signature.

Methods

 __init__([reference, alpha]) Initialize self. fit(df, exposure, outcome) Calculates the Odds Ratio plot([scale, center]) Plot the odds ratios along with their corresponding confidence intervals. summary([decimal]) Prints the summary results