From 7b4a797de14ae74278f60a4fdea5ee88aece4f5e Mon Sep 17 00:00:00 2001 From: Matt Dancho Date: Tue, 22 Oct 2024 12:30:27 -0400 Subject: [PATCH] #225 adam_reg(): tuning ets_model and loss --- NAMESPACE | 2 ++ R/dials-adam_params.R | 47 +++++++++++++++++++++++++++++++++++++++++++ man/adam_params.Rd | 37 ++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 10d48291..cc7b3b09 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -186,6 +186,7 @@ export(enquo) export(enquos) export(error) export(ets_fit_impl) +export(ets_model) export(ets_predict_impl) export(exp_smoothing) export(expr) @@ -210,6 +211,7 @@ export(is_modeltime_table) export(is_residuals) export(juice_xreg_recipe) export(load_namespace) +export(loss) export(maape) export(maape_vec) export(make_ts_splits) diff --git a/R/dials-adam_params.R b/R/dials-adam_params.R index cb3babbc..bd5913a9 100644 --- a/R/dials-adam_params.R +++ b/R/dials-adam_params.R @@ -5,6 +5,26 @@ #' @details #' The main parameters for ADAM models are: #' +#' - `ets_model`: +#' - model="ZZZ" means that the model will be selected based on the chosen information criteria type. The Branch and Bound is used in the process. +#' - model="XXX" means that only additive components are tested, using Branch and Bound. +#' - model="YYY" implies selecting between multiplicative components. +#' - model="CCC" triggers the combination of forecasts of models using information criteria weights (Kolassa, 2011). +#' - combinations between these four and the classical components are also accepted. For example, model="CAY" will combine models with additive trend and either none or multiplicative seasonality. +#' - model="PPP" will produce the selection between pure additive and pure multiplicative models. "P" stands for "Pure". This cannot be mixed with other types of components. +#' - model="FFF" will select between all the 30 types of models. "F" stands for "Full". This cannot be mixed with other types of components. +#' - The parameter model can also be a vector of names of models for a finer tuning (pool of models). For example, model=c("ANN","AAA") will estimate only two models and select the best of them. +#' - `loss`: +#' - likelihood - the model is estimated via the maximization of the likelihood of the function specified in distribution; +#' - MSE (Mean Squared Error), +#' - MAE (Mean Absolute Error), +#' - HAM (Half Absolute Moment), +#' - LASSO - use LASSO to shrink the parameters of the model; +#' - RIDGE - use RIDGE to shrink the parameters of the model; +#' - TMSE - Trace Mean Squared Error, +#' - GTMSE - Geometric Trace Mean Squared Error, +#' - MSEh - optimisation using only h-steps ahead error, +#' - MSCE - Mean Squared Cumulative Error. #' - `non_seasonal_ar`: The order of the non-seasonal auto-regressive (AR) terms. #' - `non_seasonal_differences`: The order of integration for non-seasonal differencing. #' - `non_seasonal_ma`: The order of the non-seasonal moving average (MA) terms. @@ -32,6 +52,33 @@ #' @name adam_params +#' @export +#' @return A parameter +#' @rdname adam_params +ets_model <- function(values = c("ZZZ", "XXX", "YYY", "CCC", "PPP", "FFF")) { + dials::new_qual_param( + type = "character", + # default = FALSE, + values = values, + label = c(ets_model = "ETS Model"), + finalize = NULL + ) +} + +#' @export +#' @return A parameter +#' @rdname adam_params +loss <- function(values = c("likelihood", "MSE", "MAE", "HAM", "LASSO", "RIDGE", "TMSE", "GTMSE", "MSEh", "MSCE")) { + dials::new_qual_param( + type = "character", + # default = FALSE, + values = values, + label = c(ets_model = "Loss Function"), + finalize = NULL + ) +} + + #' @export #' @return A parameter #' @rdname adam_params diff --git a/man/adam_params.Rd b/man/adam_params.Rd index eab86ec3..96b3278f 100644 --- a/man/adam_params.Rd +++ b/man/adam_params.Rd @@ -2,6 +2,8 @@ % Please edit documentation in R/dials-adam_params.R \name{adam_params} \alias{adam_params} +\alias{ets_model} +\alias{loss} \alias{use_constant} \alias{regressors_treatment} \alias{outliers_treatment} @@ -11,6 +13,13 @@ \alias{select_order} \title{Tuning Parameters for ADAM Models} \usage{ +ets_model(values = c("ZZZ", "XXX", "YYY", "CCC", "PPP", "FFF")) + +loss( + values = c("likelihood", "MSE", "MAE", "HAM", "LASSO", "RIDGE", "TMSE", "GTMSE", + "MSEh", "MSCE") +) + use_constant(values = c(FALSE, TRUE)) regressors_treatment(values = c("use", "select", "adapt")) @@ -49,6 +58,10 @@ A parameter A parameter +A parameter + +A parameter + A parameter } \description{ @@ -57,6 +70,30 @@ Tuning Parameters for ADAM Models \details{ The main parameters for ADAM models are: \itemize{ +\item \code{ets_model}: +\itemize{ +\item model="ZZZ" means that the model will be selected based on the chosen information criteria type. The Branch and Bound is used in the process. +\item model="XXX" means that only additive components are tested, using Branch and Bound. +\item model="YYY" implies selecting between multiplicative components. +\item model="CCC" triggers the combination of forecasts of models using information criteria weights (Kolassa, 2011). +\item combinations between these four and the classical components are also accepted. For example, model="CAY" will combine models with additive trend and either none or multiplicative seasonality. +\item model="PPP" will produce the selection between pure additive and pure multiplicative models. "P" stands for "Pure". This cannot be mixed with other types of components. +\item model="FFF" will select between all the 30 types of models. "F" stands for "Full". This cannot be mixed with other types of components. +\item The parameter model can also be a vector of names of models for a finer tuning (pool of models). For example, model=c("ANN","AAA") will estimate only two models and select the best of them. +} +\item \code{loss}: +\itemize{ +\item likelihood - the model is estimated via the maximization of the likelihood of the function specified in distribution; +\item MSE (Mean Squared Error), +\item MAE (Mean Absolute Error), +\item HAM (Half Absolute Moment), +\item LASSO - use LASSO to shrink the parameters of the model; +\item RIDGE - use RIDGE to shrink the parameters of the model; +\item TMSE - Trace Mean Squared Error, +\item GTMSE - Geometric Trace Mean Squared Error, +\item MSEh - optimisation using only h-steps ahead error, +\item MSCE - Mean Squared Cumulative Error. +} \item \code{non_seasonal_ar}: The order of the non-seasonal auto-regressive (AR) terms. \item \code{non_seasonal_differences}: The order of integration for non-seasonal differencing. \item \code{non_seasonal_ma}: The order of the non-seasonal moving average (MA) terms.