predict.nested_model_fit | R Documentation |
Apply a fitted nested model to generate different types of predictions.
stats::predict()
/ parsnip::predict_raw()
methods for nested model fits.
## 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(), ...)
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 |
A data frame of model predictions. For predict_raw()
, a
matrix, data frame, vector or list.
parsnip::predict.model_fit()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.