View source: R/modeltime-residuals.R
modeltime_residuals | R Documentation |
This is a convenience function to unnest model residuals
modeltime_residuals(object, new_data = NULL, quiet = TRUE, ...)
object |
A Modeltime Table |
new_data |
A |
quiet |
Hide errors ( |
... |
Not currently used. |
A tibble with residuals.
library(tidyverse)
library(lubridate)
library(timetk)
library(parsnip)
library(rsample)
# Data
m750 <- m4_monthly %>% filter(id == "M750")
# Split Data 80/20
splits <- initial_time_split(m750, prop = 0.9)
# --- MODELS ---
# Model 1: prophet ----
model_fit_prophet <- prophet_reg() %>%
set_engine(engine = "prophet") %>%
fit(value ~ date, data = training(splits))
# ---- MODELTIME TABLE ----
models_tbl <- modeltime_table(
model_fit_prophet
)
# ---- RESIDUALS ----
# In-Sample
models_tbl %>%
modeltime_calibrate(new_data = training(splits)) %>%
modeltime_residuals() %>%
plot_modeltime_residuals(.interactive = FALSE)
# Out-of-Sample
models_tbl %>%
modeltime_calibrate(new_data = testing(splits)) %>%
modeltime_residuals() %>%
plot_modeltime_residuals(.interactive = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.