Learn R Programming

dlnm (version 0.1.0)

crossplot: Plot predicted effects for a DLNM

Description

Plot several graphs (3d, slices and overall effects) of predicted effects from distributed lag non-linear models (DLNM).

Usage

crossplot(crosspred, type="3d", var=NULL, lag=NULL,
	ylim=NULL, title=NULL, label="var")

Arguments

crosspred
an object of class "crosspred".
type
type of plot. See Details below.
var
values of predictor for which specific effects must be plotted. Used only if type="slices".
lag
lag values for which specific effects must be plotted. Used only if type="slices".
ylim
numeric vectors of length 2, giving the y coordinates ranges. Used only if type="overall" or type="slices".
title
the main title on top of the plot.
label
label for predictor to be inserted in the plot.

Details

Different plots can be obtained choosing the following values for the argument type: "3d": a 3-D plot generated by calling the function persp. "overall": a plot of the overall effects (summed up all the single lag contributions). "slices": a multiple plot of effects at specific values of predictor or lags, chosen by var and lag, respectively. Up to 4 plots for each dimension are allowed. A vignette with a detailed overview of all the functionalities of the package will be added in the next releases.

References

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

See Also

crossbasis, crosspred

Examples

Run this code
# Example 3. See crossbasis and crosspred for other examples

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

### DLNM for the effect of temperature on mortality up to 30 days of lag
### space of predictor: 5df spline for temperature
### space of predictor: linear effect for PM10
### lag function: 5df spline for temperature
### lag function: single strata at lag 0-1 for PM10

basis.pm <- crossbasis(data$pm10,vartype="lin", lagtype="strata",
	cen=FALSE, maxlag=1)
basis.temp <- crossbasis(data$temp, vardf=5, lagdf=5,
	cenvalue=21, maxlag=30)
summary(basis.pm)
summary(basis.temp)
model <- glm(death ~  basis.pm + basis.temp, family=quasipoisson(), data)
pred.temp <- crosspred(basis.temp, model, at=-26:33)

crossplot(pred.temp, label="Temperature",
	title="3D graph of temperature effect")
crossplot(pred.temp, "overall", label="Temperature",
	title="Overall effect of temperature over 30 days of lag")
crossplot(pred.temp, "slices", var=c(-20,0,27,33),
	lag=c(0,5,15,28),	label="Temperature")

Run the code above in your browser using DataLab