zepid.calc.utils.risk_ci(events, total, alpha=0.05, confint='wald')

Calculate two-sided risk confidence intervals

Risk is calculated from

\[R = \frac{a}{a+b}\]

Wald standard error is

\[SE_{Wald} = \left(\frac{1}{a} - \frac{1}{b}\right)^{\frac{1}{2}}\]

Hypergeometric standard error is

\[SE_{HypGeo} = \left(\frac{a b}{(a+b)^2 (a+b-1)}\right)^{\frac{1}{2}}\]
  • events (integer, float) – Number of events/outcomes that occurred
  • total (integer, float) – Total number of subjects that could have experienced the event
  • alpha (float, optional) – Alpha level. Default is 0.05
  • confint (string, optional) – Type of confidence interval to generate. Current options include Wald or Hypergeometric confidence intervals

Tuple containing risk, lower CL, upper CL, SE

Return type:



Confidence intervals rely on the central limit theorem, so there must be at least 5 events and 5 nonevents


Estimate the risk, standard error, and confidence intervals

>>> from zepid.calc import risk_ci
>>> r = risk_ci(45, 100)

Extracting the estimated risk

>>> r.point_estimate

Extracting the lower and upper confidence intervals, respectively

>>> r.lower_bound
>>> r.upper_bound

Extracting the standard error

>>> r.standard_error