Extract predicted values via predict
from a model object, conditional on data
prediction(model, data, type = c("response", "link"))
A data.frame over which to calculate marginal effects.
A character string indicating the type of marginal effects to estimate. Mostly relevant for non-linear models, where the reasonable options are “response” (the default) or “link” (i.e., on the scale of the linear predictor in a GLM).
An data.frame with number of rows equal to number of rows in data
, where each row is an observation and the two columns represent fitted/predicted values and the standard errors thereof.
require("datasets")
x <- lm(mpg ~ cyl * hp + wt, data = mtcars)
prediction(x)
This function is simply a wrapper around predict
that returns a data.frame containing predicted values with respect to all variables specified in data
. It is used internally by build_margins
.