Skip to contents

Calculates the weighted adjusted potential impact fractions (or population attributable fractions). Each individual fraction \(\widehat{\text{PIF}}_i\) is rescaled proportionally so that together they are consistent with the ensemble fraction.

Usage

weighted_adjusted_paf(
  paf1,
  ...,
  weights = NULL,
  var_weights = 0,
  var_pif_weights = NULL,
  var_p = NULL,
  var_beta = NULL,
  pif_total_link = "log-complement",
  pif_total_link_inv = NULL,
  pif_total_link_deriv = NULL,
  pif_ensemble_link = "identity",
  pif_ensemble_link_inv = NULL,
  pif_ensemble_link_deriv = NULL,
  conf_level = 0.95,
  label_ensemble = NULL,
  label_sum = NULL,
  quiet = FALSE,
  link = "log",
  link_inv = NULL,
  link_deriv = NULL
)

weighted_adjusted_pif(
  pif1,
  ...,
  weights = NULL,
  var_weights = 0,
  var_pif_weights = NULL,
  var_p = NULL,
  var_beta = NULL,
  pif_total_link = "log-complement",
  pif_total_link_inv = NULL,
  pif_total_link_deriv = NULL,
  pif_ensemble_link = "identity",
  pif_ensemble_link_inv = NULL,
  pif_ensemble_link_deriv = NULL,
  conf_level = 0.95,
  label_ensemble = NULL,
  label_sum = NULL,
  quiet = FALSE,
  link = "log",
  link_inv = NULL,
  link_deriv = NULL
)

Arguments

paf1

A population attributable fraction (class pif_class). This is the first of the individual fractions to be adjusted.

...

The remaining potential impact fractions (class pif_class). All fractions must be of the same type (all PIF or all PAF).

weights

Weights for the ensemble (pif_ensemble). Passed directly to pif_ensemble() / paf_ensemble(). Defaults to NULL (equal weights of 1 for each fraction). When adjusting for communality (Mukadam et al. 2019) the weights are 1 - communality.

var_weights

Covariance structure for weights. Passed directly to pif_ensemble() / paf_ensemble(). Defaults to 0.

var_pif_weights

Covariance matrix between individual fractions and weights. Passed to pif_ensemble() / paf_ensemble(). Defaults to NULL.

var_p, var_beta

(Optional) Covariance matrices between the estimates of p (respectively beta) of different fractions, with row and column names given by the identifiers of the parameters (see the section Shared parameters in pif()). Passed to pif_total() and pif_ensemble(). Defaults to NULL (fractions are correlated only through shared identifiers).

Link to pass to pif_total in the denominator of the adjustment

Inverse of the link to pass to pif_total in the denominator of the adjustment

Derivative of the link to pass to pif_total in the denominator of the adjustment

Link to pass to pif_ensemble in the numerator of the adjustment

Inverse of the link to pass to pif_ensemble in the numerator of the adjustment

Derivative of the link to pass to pif_ensemble in the numerator of the adjustment

conf_level

Confidence level for the confidence interval (default 0.95).

label_ensemble

Character label for the internally constructed ensemble fraction. Defaults to NULL (auto-generated).

label_sum

Character label for the internally constructed sum (total) fraction. Defaults to NULL (auto-generated).

quiet

Whether to show messages.

Link used to build the confidence intervals of the adjusted fractions. Defaults to "log", the scale on which their variance is derived (see Formula), which guarantees strictly positive intervals. Use "identity" for symmetric Wald intervals (required if an adjusted fraction is not strictly positive) or a function together with link_inv and link_deriv.

(Optional) Inverse and derivative of link when link is a function.

pif1

A potential impact fraction (class pif_class). This is the first of the individual fractions to be adjusted.

Value

A named list of pif_class objects, one per input fraction, each being the weighted adjusted PAF (or PIF, respectively).

Formula

