Attributable fraction and attributable number calculations for DLNMs. Use when computing health burden, using attrdl(), or running Monte Carlo simulations for CIs.
| Measure | Definition | Formula |
|---|---|---|
| AF (Attributable Fraction) | Proportion of outcome attributable to exposure | 1 - 1/RR (for each day) |
| AN (Attributable Number) | Absolute count attributable to exposure | AF × observed count |
| Forward: Today's exposure → future burden | Sum over lag 0 to maxlag | Standard approach |
| Backward: Today's deaths → past exposures | Sum over past exposures | Alternative interpretation |
attrdl() FunctionBased on Gasparrini & Leone (2014). Available from author's website/GitHub:
# Forward attributable fraction
af <- attrdl(exposure, cb, outcome, model, type = "af", cen = cen_value)
# Forward attributable number
an <- attrdl(exposure, cb, outcome, model, type = "an", cen = cen_value)
cen: Centering value (reference for "no effect"). Must match crosspred() centering.type: "af" or "an".dir: "forw" (forward) or "back" (backward).range: Exposure range to consider (e.g., c(cen_value, max(exposure)) for heat only).set.seed(42)
nsim <- 1000
sim_coefs <- mvrnorm(nsim, coef(model), vcov(model))
af_sim <- sapply(1:nsim, function(i) {
attrdl(exposure, cb, outcome, model, type = "af",
cen = cen_value, coef = sim_coefs[i, ], vcov = NULL)
})
af_ci <- quantile(af_sim, c(0.025, 0.975))
mvrnorm: From MASS package. Simulates from multivariate normal.For temperature studies, split into:
# Cold vs. Heat
af_cold <- attrdl(exposure, cb, outcome, model, type = "af",
cen = cen_value, range = c(min(exposure), cen_value))
af_heat <- attrdl(exposure, cb, outcome, model, type = "af",
cen = cen_value, range = c(cen_value, max(exposure)))