Skip to contents

This is a boilerplate function to create automatically the following:

  • recipe

  • model specification

  • workflow

  • tuned model (grid ect)

  • calibration tibble and plot

Usage

ts_auto_croston(
  .data,
  .date_col,
  .value_col,
  .formula,
  .rsamp_obj,
  .prefix = "ts_croston",
  .tune = TRUE,
  .grid_size = 10,
  .num_cores = 1,
  .cv_assess = 12,
  .cv_skip = 3,
  .cv_slice_limit = 6,
  .best_metric = "rmse",
  .bootstrap_final = FALSE
)

Arguments

.data

The data being passed to the function. The time-series object.

.date_col

The column that holds the datetime.

.value_col

The column that has the value

.formula

The formula that is passed to the recipe like value ~ .

.rsamp_obj

The rsample splits object

.prefix

Default is ts_exp_smooth

.tune

Defaults to TRUE, this creates a tuning grid and tuned model.

.grid_size

If .tune is TRUE then the .grid_size is the size of the tuning grid.

.num_cores

How many cores do you want to use. Default is 1

.cv_assess

How many observations for assess. See timetk::time_series_cv()

.cv_skip

How many observations to skip. See timetk::time_series_cv()

.cv_slice_limit

How many slices to return. See timetk::time_series_cv()

.best_metric

Default is "rmse". See modeltime::default_forecast_accuracy_metric_set()

.bootstrap_final

Not yet implemented.

Value

A list

Details

This uses the forecast::croston() for the parsnip engine. This model does not use exogenous regressors, so only a univariate model of: value ~ date will be used from the .date_col and .value_col that you provide.

Author

Steven P. Sanderson II, MPH

Examples

if (FALSE) {
library(dplyr)

data <- AirPassengers %>%
  ts_to_tbl() %>%
  select(-index)

splits <- time_series_split(
  data
  , date_col
  , assess = 12
  , skip = 3
  , cumulative = TRUE
)

ts_exp <- ts_auto_croston(
  .data = data,
  .num_cores = 5,
  .date_col = date_col,
  .value_col = value,
  .rsamp_obj = splits,
  .formula = value ~ .,
  .grid_size = 20
)

ts_exp$recipe_info
}