Learn R Programming

dosresmeta (version 1.3.0)

predict.dosresmeta: Predicted Values from dosresmeta Models

Description

This method function computes predictions from fitted dose-response models represented in objects of class "dosresmeta", optionally for a new set of exposure levels. Predictions are optionally accompanied by confidence intervals and/or standard errors for the predictions.

Usage

## S3 method for class 'dosresmeta':
predict(object, newdata, xref, se.incl = FALSE,
  expo = TRUE, ci.incl = TRUE, ci.level = 0.95, order = TRUE, delta,
  ...)

Arguments

object
an object of class dosreseta.
newdata
an optional data frame or matrix in which to look for variables values with which to predict from dose-response models.
xref
an optional scalar to indicate which levels should serve as referent for the predicted relative risks. See details.
expo
logical switch indicating if the prediction should be on the exponential scale.
se.incl
logical switch indicating if standard errors need to be included.
ci.incl
logical switch indicating if confidence intervals need to be included.
ci.level
a numerical value between 0 and 1, specifying the confidence level for the computation of confidence intervals.
order
logical to indicate if the predictions need to be sorted by exposure levels.
delta
an optional scalar to specify to predict the linear trend related to that increase.
...
further arguments passed to or from other methods.

Value

  • The results are returned structured in a data frame.

Details

The method function predict produces predicted values from dosresmeta objects. When more than one study is included in the analysis, estimated predictions are only based on the fixed part of the model. If newdata is omitted, the predictions are based on the data used for the fit. If xref is provided, it must be equal to one of the modeled values. If not provided, the minimum modeled referent value will be used as referent for the predicted relative risks If newdata is specified, it should include all the variables used to model the dose-response relation. Again, if specified, xref must be equal to one of the value in the newdata. If omitted, the minimum value for the newdara will be used as referent. Only for the linear trend it is possible to specify the predicted increase of risk correspongind to an increase equal to delta argument. By default (order = TRUE), the predictions are sorted by exposure levels to facilitate understanding and possible graphical presentation of the results.

See Also

dosresmeta, predict

Examples

Run this code
## Load data and run the model
data("alcohol_cvd")
model <- dosresmeta(formula = logrr ~ dose + I(dose^2), type = type, id = id,
                   se = se, cases = cases, n = n, data = alcohol_cvd)

## Predicted modeled data
predict(model, order = FALSE)

## Plot predicted dose-response relation
with(predict(model), {
 plot(dose, pred, log = "y", type = "l",
      xlim = c(0, 45), ylim = c(.4, 2))
 lines(dose,  ci.lb, lty = 2)
 lines(dose, ci.ub, lty = 2)
 rug(dose, quiet = TRUE)
})

## Prediction for new values
newdata <- data.frame(dose = seq(0, 50, 1))
predict(model, newdata)

## Smoother plot
with(predict(model, newdata),{
 plot(dose, pred, log = "y", type = "l",
               ylim = c(.4, 2))
 lines(dose, ci.lb, lty = 2)
 lines(dose, ci.ub, lty = 2)
 rug(alcohol_cvd$dose, quiet = TRUE)
})

## Tabular results
newdata <- data.frame(dose = seq(0,50,5))
round(predict(model, newdata), 2)

Run the code above in your browser using DataLab