predict.mid {midr} | R Documentation |
Predict Method for fitted MID Models
Description
The method of predict()
for "mid" objects obtains predictions from a fitted MID model.
Usage
## S3 method for class 'mid'
predict(
object,
newdata = NULL,
na.action = "na.pass",
type = c("response", "link", "terms"),
terms = object$terms,
...
)
mid.f(object, term, x, y = NULL)
Arguments
object |
a "mid" object to be used to make predictions. |
newdata |
a data frame of the new observations. |
na.action |
a function or character string specifying what should happen when the data contain |
type |
the type of prediction required. The default is on the scale of the response varialbe. The alternative "link" is on the scale of the linear predictors. The "terms" option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale. |
terms |
a character vector of term labels, specifying a subset of component functions to be used to make predictions. |
... |
not used. |
term |
a character string specifying the component function of a fitted MID model. |
x |
a matrix, data frame or vector to be used as the input to the first argument of the component function. If a matrix or data frame is passed, inputs for both |
y |
a vector to be used as the input to the second argument of the component function. |
Details
The S3 method of predict()
for MID models returns the model predictions.
mid.f()
works as a component function of a MID model.
Value
predict.mid()
returns a numeric vector of MID model predictions.
Examples
data(trees, package = "datasets")
idx <- c(5L, 10L, 15L, 20L, 25L, 30L)
mid <- interpret(Volume ~ .^2, trees[-idx,], lambda = 1)
trees[idx, "Volume"]
predict(mid, trees[idx,])
predict(mid, trees[idx,], type = "terms")
mid.f(mid, "Girth", trees[idx,])
mid.f(mid, "Girth:Height", trees[idx,])
predict(mid, trees[idx,], terms = c("Girth", "Height"))