attrdl: Attributable risk from distributed lag nonlinear models

Description Usage Arguments Details Value Note Author(s) References Examples

View source: R/attrdl.R

Description

This is a general function that computes attributable risk (attributable numbers or fractions) from distributed lag nonlinear models.

Usage

1
2
3
attrdl(x, basis, cases, model = NULL, coef = NULL, vcov = NULL,
  type = "af", dir = "back", tot = TRUE, cen, range = NULL,
  sim = FALSE, nsim = 5000, sub = 1:length(cases))

Arguments

x

An exposure vector OR (only for dir="back") a matrix of lagged exposures, for which the attributable risk needs to be computed.

basis

The object of class "crossbasis" used for fitting the model.

cases

The cases vector OR (only for dir="forw") the matrix of future cases corresponding to x.

model

The fitted model. You need to provide either this, or arguments coef and vcov. The model MUST have a log link function.

coef

Coefficients for basis IF model is not provided

vcov

Variance-covariance matrix for basis IF model is not provided

type

Either "an" or "af" for attributable number or attributable fraction

dir

Either "back" or "forw" for backward or forward perspectives of attributable risk

tot

If TRUE, the total attributable risk is computed (number or fraction, depending on argument type)

cen

The reference value used as the counterfactual scenario (the comparator)

range

The range of exposure (for which the attributable risk, compared to cen, is calculated). If NULL, the whole range is used.

sim

Set to TRUE if Monte Carlo simulation samples should be returned.

nsim

Number of simulation samples desired (only for nsim=TRUE).

sub

Subset of cases for which to calculate the attributable risk (as an integer index vector). Defaults to 1:length(cases). Argument cases should be a vector (not a matrix).

Details

Original function and documentation written by Antonio Gasparrini and available here. Slightly amended by Theodore Lytras for use with FluMoDL.

Documentation below copied from the original source.

This function computes the attributable fraction or number for a specific exposure scenario and associated cases, given an estimated exposure-lag-response association defined by a DLNM. Either forward or backward versions of attributable risk measures are available in this setting. The method is described by Gasparrini and Leone (2014), see references below. The function works in combination with other functions in the package dlnm, which is assumed to be available.

The exposure and cases are provided by the arguments x and cases, respectively. The original cross-basis and fitted model containg it used for estimation are provided by the arguments basis and model, respectively. Alternatively, the user can provide estimated coefficients and (co)variance matrix with coef and vcov.

The function works both with time series and non-time series data. In a time series setting, both x and cases represent a complete series of ordered observations. More generally, the user can apply this function for any kind of data: in this case x must be a matrix of lagged exposures when dir="back", and cases must be a matrix of future cases dir="forw". The function can compute the total attributable risk (if tot=TRUE, the default) or the contribution for each observation. The argument cen defines the value used as counterfactual scenario.

If sim=TRUE, the function computes samples of the attributable risk measures by simulating from the assumed normal distribution of the estimated coefficients (only implemented for total estimates). These samples can be used to defined empirical confidence intervals.

Value

By default, a numeric scalar representing the total attributable fraction or number. If sim=TRUE, a vector of the simulated samples with length nsim. If tot=FALSE, a vector with contributions for all the observations (see Note below). These quantities are defined versus a counterfactual scenario defined through the argument cen.

Note

The function handles missing values in both the x and cases objects, excluding incomplete observations (also due to lagging) accordingly. However, the total attributable number is rescaled to match the fraction using as denominator the total observed number in cases. This approach uses the all the available information even in the presence of missing values in x. All of this under the assumption that the missing mechanism is unrelated with both exposure and cases values.

The functions can be also used with estimates from DLNMs reduced to the overall cumulative exposure-response through the function crossreduce in the package dlnm. In this case, the modified coefficients and (co)variance matrix of the reduced cross-basis in basis must be passed using the arguments coef and vcov. This option can be useful when the original estimates from the full cross-basis are not available any more, for example following a meta-analysis. Given the lag-specific estimates are not available in this case, only the forward version of attributable risk (dir="forw") can be computed. See Gasparrini and Leone (2014) for further info.

Author(s)

Original author: Antonio Gasparrini <antonio.gasparrini@lshtm.ac.uk>

References

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# load the package
library(FluMoDL)  # package dlnm is automatically loaded

# define the cross-basis and fit the model
cb <- crossbasis(chicagoNMMAPS$temp, lag=30, argvar=list(fun="bs",
   knots=c(-10,3,18)), arglag=list(knots=c(1,3,10)))
library(splines)
model <- glm(death ~ cb + ns(time, 7*14) + dow,
   family=quasipoisson(), chicagoNMMAPS)

# global backward attributable risk of temperature (number and fraction)
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,type="an",cen=21)
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,cen=21)

# global forward attributable fraction
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,dir="forw",cen=21)

# empirical confidence intervals
afsim <- attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,cen=21,
   sim=TRUE,nsim=1000)
quantile(afsim,c(2.5,97.5)/100)

# attributable fraction component due to heat and cold
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,cen=21,range=c(21,100))
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,cen=21,range=c(-100,21))

# daily attributable deaths in the second month
attrdl(chicagoNMMAPS$temp,cb,chicagoNMMAPS$death,model,type="an",
   tot=FALSE,cen=21)[31:60]

thlytras/FluMoDL documentation built on Nov. 5, 2019, 10:06 a.m.