predict.nested_model_fit {nestedmodels} | R Documentation |
Nested Model Predictions
Description
Apply a fitted nested model to generate different types of predictions.
stats::predict()
/ parsnip::predict_raw()
methods for nested model fits.
Usage
## S3 method for class 'nested_model_fit'
predict(object, new_data, type = NULL, opts = list(), ...)
## S3 method for class 'nested_model_fit'
predict_raw(object, new_data, opts = list(), ...)
Arguments
object |
A |
new_data |
A data frame to make predictions on. Can be nested or non-nested. |
type |
A singular character vector or |
opts |
A list of optional arguments. Passed on to
|
... |
Arguments for the underlying model's predict function. Passed on
to |
Value
A data frame of model predictions. For predict_raw()
, a
matrix, data frame, vector or list.
See Also
Examples
library(dplyr)
library(tidyr)
library(parsnip)
data <- filter(example_nested_data, id %in% 5:15)
nested_data <- nest(data, data = -id)
model <- linear_reg() %>%
set_engine("lm") %>%
nested()
fitted <- fit(model, z ~ x + y + a + b, nested_data)
predict(fitted, example_nested_data)
predict_raw(fitted, example_nested_data)
[Package nestedmodels version 1.1.0 Index]