
Combine Potential Impact Fractions and Population Attributable Fractions
totalpifpaf.Rd
Combine potential impact fractions or the population attributable fractions
to either generate the total fraction from the fractions of
subpopulations (pif_total/paf_total
) or the ensemble fraction of a population
from different (independent) exposures.
Usage
paf_total(
paf1,
...,
pif_weights,
sigma_pif_weights = 0,
conf_level = 0.95,
link = "log-complement",
link_inv = NULL,
link_deriv = NULL,
quiet = FALSE
)
pif_total(
pif1,
...,
pif_weights,
sigma_pif_weights = 0,
conf_level = 0.95,
link = "log-complement",
link_inv = NULL,
link_deriv = NULL,
quiet = FALSE
)
pif_ensemble(
pif1,
...,
pif_weights = NULL,
sigma_pif_weights = NULL,
link = "identity",
link_inv = NULL,
link_deriv = NULL,
conf_level = 0.95,
quiet = FALSE
)
Arguments
- paf1
A population attributable fraction (class
pif_class
)- ...
The remaining potential impact fractions or (respectively) population attributable fractions.
- pif_weights
A vector containing the proportion of the population for each of the categories (for each of the pifs given).
- sigma_pif_weights
link_covariance structure for the
pif_weights
. Can be0
(default) if the pif_weights are not random, a vector if only the link_variances of the pif_weights are available or a link_covariance matrix.- conf_level
Confidence level for the confidence interval (default 0.95).
- link
Link function such that the
pif
confidence intervals stays within the expected bounds.- link_inv
The inverse of
link
. For example iflink
islogit
this should beinv_logit
.- link_deriv
Derivative of the
link
function. The function tries to build it automatically fromlink
usingDeriv::Deriv()
.- quiet
Whether to show messages.
- pif1
A potential impact fraction (class
pif_class
)
Total potential impact fraction
Assuming the overall population can be subdivided into \(N\) distinct subpopulations each of them with a different potential impact fraction (or population attributable fraction) we can estimate the total population attributable fraction or potential impact fraction of the whole population as:
$$ \text{PIF}_{\text{Total}} = \sum\limits_{i = 1}^{N} \pi_i \cdot \text{PIF}_i $$
where each \(\text{PIF}_i\) corresponds to the potential impact fraction of the i-th subpopulation and \(\pi_i\) correspond to the proportion of the total population occupied by \(\text{PIF}_i\). The pif_weights are such that \(\sum_{i=1}^{N} \pi_i = 1\).
Ensemble potential impact fraction
If a population is exposed to \(K\) different independent risk factors then the ensemble impact fraction of the combination of those factors can be written as:
$$ \text{PIF}_{\text{Ensemble}} = 1 - \prod\limits_{\ell = 1}^{K} \Big(1 - \cdot \text{PIF}_{\ell}\Big) $$
where each \(\text{PIF}_{\ell}\) corresponds to the potential impact fraction of the \(\ell\)-th risk factor for the same population.
Examples
#Potential impact fraction for women
pif_women <- pif(0.32, 0.1, 1.2, quiet = TRUE, var_p = 0.1)
#Potential impact fraction for men
pif_men <- pif(0.27, 0.1, 1.3, quiet = TRUE, var_p = 0.1)
#Population potential impact fraction with 49% men and 51% women
pif_total(pif_men, pif_women, pif_weights = c(0.49, 0.51), link = "logit")
#>
#> ── Potential Impact Fraction ──
#>
#> PIF = 4.421% [95% CI: 0.448% to 32.224%]
#> standard_deviation(pif %) = 5.023
#> standard_deviation(link(pif)) = 1.189
#Population attributable fraction for women
paf_women <- paf(0.32, 1.3, quiet = TRUE, var_p = 0.1)
#Population attributable fraction for men
paf_men <- paf(0.27, 1.3, quiet = TRUE, var_p = 0.1)
paf_total(paf_men, paf_women, pif_weights = c(0.49, 0.51), link = "logit")
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#>
#> ── Population Attributable Fraction ──
#>
#> PAF = 8.139% [95% CI: 1.969% to 28.099%]
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> standard_deviation(paf %) = 5.661
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> standard_deviation(link(paf)) = 0.757
# Calculate the ensemble from lead and radiation exposure
paf_lead <- paf(0.2, 2.2, quiet = TRUE, var_p = 0.001)
paf_rad <- paf(0.1, 1.2, quiet = TRUE, var_p = 0.0001)
pif_ensemble(paf_lead, paf_rad)
#>
#> ── Population Attributable Fraction ──
#>
#> PAF = 20.936% [95% CI: 14.926% to 26.946%]
#> standard_deviation(paf %) = 3.067
#> standard_deviation(link(paf)) = 0.031
# Totals and ensembles can be combined
pif_lead_women <- paf(0.27, 2.2, quiet = TRUE, var_p = 0.001)
pif_rad_women <- paf(0.12, 1.2, quiet = TRUE, var_p = 0.001)
pif_women <- pif_ensemble(pif_lead_women, pif_rad_women)
pif_lead_men <- paf(0.30, 2.2, quiet = TRUE, var_p = 0.001)
pif_rad_men <- paf(0.10, 1.2, quiet = TRUE, var_p = 0.001)
pif_men <- pif_ensemble(pif_lead_men, pif_rad_men)
pif_total(pif_men, pif_women, pif_weights = c(0.49, 0.51))
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#>
#> ── Population Attributable Fraction ──
#>
#> PAF = 27.060% [95% CI: 23.196% to 30.730%]
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> standard_deviation(paf %) = 1.921
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> ! The relative risk beta parameters for the potential impact fractions appear to be the same. If they are, set `uncorrelated_beta = FALSE`. Otherwise set `uncorrelated_beta = TRUE
#> standard_deviation(link(paf)) = 0.026