# Example 2. See crossbasis and crossplot for other examples
### 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
data(chicagoNMMAPS)
basis.o3 <- crossbasis(chicagoNMMAPS$o3, vartype="hthr", varknots=40.3,
lagtype="integer", maxlag=5)
basis.temp <- crossbasis(chicagoNMMAPS$temp, vartype="dthr", 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(), chicagoNMMAPS)
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")
### alternatively, a piecewise linear effect above 35 microgr/m3 for o3,
### with an additional change in slope at 50 microgr/m3
### same lag function as before
basis.o3 <- crossbasis(chicagoNMMAPS$o3, vartype="hthr", varknots=c(35,50),
lagtype="integer", maxlag=5)
summary(basis.o3)
model <- update(model)
pred.o3 <- crosspred(basis.o3, model, at=c(0:65))
crossplot(pred.o3,"overall",label="Ozone",
title="Overall effect of ozone over 5 days of lag")
### See the vignette 'dlnmOverview' for a detailed explanation of this example
Run the code above in your browser using DataLab