train_models: Train models: CSR, LASSO, Bagging, Ensemble, RW and Benchmark

View source: R/train_models.R

train_modelsR Documentation

Train models: CSR, LASSO, Bagging, Ensemble, RW and Benchmark

Description

This function implements the cross-validation method with the models mentioned above. The Ensemble model is a simple average of the CSR and Bagging model predictions. The Benchmark model comes from columns in data, used to calculate the accuracy (RMSE) in relation to the observed y. Usually, these columns are external predictions (Focus) used in the model and as a benchmark.

Usage

train_models(
  data,
  y,
  init_window = 150,
  horizon = 12,
  K = 20,
  k = 15,
  R = 500,
  pre_testing = "group-joint",
  quiet = FALSE,
  benchmark_col_regex = "expectativa_ipca_h_\\d{1,2}$",
  benchmark_name = "Focus",
  ...
)

Arguments

data

A tsibble object

y

Column name of the variable of interest

init_window

Number of initial observations to be used in the first cross-validation subsample

horizon

Forecast horizon

K

Number of variables to be selected after the pre-testing. If K=ncol(x) the pre-testing is redundant (see HDeconometrics::csr).

k

Number of variables in each subset. Must be smaller than K (see HDeconometrics::csr).

R

Number of bootstrap replucations (see HDeconometrics::bagging).

pre_testing

The type of pre-testing (see HDeconometrics::bagging).

quiet

The default (FALSE) prints log messages to the Console.

benchmark_col_regex

Regex expression for internal selection of columns to take predictions from a "benchmark model". The number of columns must be at least 1 and at most equal to horizon, corresponding to the forecast horizons.

benchmark_name

Name to be given to the benchmark model.

...

Arguments passed to the HDeconometrics package

Value

Tibble

Examples

df_macro <- get_data(quiet = TRUE)
df_macro_augmented <- ts_transform(df_macro, "ipca")
seasonal_dummies <- names(df_macro_augmented[, names(df_macro_augmented) %in% month.abb])
acc <- train_models(df_macro_augmented, "ipca", fixed.controls = seasonal_dummies)

schoulten/ipca documentation built on May 27, 2022, 10:05 p.m.