zepid.base.RiskRatio¶

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

Estimate of Risk Ratio with a (1-alpha)*100% Confidence interval from a pandas DataFrame. Missing data is ignored. Exposure categories should be mutually exclusive

Risk ratio is calculated from

$RR = \frac{\Pr(Y|A=1)}{\Pr(Y|A=0)}$

Risk ratio standard error is

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

Note

Outcome must be coded as (1: yes, 0:no). Only works supports 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 risk ratio in a data set

>>> from zepid import RiskRatio, load_sample_data
>>> rr = RiskRatio()
>>> rr.summary()


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

>>> rr = RiskRatio(reference=1)
>>> rr.summary()


Generate a plot of the calculated risk ratio(s)

>>> import matplotlib.pyplot as plt
>>> rr = RiskRatio()

__init__(reference=0, alpha=0.05)
 __init__([reference, alpha]) Initialize self. fit(df, exposure, outcome) Calculates the Risk Ratio given a data set plot([measure, scale, center]) Plot the risk ratios or the risks along with their corresponding confidence intervals. summary([decimal]) Prints the summary results