crosspred {dlnm}R Documentation

Generate predicted effects for a DLNM

Description

Generate predicted effects from a distributed lag non-linear model (DLNM) for a set of values of the original predictor. It returns specific effects for each combination of values and lags, plus overall and (optionally) cumulative effects (summed up along lags).

Usage

crosspred(crossbasis, model, at=NULL, 
        from=NULL, to=NULL, by=NULL, cumul=FALSE)

Arguments

crossbasis an object of class "crossbasis".
model a model object for which the prediction is desired.
at vector of values used for prediction.
from, to range of values used for prediction.
by increment of the sequence.
cumul logical. If TRUE, cumulative effects are predicted. See details.

Details

The object crossbasis must be the same containing the cross-basis matrix included in model, including its attributes and class. The set of values for which the effects must be computed can be specified by at or alternatively by from/to/by. If specified by at, the values are automatically ordered and made unique. By default, from and to correspond to the range of the original vector of observation stored in the crossbasis object (see crossbasis). If by is not provided, 30 equally spaced values are returned.

Matrices with cumulative effects summed upon lags for each values used for prediction are included if cumul=TRUE. For a long lag series (i.e. 1000 lags) the routine can be slow. These matrices are required by crossplot to graph the cumulative effects along lags.

For a detailed overview of the options, see:

vignette("dlnmOverview")

Value

A list object of class "crosspred" with the following components:

predvar vector of observations used for prediction.
maxlag a positive value defining the maximum lag.
coef, vcov related coefficients and variance-covariance matrix from model.
matfit, matse matrices of effects and related standard errors for each value of predvar and lag.
allfit, allse vectors of total effects and related standard errors for each value of predvar.
cumfit, cumse matrices of cumulative effects (along lags) and related standard errors for each value of predvar and lag. Computed if cumul=TRUE.
matRRfit exponentiated effects from matfit.
matRRlow, matRRhigh matrices with low and high 95% confidence intervals for matRRfit.
allRRfit exponentiated total effects from allfit.
cumRRfit exponentiated effects from cumfit. Computed if cumul=TRUE.
cumRRlow, cumRRhigh matrices with low and high 95% confidence intervals for cumRRfit. Computed if cumul=TRUE.
model.class class of the model command used for estimation.
model.link a specification for the model link function.

Warnings

The name of the object crossbasis will be used by to extract the related estimated parameters from model. This name must not match the names of other predictors in the model formula. In addition, if more than one variable is transformed by cross-basis functions in the same model, different names must be specified.

Note

All the effects are reported versus a reference value corresponding to the centering point for continuous functions or to the default values for the other options (see crossbasis). Exponentiated effects are included if model.link is equal to log or logit.

Author(s)

Antonio Gasparrini, antonio.gasparrini@lshtm.ac.uk

References

Armstrong, B. Models for the relationship between ambient temperature and daily mortality. Epidemiology. 2006, 17(6):624-31.

See Also

crossbasis, crossplot

Examples

# Example 2. See crossbasis and crossplot for other examples

### DLM with threshold for the effect of O3 on mortality up to 5 days of lag
### space of predictor: linear effect above 40.3 microgr/m3 for O3
### space of predictor: linear effects below 10C and above 25C for temperature
### lag function: integer lag parameterization (unconstrained) for O3
### lag function: strata intervals at lag 0-1, 2-6 and 7-15 for temperature

data(chicagoNMMAPS)
basis.o3 <- crossbasis(chicagoNMMAPS$o3, vartype="hthr", varknots=40.3,
        lagtype="integer", maxlag=5)
basis.temp <- crossbasis(chicagoNMMAPS$temp, vartype="dthr", varknots=c(10,25),
        lagtype="strata", lagknots=c(2,7), maxlag=15)
summary(basis.o3)
summary(basis.temp)
model <- glm(death ~  basis.o3 + basis.temp, family=quasipoisson(), chicagoNMMAPS)
pred.o3 <- crosspred(basis.o3, model, at=c(0:65,40.3,50.3))

crossplot(pred.o3, "slices", var=50.3,
        title="Effect of a 10-unit increase in ozone along lags")
# overall effect for a 10-unit increase in ozone over 15 days of lag, with CI
pred.o3$allRRfit["50.3"]
cbind(pred.o3$allRRlow, pred.o3$allRRhigh)["50.3",]
crossplot(pred.o3, label="Ozone", title="3D graph of ozone effect")
crossplot(pred.o3, "contour", label="Ozone", 
        title="Contour graph of ozone effect")

### alternatively, a piecewise linear effect above 35 microgr/m3 for o3,
###     with an additional change in slope at 50 microgr/m3
### same lag function as before

basis.o3 <- crossbasis(chicagoNMMAPS$o3, vartype="hthr", varknots=c(35,50),
        lagtype="integer", maxlag=5)
summary(basis.o3)
model <- update(model)
pred.o3 <- crosspred(basis.o3, model, at=c(0:65))

crossplot(pred.o3,"overall",label="Ozone",
        title="Overall effect of ozone over 5 days of lag")

### See the vignette 'dlnmOverview' for a detailed explanation of this example

[Package dlnm version 1.1.1 Index]