add_all_multivariate_forecast_models: Add all multivariate forecast models

Description Usage Arguments Value Examples

View source: R/INTRA_FORECAST_add_all_multivariate_forecast_models.R

Description

add_all_multivariate_forecast_models is a wrapper function to add multiple multivariate forecast models to a (named) list of forecast models. The forecast models are created based on multiple calls of the add-forecasting-model functions in the tsforecast package. The fc_methods parameter can be used to control which forecast models are added.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
add_all_multivariate_forecast_models(
  ts_object_train,
  ts_object_valid,
  fc_models = list(),
  periods_ahead = 1,
  periods_history = Inf,
  fc_methods = supported_fc_methods_multi_var(),
  keep_fc_model_objects = FALSE,
  verbose = FALSE,
  parallel = FALSE
)

Arguments

ts_object_train

A time series object, which contains only the training data.

ts_object_valid

A time series object, which contains the validation data. This is used for multivariate frameworks, thus it should have the forecasted/actual values of the external regressors as well.

fc_models

A named list of forecast models, with for each forecast model a list with the model itself and a table with forecast values.

periods_ahead

A positive integer value indicating the number of periods to forecast ahead.

periods_history

A positive integer value indicating the number of historic datapoints to use for training, which is only relevant for specific forecast methods such as drift and mean.

fc_methods

A character vector specifying the forecast methods to add. For more info `?supported_fc_methods`.

keep_fc_model_objects

Boolean, which is set to TRUE in order to keep original fc_model objects in the main_forecasting_table after running the forecast. This is needed for scenario analysis in multivariate forecasting. However, it may lead to memory issues, as the main_forecasting_table increases in size.

verbose

Boolean, which is set to TRUE if status updates are valued, or set to FALSE if they are not.

Value

A named list of forecast models, with for each forecast model a list with the model itself and a table with forecast values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
ts_object_train <- tstools::initialize_ts_forecast_data(
      data = dummy_gasprice,
      date_col = "year_month",
      col_of_interest = "gasprice",
      group_cols = c("state", "oil_company"),
      xreg_cols = c("spotprice", "gemprice")
   ) %>%
   dplyr::filter(grouping == "state = New York   &   oil_company = CompanyA") %>%
   dplyr::slice(1:179) %>%
   tstools::transform_data_to_ts_object()
ts_object_valid <- tstools::initialize_ts_forecast_data(
     data = dummy_gasprice,
     date_col = "year_month",
     col_of_interest = "gasprice",
     group_cols = c("state", "oil_company"),
     xreg_cols = c("spotprice", "gemprice")
   ) %>%
   dplyr::filter(grouping == "state = New York   &   oil_company = CompanyA") %>%
   dplyr::slice(180:191) %>%
   tstools::transform_data_to_ts_object()
res <- add_all_multivariate_forecast_models(
   ts_object_train = ts_object_train,
   ts_object_valid = ts_object_valid,
   periods_ahead = 12,
   verbose = T
)

ing-bank/tsforecast documentation built on Sept. 18, 2020, 9:40 a.m.