R6 class ModelCompareBase

R6 class ModelCompareBase

Methods

Public methods


Method new()

Initialize an object to compare several Univatiate Time Series Models

Usage

ModelCompareBase$new(
  data = NA,
  mdl_list,
  n.ahead = NA,
  batch_size = NA,
  step_n.ahead = TRUE,
  verbose = 0
)

Arguments

data

The dataframe containing the time series realizations (data should not contain time index)

mdl_list

A named list of all models (see format below)

n.ahead

The number of observations used to calculate ASE or forecast ahead

batch_size

If any of the models used sliding ase method, then this number indicates the batch size to use

step_n.ahead

If using sliding window, should batches be incremented by n.ahead (Default = TRUE)

verbose

How much to print during the model building and other processes (Default = 0)

Returns

A new `ModelCompareBase` object.


Method get_data()

Returns the time series realization

Usage

ModelCompareBase$get_data()

Returns

The Time Series Realization


Method get_data_var_interest()

Returns the dependent variable data only

Usage

ModelCompareBase$get_data_var_interest()

Returns

The dependent variable data only


Method get_batch_size()

Returns the batch size value

Usage

ModelCompareBase$get_batch_size()

Returns

The Batch Size Value


Method set_batch_size()

Sets the batch size value

Usage

ModelCompareBase$set_batch_size(batch_size)

Arguments

batch_size

Batch Size Value


Method get_n.ahead()

Returns the n.ahead value

Usage

ModelCompareBase$get_n.ahead()

Returns

The n.ahead value


Method set_verbose()

Adjust the verbosity level

Usage

ModelCompareBase$set_verbose(verbose = 0)

Arguments

verbose

0 = Minimal Printing only (usualy limited to step being performed) 1 = Basic printing of model builds, etc. 2 = Reserved for debugging mode. May slow down the run due to excessive printing, especially when using batches


Method get_model_names()

Get all the model names

Usage

ModelCompareBase$get_model_names(only_sliding = FALSE)

Arguments

only_sliding

If TRUE, this will only plot the ASEs for the models that used window ASE calculations

Returns

A vector of all model names


Method add_models()

Add models to the existing object

Usage

ModelCompareBase$add_models(mdl_list, batch_size = -1)

Arguments

mdl_list

The list of new models to add

batch_size

The batch size to use if model is using sliding ASE calculations


Method remove_models()

Remove models from the object

Usage

ModelCompareBase$remove_models(mdl_names)

Arguments

mdl_names

A vector of the model names to remove.


Method keep_models()

Keep only the provided models

Usage

ModelCompareBase$keep_models(mdl_names)

Arguments

mdl_names

A vector of the model names to keep.


Method compute_metrics()

Computes the Metrics for the models

Usage

ModelCompareBase$compute_metrics(step_n.ahead = TRUE)

Arguments

step_n.ahead

If TRUE, for rolling window calculations, the step size will be equal to n.ahead, else it will be equal to 1


Method plot_simple_forecasts()

Plots the simple forecast for each model

Usage

ModelCompareBase$plot_simple_forecasts(
  lastn = FALSE,
  limits = FALSE,
  zoom = NA
)

Arguments

lastn

If TRUE, this will plot the forecasts forthe last n.ahead values of the realization (Default: FALSE)

limits

If TRUE, this will also plot the lower and upper limits of the forecasts (Default: FALSE)

zoom

A number indicating how much to zoom into the plot. For example zoom = 50 will only plot the last 50 points of the realization Useful for cases where realizations that are long and n.ahead is small.


Method plot_batch_forecasts()

Plots the forecasts per batch for all models

Usage

ModelCompareBase$plot_batch_forecasts(
  only_sliding = TRUE,
  plot = TRUE,
  silent = FALSE
)

Arguments

only_sliding

If TRUE, this will only plot the batch forecasts for the models that used window ASE calculations

plot

If FALSE the plots are not plotted; useful when you want to just return the data (Default = TRUE)

silent

If FALSE, any warnings are suppressed


Method plot_batch_ases()

Plots the ASEs per batch for all models

Usage

ModelCompareBase$plot_batch_ases(
  only_sliding = TRUE,
  plot = TRUE,
  silent = FALSE
)

Arguments

only_sliding

If TRUE, this will only plot the ASEs for the models that used window ASE calculations

plot

If FALSE the plots are not plotted; useful when you want to just return the data (Default = TRUE)

silent

If FALSE, any warnings are suppressed


Method plot_boxplot_ases()

Plots the boxplot of the ASE values for the models

Usage

ModelCompareBase$plot_boxplot_ases(plot = TRUE)

Arguments

plot

If FALSE the plots are not plotted; useful when you want to just return the data (Default = TRUE)


Method statistical_compare()

Statistically compares the ASE values of the models using ANOVA and Tukey Adjustment for multiple comparison

Usage

ModelCompareBase$statistical_compare()

Returns

The results of the ANOVA test


Method get_tabular_metrics()

Gets the metrics and results in tabular format

Usage

ModelCompareBase$get_tabular_metrics(only_sliding = FALSE, ases = TRUE)

Arguments

only_sliding

If TRUE, this will only get results for models that use a sliding ASE calculation method. (Default: FALSE)

ases

If TRUE returns the ASE values for each batch. If FALSE returns the forecasts, and the lower and upper limits asscoiated with the forecasts


Method summarize_build()

Returns the model Build Summary (if applicable)

Usage

ModelCompareBase$summarize_build()