Learn R Programming

dlnm (version 1.6.2)

crossreduce: Reduce the Fit of a DLNM to One Dimension

Description

Reduce the fit of a bi-dimensional DLNM to summaries defined in the the dimension of predictor or lags only, and re-expresses it in terms of modified parameters of the one-dimensional basis functions chosen for that space. Specifically, it summarizes lag-specific or overall predicted effects in the predictor dimension, or predictor-specific effects in the lag dimension. It returns the new parameters and predictions.

Usage

crossreduce(basis, model=NULL, type="overall", value=NULL, coef=NULL, vcov=NULL,
  model.link=NULL, at=NULL, from=NULL, to=NULL, by=NULL, bylag=1, ci.level=0.95)
  
## S3 method for class 'crossreduce':
summary(object, ...)

Arguments

basis
an object of class "crossbasis".
model
a model object for which the reduction and prediction are desired. See Details below.
coef, vcov, model.link
user-provided coefficients, (co)variance matrix and model link for the reduction and then prediction. See Details below.
type
type of reduction. Possible options are "overall" (default) or "lag" for reduction to the predictor space of overall or lag-specific effects, or "var" for reduction to the lag space of predictor-specific effects. See
value
the single value of predictor or lag for which predictor-specific or lag-specific functions must be defined, respectively. See Details below.
at
vector of values used for prediction in the dimension of predictor.
from, to
range of predictor values used for prediction.
by, bylag
increment of the sequences of predictor and lag values used for prediction.
ci.level
confidence level for the computation of confidence intervals.
object
an object of class "crossreduce".
...
additional arguments to be passed to summary.

Value

  • A list object of class "crossreduce" with the following (optional) components:
  • newcoef, newvcovreduced parameters of the original fitted model for the chosen dimension.
  • newbasisbasis matrix computed at predvar or for the sequence of lags defined by lag, depending on the chosen dimension.
  • type, valuetype of reduction and (optional) value, as arguments above.
  • predvarvector of observations used for prediction, if the reduction is in the dimension of predictor.
  • laginteger vector defining the lag range.
  • bylagincrement of the sequence of lag values.
  • fit, sevectors of predicted effects and related standard errors.
  • RRfitvector of exponentiated predicted effects from fit.
  • RRlow, RRhighvectors with low and high confidence intervals for RRfit.
  • ci.levelconfidence level used for the computation of confidence intervals.
  • model.classclass of the model command used for estimation.
  • model.linka specification for the model link function.

Warnings

In case of collinear variables in the basis object, some of them are discarded and the related parameters not included in model. Then, crossreduce will return an error. Check that the specification of the variables is meaningful through summary.crossbasis . The name of the object basis will be used to extract the related estimated parameters from object. If more than one variable is transformed by cross-basis functions in the same model, different names must be specified.

Details

model is the model object including basis. It must include methods for coef and vcov, applied to extract the parameters. For model classes without these methods, the user can manually extract the related parameters and include them in coef-vcov, also specifying model.link. In this case, the dimensions and order of the first two must match the variables included in basis. The dimension to which the fit is reduced is chosen by type, computing summaries for overall or lag-specific effects in the predictor dimension, or predictor-specific effects in the lag dimension. For specific effects, the value at which the reduction is computed is chosen by value. The function then re-express the original fit of the model, defined by the parameters of the bi-dimensional cross-basis functions, in summaries defined by the one-dimensional basis for the related space and a (usually smaller) set of modified parameters. Similarly to crosspred, the object basis must be the same containing the cross-basis matrix included in object, including its attributes and class. The optional arguments at and from/to/by provides the values for predicted effects when the reduction is in the dimension of predictor. bylag determines istead the increment of the sequence of lag values. Exponentiated outcomes and confidence intervals are also optionally returned. See crosspred for details. 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

crossbasis to generate cross-basis matrices. crosspred to obtain predictions after model fitting. plot.crossreduce to plot several the graphs. 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