predict.mid | R Documentation |
predict.mid()
is an S3 method for "mid" objects that obtains predictions from a fitted MID model.
It can be used to predict on new data or to retrieve the fitted values from the original data.
## S3 method for class 'mid'
predict(
object,
newdata = NULL,
na.action = "na.pass",
type = c("response", "link", "terms"),
terms = object$terms,
...
)
object |
a "mid" object to be used to make predictions. |
newdata |
a data frame of the new observations. If |
na.action |
a function or character string specifying what should happen when the data contain |
type |
the type of prediction required. One of "response", "link", or "terms". |
terms |
a character vector of term labels, specifying a subset of component functions to use for predictions. |
... |
arguments to be passed to other methods (not used in this method). |
The type
argument allows you to specify the scale of the prediction.
By default (type = "response"
), the function returns predictions on the original scale of the response variable.
Alternatively, you can obtain predictions on the scale of the linear predictor by setting type = "link"
.
For a detailed breakdown, setting type = "terms"
returns a matrix where each column represents the contribution of a specific model term on the linear predictor scale.
The terms
argument allows for predictions based on a subset of the model's component functions, excluding others.
predict.mid()
returns a numeric vector of MID model predictions, or a matrix if type = "terms"
.
interpret
, mid.effect
, get.yhat
data(airquality, package = "datasets")
test <- 1:10
mid <- interpret(Ozone ~ .^2, airquality[-test, ], lambda = 1, link = "log")
# Predict on new data
predict(mid, airquality[test, ])
# Get predictions on the link scale
predict(mid, airquality[test, ], type = "link")
# Get the contributions of specific terms
predict(mid, airquality[test, ], terms = c("Temp", "Wind"), type = "terms")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.