The weighted adjusted fraction for the \(i\)-th exposure is: $$ \widehat{\text{PIF}}_i^{\text{adj}} = \frac{\widehat{\text{PIF}}_i}{\sum_{j=1}^{n} \widehat{\text{PIF}}_j} \cdot \widehat{\text{PIF}}_{\text{Ensemble}} $$

Using the log-transform, the variance is: $$ \begin{aligned} \operatorname{Var}\!\Big[\ln \widehat{\text{PIF}}_i^{\text{adj}}\Big] &= \operatorname{Var}\!\left[\ln \widehat{\text{PIF}}_i\right] + \operatorname{Var}\!\left[\ln \textstyle\sum_j \widehat{\text{PIF}}_j\right] + \operatorname{Var}\!\left[\ln \widehat{\text{PIF}}_{\text{Ensemble}}\right] \\ &\quad + 2\Bigg[ \operatorname{Cov}\!\Big(\ln \widehat{\text{PIF}}_i, \ln \widehat{\text{PIF}}_{\text{Ensemble}}\Big) - \operatorname{Cov}\!\Big(\ln \widehat{\text{PIF}}_i, \ln \textstyle\sum_j \widehat{\text{PIF}}_j\Big) - \operatorname{Cov}\!\Big(\ln \widehat{\text{PIF}}_{\text{Ensemble}}, \ln \textstyle\sum_j \widehat{\text{PIF}}_j\Big) \Bigg] \end{aligned} $$

where each log-covariance is approximated via the delta method: $$ \operatorname{Cov}\!\big(\ln X, \ln Y\big) \approx \frac{\operatorname{Cov}(X, Y)}{X \cdot Y} $$

The confidence interval is built on the scale of link (the log scale by default): $$ \exp\Big( \ln \widehat{\text{PIF}}_i^{\text{adj}} \pm Z_{\alpha/2} \sqrt{\operatorname{Var}\big[\ln \widehat{\text{PIF}}_i^{\text{adj}}\big]}\Big). $$

The covariances \(\operatorname{Cov}(\widehat{\text{PIF}}_i, \cdot)\) are computed by the internal function cov_total_pif() applied to the individual fraction and the internally constructed sum/ensemble objects, which automatically propagates the full uncertainty structure already embedded in those objects.

Examples

paf_lead <- paf(0.2, 2.2, quiet = TRUE, var_p = 0.001, label = "Lead")
paf_rad  <- paf(0.1, 1.2, quiet = TRUE, var_p = 0.0001, label = "Radiation")

weighted_adjusted_paf(paf_lead, paf_rad)
#> $Lead
#> 
#> ── Population Attributable Fraction: [Lead_adj] ──
#> 
#> PAF = 52.726% [95% CI: 46.946% to 59.217%]
#> standard_deviation(paf %) = 3.123
#> 
#> $Radiation
#> 
#> ── Population Attributable Fraction: [Radiation_adj] ──
#> 
#> PAF = 16.116% [95% CI: 13.753% to 18.885%]
#> standard_deviation(paf %) = 1.304
#> 

pif_lead <- pif(0.2, p_cft = 0.1, beta = log(2.2), quiet = TRUE,
                var_p = 0.001, label = "Lead")
pif_rad  <- pif(0.1, p_cft = 0.05, beta = log(1.2), quiet = TRUE,
                var_p = 0.0001, label = "Radiation")

weighted_adjusted_pif(pif_lead, pif_rad)
#> $Lead
#> 
#> ── Potential Impact Fraction: [Lead_adj] ──
#> 
#> PIF = 9.591% [95% CI: 5.482% to 16.780%]
#> standard_deviation(pif %) = 2.737
#> 
#> $Radiation
#> 
#> ── Potential Impact Fraction: [Radiation_adj] ──
#> 
#> PIF = 0.972% [95% CI: 0.659% to 1.432%]
#> standard_deviation(pif %) = 0.192
#>