# Example 1. See crosspred and crossplot for other examples
### simple DLM
### space of predictor: linear effect for PM10
### space of predictor: 5df natural cubic spline for temperature
### lag function: 4th degree polynomial for PM10 up to lag15
### lag function: strata intervals at lag 0 and 1-3 for temperature
data(chicagoNMMAPS)
basis.pm <- crossbasis(chicagoNMMAPS$pm10, vartype="lin", lagtype="poly",
lagdegree=4, cen=FALSE, maxlag=15)
basis.temp <- crossbasis(chicagoNMMAPS$temp, vardf=5, lagtype="strata",
lagknots=1, cenvalue=21, maxlag=3)
summary(basis.pm)
summary(basis.temp)
model <- glm(death ~ basis.pm + basis.temp + ns(time, 7*14) + dow,
family=quasipoisson(), chicagoNMMAPS)
pred.pm <- crosspred(basis.pm, model, at=0:20, cumul=TRUE)
crossplot(pred.pm, "slices", var=10,
title="Effects of a 10-unit increase in PM10 along lags")
crossplot(pred.pm, "slices", var=10, cumul=TRUE,
title="Cumulative effects of a 10-unit increase in PM10 along lags")
# overall effect for a 10-unit increase in PM over 15 days of lag, with CI
pred.pm$allRRfit["10"]
cbind(pred.pm$allRRlow, pred.pm$allRRhigh)["10",]
### See the vignette 'dlnmOverview' for a detailed explanation of this example
Run the code above in your browser using DataLab