R6 class ModelCompareBase
R6 class ModelCompareBase
new()
Initialize an object to compare several Univatiate Time Series Models
ModelCompareBase$new( data = NA, mdl_list, n.ahead = NA, batch_size = NA, step_n.ahead = TRUE, verbose = 0 )
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)
A new 'ModelCompareBase' object.
get_data()
Returns the time series realization
ModelCompareBase$get_data()
The Time Series Realization
get_data_var_interest()
Returns the dependent variable data only
ModelCompareBase$get_data_var_interest()
The dependent variable data only
get_batch_size()
Returns the batch size value
ModelCompareBase$get_batch_size()
The Batch Size Value
set_batch_size()
Sets the batch size value
ModelCompareBase$set_batch_size(batch_size)
batch_size
Batch Size Value
get_n.ahead()
Returns the n.ahead value
ModelCompareBase$get_n.ahead()
The n.ahead value
set_verbose()
Adjust the verbosity level
ModelCompareBase$set_verbose(verbose = 0)
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
get_model_names()
Get all the model names
ModelCompareBase$get_model_names(only_sliding = FALSE)
only_sliding
If TRUE, this will only plot the ASEs for the models that used window ASE calculations
A vector of all model names
add_models()
Add models to the existing object
ModelCompareBase$add_models(mdl_list, batch_size = -1)
mdl_list
The list of new models to add
batch_size
The batch size to use if model is using sliding ASE calculations
remove_models()
Remove models from the object
ModelCompareBase$remove_models(mdl_names)
mdl_names
A vector of the model names to remove.
keep_models()
Keep only the provided models
ModelCompareBase$keep_models(mdl_names)
mdl_names
A vector of the model names to keep.
compute_metrics()
Computes the Metrics for the models
ModelCompareBase$compute_metrics(step_n.ahead = TRUE)
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
plot_simple_forecasts()
Plots the simple forecast for each model
ModelCompareBase$plot_simple_forecasts( lastn = FALSE, newxreg = NA, limits = FALSE, zoom = NA, plot = TRUE )
lastn
If TRUE, this will plot the forecasts forthe last n.ahead values of the realization (Default: FALSE)
newxreg
The future exogenous variable values. Applicable to models that require the values of the new exogenous variables to be provided for future forecasts, e.g. nnfor::mlp()
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.
plot
If FALSE the plots are not plotted; useful when you want to just return the data (Default = TRUE)
plot_batch_forecasts()
Plots the forecasts per batch for all models
ModelCompareBase$plot_batch_forecasts( only_sliding = TRUE, plot = TRUE, silent = FALSE )
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
plot_batch_ases()
Plots the ASEs per batch for all models
ModelCompareBase$plot_batch_ases( only_sliding = TRUE, plot = TRUE, silent = FALSE )
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
plot_boxplot_ases()
Plots the boxplot of the ASE values for the models
ModelCompareBase$plot_boxplot_ases(plot = TRUE)
plot
If FALSE the plots are not plotted; useful when you want to just return the data (Default = TRUE)
statistical_compare()
Statistically compares the ASE values of the models using ANOVA and Tukey Adjustment for multiple comparison
ModelCompareBase$statistical_compare()
The results of the ANOVA test
get_tabular_metrics()
Gets the metrics and results in tabular format
ModelCompareBase$get_tabular_metrics(only_sliding = FALSE, ases = TRUE)
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
summarize_build()
Returns the model Build Summary (if applicable)
ModelCompareBase$summarize_build()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.