Learn R Programming

dlnm (version 1.6.2)

plot.crossreduce: Plot Predictions for a Reduced DLNM

Description

High and low-level method functions for graphs of predictions from reduced distributed lag non-linear models (DLNM).

Usage

## S3 method for class 'crossreduce':
plot(x, ci="area", ci.arg, ci.level=x$ci.level, exp=NULL, ...)

## S3 method for class 'crossreduce':
lines(x, ci="n", ci.arg, ci.level=x$ci.level, exp=NULL, ...)

## S3 method for class 'crossreduce':
points(x, ci="n", ci.arg, ci.level=x$ci.level, exp=NULL, ...)

Arguments

x
an object of class "crossreduce".
ci
type of confidence intervals representation: one of "area", "bars", "lines" or "n". Default to "area" in high level functions, "n" for low-level functions.
ci.arg
list of arguments to be passed to low-level plotting functions to draw the confidence intervals. See Details.
ci.level
confidence level for the computation of confidence intervals.
exp
logical. It forces the choice about the exponentiation of effects. See Details.
...
optional graphical arguments. See Details.

Details

Differently than for plotting functions for crosspred objects (see plot.crosspred), the type of the plot is automatically chosen by the dimension and values over which the model has been reduced. Namely, the overall or lag-specific effects along chosen values of the predictor, or predictor-specific effects along lags. These methods allow a great flexibility in the choice of graphical parameters, specified through arguments of the original plotting functions. See plot.default, lines and points for information on additional graphical arguments. Some arguments, if not specified, are set to different default values than the original functions. Confidence intervals are plotted for ptype equal to "overall" or "slices". Their type is determined by ci, with options "area" (default for plot), "bars", "lines" or "n" (no confidence intervals, default for points and lines). The appearance may be modified through ci.arg, a list of arguments passed to to low-level plotting functions: polygon for "area", segments for "bars" and lines for "lines". See the original functions for a complete list of the arguments. This option offers flexibility in the choice of confidence intervals display. As above, some unspecified arguments are set to different default values. For a detailed illustration of the use of the functions, see: vignette("dlnmOverview")

References

Gasparrini A., Armstrong, B., Kenward M. G. Reducing and meta-analyzing estimates from distributed lag non-linear models. 2012; (Submitted).

See Also

onebasis to generate simple basis matrices. crosspred to obtain predictions after model fitting. crossreduce to reduce the fit ot one dimension. See dlnm-package for an overview of the package and type 'vignette(dlnmOverview)' for a detailed description.

Examples

Run this code
# CREATE THE CROSS-BASIS: DOUBLE THRESHOLD AND NATURAL SPLINE
cb4 <- crossbasis(chicagoNMMAPS$temp, lag=30, argvar=list(type="dthr",
  knots=c(10,25)), arglag=list(df=5))

# RUN THE MODEL AND GET THE PREDICTION FOR TEMPERATURE
library(splines)
model4 <- glm(death ~  cb4 + ns(time, 7*14) + dow,
  family=quasipoisson(), chicagoNMMAPS)
pred4 <- crosspred(cb4, model4, by=1)

# REDUCE TO OVERALL ASSOCIATION
redall <- crossreduce(cb4, model4)
summary(redall)
# REDUCE TO LAG-SPECIFIC ASSOCIATION FOR LAG 5
redlag <- crossreduce(cb4, model4, type="lag", value=5)
# REDUCE TO PREDICTOR-SPECIFIC ASSOCIATION AT VALUE 33
redvar <- crossreduce(cb4, model4, type="var", value=33)

# NUMBER OF PARAMETERS OF THE ORIGINAL MODEL
length(coef(pred4))
# REDUCED NUMBER OF PARAMETERS FOR OVERALL AND LAG-SPECIFIC ASSOCIATIONS
length(coef(redall)) ; length(coef(redlag))
# REDUCED NUMBER OF PARAMETERS FOR PREDICTOR-SPECIFIC ASSOCIATIONS
length(coef(redvar))

# TEST: IDENTICAL FIT BETWEEN ORIGINAL AND REDUCED FIT
plot(pred4, "overall", xlab="Temperature", ylab="RR",
  ylim=c(0.8,1.6), main="Overall effects")
lines(redall, ci="lines",col=4,lty=2)
legend("top",c("Original","Reduced"),col=c(2,4),lty=1:2,ins=0.1)

# RECONSTRUCT THE FIT IN TERMS OF ONE-DIMENSIONAL BASIS
b4 <- onebasis(0:30,knots=attributes(cb4)$arglag$knots,int=TRUE,cen=FALSE)
pred4b <- crosspred(b4,coef=coef(redvar),vcov=vcov(redvar),model.link="log",by=1)

# TEST: IDENTICAL FIT BETWEEN ORIGINAL, REDUCED AND RE-CONSTRUCTED
plot(pred4, "slices", var=33, ylab="RR", ylim=c(0.9,1.2),
  main="Predictor-specific effects at 33C")
lines(redvar, ci="lines", col=4, lty=2)
points(pred4b, col=1, pch=19, cex=0.6)
legend("top",c("Original","Reduced","Reconstructed"),col=c(2,4,1),lty=c(1:2,NA),
  pch=c(NA,NA,19),pt.cex=0.6,ins=0.1)

Run the code above in your browser using DataLab