# Example 3. See crossbasis and crosspred for other examples
### DLNM for the effect of temperature on mortality up to 30 days of lag
### space of predictor: 5df quadratic spline for temperature
### space of predictor: linear effect for PM10
### lag function: 5df natural cubic spline for temperature
### lag function: single strata at lag 0-1 for PM10
data(chicagoNMMAPS)
basis.pm <- crossbasis(chicagoNMMAPS$pm10,vartype="lin", lagtype="strata",
cen=FALSE, maxlag=1)
basis.temp <- crossbasis(chicagoNMMAPS$temp, vartype="bs", vardf=5, vardegree=2,
lagdf=5, cenvalue=21, maxlag=30)
summary(basis.pm)
summary(basis.temp)
model <- glm(death ~ basis.pm + basis.temp, family=quasipoisson(), chicagoNMMAPS)
pred.temp <- crosspred(basis.temp, model, at=-26:33, cumul=TRUE)
crossplot(pred.temp, label="Temperature",
title="3D graph of temperature effect")
crossplot(pred.temp, "contour", label="Temperature",
title="Contour 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")
crossplot(pred.temp, "slices", cum=TRUE, ci="bars", var=-20,
label="Temperature", title="Cumulative effect for -20C along lags")
### See the vignette 'dlnmOverview' for a detailed explanation of this example
Run the code above in your browser using DataLab