# Example 1. See crosspred and crossplot 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, pm10tmean+pm10mtrend)
### simple DLM for the effect of PM10 on mortality up to 15 days of lag
### space of predictor: linear effect for PM10
### space of predictor: 5df natural cubic spline for temperature
### lag function: 4th degree polynomial for PM10
### lag function: strata intervals at lag 0 and 1-3 for temperature
basis.pm <- crossbasis(data$pm10, vartype="lin", lagtype="poly",
lagdf=5,cen=FALSE,maxlag=15)
basis.temp <- crossbasis(data$temp, vardf=5, lagtype="strata",
lagknots=1, cenvalue=21, maxlag=3)
summary(basis.pm)
summary(basis.temp)
model <- glm(death ~ basis.pm + basis.temp, family=quasipoisson(), data)
pred.pm <- crosspred(basis.pm, model, at=0:20)
crossplot(pred.pm,"slices",var=10,
title="Effect 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",]
crossplot(pred.pm, "overall", ylim=c(0.99,1.04), label="PM10",
title="Overall effect of PM10 over 15 days of lag")
### See the vignette 'dlnmOverview' for a detailed explanation of this example
Run the code above in your browser using DataLab