Skip to contents

Add a Model into a Modeltime Table

Usage

add_modeltime_model(object, model, location = "bottom")

Arguments

object

Multiple Modeltime Tables (class mdl_time_tbl)

model

A model of class model_fit or a fitted workflow object

location

Where to add the model. Either "top" or "bottom". Default: "bottom".

See also

Examples

# \donttest{
library(tidymodels)
#> ── Attaching packages ────────────────────────────────────── tidymodels 1.3.0 ──
#>  broom        1.0.9      tibble       3.3.0
#>  dials        1.4.1      tidyr        1.3.1
#>  ggplot2      3.5.2      tune         1.3.0
#>  infer        1.0.9      workflows    1.3.0
#>  modeldata    1.5.1      workflowsets 1.1.1
#>  purrr        1.1.0      yardstick    1.3.2
#>  recipes      1.3.1     
#> ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
#>  yardstick::accuracy() masks smooth::accuracy(), greybox::accuracy()
#>  purrr::discard()      masks scales::discard()
#>  dplyr::filter()       masks stats::filter()
#>  dplyr::lag()          masks stats::lag()
#>  smooth::pls()         masks parsnip::pls()
#>  tidyr::spread()       masks greybox::spread()
#>  recipes::step()       masks stats::step()

model_fit_ets <- exp_smoothing() %>%
    set_engine("ets") %>%
    fit(value ~ date, training(m750_splits))
#> frequency = 12 observations per 1 year

m750_models %>%
    add_modeltime_model(model_fit_ets)
#> # Modeltime Table
#> # A tibble: 4 × 3
#>   .model_id .model     .model_desc            
#>       <int> <list>     <chr>                  
#> 1         1 <workflow> ARIMA(0,1,1)(0,1,1)[12]
#> 2         2 <workflow> PROPHET                
#> 3         3 <workflow> GLMNET                 
#> 4         4 <fit[+]>   ETS(A,A,A)             
# }