zepid.base.NNT¶
-
class
zepid.base.
NNT
(reference=0, alpha=0.05)¶ Estimates of Number Needed to Treat. NNT (1-alpha)*100% confidence interval presentation is based on Altman, DG (BMJ 1998). Missing data is ignored
Number needed to treat is calculated as
\[NNT = \frac{1}{RD}\]Risk difference the corresponding confidence intervals come from
\[RD = \Pr(Y|A=1) - \Pr(Y|A=0)\]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}}\]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 number needed to treat in a data set
>>> from zepid import NNT, load_sample_data >>> df = load_sample_data(False) >>> nnt = NNT() >>> nnt.fit(df, exposure='art', outcome='dead') >>> nnt.summary()
Calculate the number needed to treat with ‘1’ as the reference category
>>> nnt = NNT(reference=1) >>> nnt.fit(df, exposure='art', outcome='dead') >>> nnt.summary()
-
__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 NNT summary
([decimal])Prints the summary results