## 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