Learn R Programming

dlnm (version 0.3.0)

crosspred: 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 reports specific effects for each combination of values and lags, and overall effects (summed up along lags).

Usage

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

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.

Value

  • A list object of class "crosspred" with the following components:
  • predvarvector of observations used for prediction.
  • maxlaga positive value defining the maximum lag.
  • coef, vcovrelated coefficients and variance-covariance matrix from model.
  • matfit, matsematrices of effects and related standard errors for each value of predvar and lag.
  • allfit, allsevectors of total effects and related standard errors for each value of predvar.
  • matRRfitexponentiated effects from matfit.
  • matRRlow, matRRhighmatrices with low and high 95% confidence intervals for matRRfit.
  • allRRfitexponentiated total effects from allfit.
  • allRRlow, allRRhighvectors with low and high 95% confidence intervals for allRRfit.

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. In order to apply the same transformation as that used for the original predictor, the range of predvar must include the varknots for varbasis (see crossbasis).

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. For a detailed overview of the options, see: vignette("dlnmOverview", package = "dlnm")

References

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

See Also

crossbasis, crossplot

Examples

Run this code
# Example 2. See crossbasis and crossplot for other examples

# load and prepare the dataset
initDB()
data <- readCity("chic", collapseAge=TRUE)
data$temp <- (data$tmpd-32)*5/9
data$o3 <- with(data, o3tmean+o3mtrend)

### 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

basis.o3 <- crossbasis(data$o3, vartype="hthr", varknots=40.3,
	lagtype="integer", maxlag=5)
basis.temp <- crossbasis(data$temp, vartype="thr", 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(), data)
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")

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

Run the code above in your browser using DataLab