Skip to contents

Calculate both Potential Impact Fractions (PIF) and Population Attributable Fractions (PAF) for aggregated data and their confidence intervals using the delta method.

Installation

You can install the development version of deltapif with:

#install.packages("remotes")
remotes::install_github("RodrigoZepeda/deltapif")

Calculating a population attributable fraction

To estimate a population attributable fraction two ingredients are required:

  • beta: the relative risk or a value from which to calculate the relative risk (with variance var_beta).
  • p: the exposure prevalence (with variance var_p).

and in the case of potential impact fractions we also require:

  • p_cft: the counterfactual prevalence.

Note An important hypothesis of the current method is that the relative risk estimate and the prevalence of exposure are both independent in the sense that they were estimated in different populations and studies.

For example Lee et al estimate the attributable fraction of smoking on dementia. For that purpose they report the following:

  • A relative risk of 1.59 (1.15, 2.20)
  • An exposure prevalence of 8.5

We can calculate a point estimate of the PAF as follows:

library(deltapif)
paf(p = 0.085, beta = 1.59, quiet = TRUE)
#> 
#> ── Population Attributable Fraction ──
#> 
#> PAF = 4.776% [95% CI: 4.776% to 4.776%]
#> standard_deviation(paf %) = 0.000
#> standard_deviation(link(paf)) = 0.000

Note that this follows the formula by Levin:

\[ \textrm{PAF} = \frac{p \cdot (\text{RR} - 1)}{1 + p \cdot (\text{RR} - 1)} \]

Additional examples show how to calculate the PAF for multiple categories.

Adding uncertainty

Note that there is no uncertainty in the fraction as we have not inputed the standard deviation of the relative risk. To do so we notice that the variance for the relative risk is actually for the log of the relative risk. We follow the formula from Cochrane’s handbook:

\[ \text{variance}_{\ln(\text{RR})} = \Bigg(\frac{\ln(\text{upper limit}) - \ln(\text{lower limit})}{2\times 1.95}\Bigg)^2 \]

((log(2.20) - log(1.15)) / (2*1.95))^2
#> [1] 0.02766639

And because the uncertainty was specified for the log of the relative risk we use the natural logarithm ln of 1.59 as our beta where log(1.59) = 0.4637 and specify that the way to get our relative risk is through the exponential (exp) function. Finally as no uncertainty was given for p we set var_p = 0.

paf(p = 0.085, beta = 0.4637, var_beta = 0.02766639, var_p = 0, rr_link = exp)
#> 
#> ── Population Attributable Fraction ──
#> 
#> PAF = 4.775% [95% CI: 0.695% to 8.688%]
#> standard_deviation(paf %) = 2.038
#> standard_deviation(link(paf)) = 0.021

Calculating a potential impact fraction

The paper also considers the potential impact fraction of a 15% reduction of smoking this can be achieved with the pif function by specifying the counterfactual distribution (in this case the 15% reduction results in \(0.085 \times (1 - 0.15) = 0.07225\))

pif(p = 0.085, p_cft = 0.07225, beta = 0.4637, var_beta = 0.02766639, var_p = 0, rr_link = exp)
#> 
#> ── Potential Impact Fraction ──
#> 
#> PIF = 0.716% [95% CI: 0.115% to 1.314%]
#> standard_deviation(pif %) = 0.306
#> standard_deviation(link(pif)) = 0.003

Note that both the PIF and PAF result in similar point estimates and CIs as in Lee et al who report:

  • PAF: 4.9 (1.3-9.3)
  • PIF: 0.7 (0.2-1.4)

More

Visit the deltapif website for more examples and additional operations you can do with PIF.