# Example 2. See crossbasis and crossplot for other examples
### seasonal analysis
### space of predictor: linear effect above 40.3 microgr/m3 for O3
### space of predictor: linear effects below 15C and above 25C for temperature
### lag function: integer lag parameterization (unconstrained) for O3 up to lag5
### lag function: strata intervals at lag 0-1, 2-5 and 6-10 for temperature
data(chicagoNMMAPS)
chicagoNMMAPSseas <- subset(chicagoNMMAPS, month>5 & month<10)
basis.o3 <- crossbasis(chicagoNMMAPSseas$o3, group=chicagoNMMAPSseas$year,
vartype="hthr", varknots=40.3, lagtype="integer", maxlag=5)
basis.temp <- crossbasis(chicagoNMMAPSseas$temp, group=chicagoNMMAPSseas$year,
vartype="dthr", varknots=c(15,25), lagtype="strata",
lagknots=c(2,6), maxlag=10)
summary(basis.o3)
summary(basis.temp)
model <- glm(death ~ basis.o3 + basis.temp + ns(doy, 4) + dow,
family=quasipoisson(), chicagoNMMAPSseas)
pred.o3 <- crosspred(basis.o3, model, at=c(0:65,40.3,50.3))
crossplot(pred.o3, "slices", var=50.3, ci="bars",
title="Effects of a 10-unit increase in ozone along lags")
crossplot(pred.o3,"overall",label="Ozone", ylim=c(0.9,1.3),
title="Overall effects of ozone over 5 days of lag")
# 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")
### See the vignette 'dlnmOverview' for a detailed explanation of this example
Run the code above in your browser using DataLab