
crosspred(crossbasis, model, at=NULL,
from=NULL, to=NULL, by=NULL, cumul=FALSE)
"crossbasis"
.TRUE
, cumulative effects are predicted. See details."crosspred"
with the following components:model
.predvar
and lag.predvar
.predvar
and lag. Computed if cumul=TRUE
.matfit
.matRRfit
.allfit
.cumfit
. Computed if cumul=TRUE
.cumRRfit
. Computed if cumul=TRUE
.crossbasis
object, some of them are discarded and the related parameters not included in model
. crosspred
will return an error. Check that the specification of the variables in crossbasis
is meaningful.
The name of the object crossbasis
will be used by to extract the related estimated parameters from model
. This name must not match the names of other predictors in the model formula. In addition, if more than one variable is transformed by cross-basis functions in the same model, different names must be specified.model
can be an object created by the following regression functions: lm
, glm
, gam
(package glm.nb
(package gee
(package clogit
and coxph
(package crossbasis
objects.
The object crossbasis
must be the same containing the cross-basis matrix included in model
, including its attributes and class. The set of values for which the effects must be computed can be specified by at
or alternatively by from
/to
/by
. If specified by at
, the values are automatically ordered and made unique. By default, from
and to
correspond to the range of the original vector of observation stored in the crossbasis
object (see crossbasis
). If by
is not provided, 30 equally spaced values are returned.
Matrices with cumulative effects summed upon lags for each values used for prediction are included if cumul=TRUE
. For a long lag series (i.e. 1000 lags) the routine can be slow. These matrices are required by crossplot
to graph the cumulative effects along lags.
For a detailed illustration of the use of the functions, see:
vignette("dlnmOverview")
crossbasis
, crossplot
# 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