# zepid.calc.utils.risk_difference¶

zepid.calc.utils.risk_difference(a, b, c, d, alpha=0.05)

Calculates the risk difference and confidence intervals from count data.

Risk difference is calculated as

$RD = \frac{a}{a + b} - \frac{c}{c + d}$

Risk difference standard error is calculated as

$SE = \left(\frac{R_1 \times (1 - R_1)}{a+b} + \frac{R_0 \times (1-R_0)}{c+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 Tuple of risk difference, lower CL, upper CL, SE tuple

Examples

Estimate the risk difference, standard error, and confidence intervals

>>> from zepid.calc import risk_difference
>>> rd = risk_difference(45, 55, 21, 79)


Extracting the estimated risk difference

>>> rd.point_estimate


Extracting the lower and upper confidence intervals, respectively

>>> rd.lower_bound
>>> rd.upper_bound


Extracting the standard error

>>> rd.standard_error