Function estimates CES in state space form with information potential equal to errors and returns several variables.
ces(data, seasonality = c("none", "simple", "partial", "full"),
lags = c(frequency(data)), formula = NULL, regressors = c("use",
"select", "adapt"), initial = c("backcasting", "optimal", "complete"),
a = NULL, b = NULL, loss = c("likelihood", "MSE", "MAE", "HAM", "MSEh",
"TMSE", "GTMSE", "MSCE"), h = 0, holdout = FALSE,
bounds = c("admissible", "none"), silent = TRUE, model = NULL, ...)auto.ces(data, seasonality = c("none", "simple", "partial", "full"),
lags = c(frequency(data)), formula = NULL, regressors = c("use",
"select", "adapt"), initial = c("backcasting", "optimal", "complete"),
ic = c("AICc", "AIC", "BIC", "BICc"), loss = c("likelihood", "MSE",
"MAE", "HAM", "MSEh", "TMSE", "GTMSE", "MSCE"), h = 0, holdout = FALSE,
bounds = c("admissible", "none"), silent = TRUE, ...)
ces_old(data, seasonality = c("none", "simple", "partial", "full"),
initial = c("backcasting", "optimal"), a = NULL, b = NULL,
ic = c("AICc", "AIC", "BIC", "BICc"), loss = c("likelihood", "MSE",
"MAE", "HAM", "MSEh", "TMSE", "GTMSE", "MSCE"), h = 10, holdout = FALSE,
bounds = c("admissible", "none"), silent = c("all", "graph", "legend",
"output", "none"), ...)
Object of class "adam" is returned with similar elements to the adam function.
Vector, containing data needed to be forecasted. If a matrix (or
data.frame / data.table) is provided, then the first column is used as a
response variable, while the rest of the matrix is used as a set of explanatory
variables. formula
can be used in the latter case in order to define what
relation to have.
The type of seasonality used in CES. Can be: none
- No seasonality; simple
- Simple seasonality, using lagged CES
(based on t-m
observation, where m
is the seasonality lag);
partial
- Partial seasonality with the real seasonal component
(equivalent to additive seasonality); full
- Full seasonality with
complex seasonal component (can do both multiplicative and additive
seasonality, depending on the data). First letter can be used instead of
full words.
In case of the auto.ces()
function, this parameter defines which models
to try.
Vector of lags to use in the model. Allows defining multiple seasonal models.
Formula to use in case of explanatory variables. If NULL
,
then all the variables are used as is. Can also include trend
, which would add
the global trend. Only needed if data
is a matrix or if trend
is provided.
The variable defines what to do with the provided explanatory
variables:
"use"
means that all of the data should be used, while
"select"
means that a selection using ic
should be done,
"adapt"
will trigger the mechanism of time varying parameters for the
explanatory variables.
Should be a character, which can be "optimal"
,
meaning that all initial states are optimised, or "backcasting"
,
meaning that the initials of dynamic part of the model are produced using
backcasting procedure (advised for data with high frequency). In the latter
case, the parameters of the explanatory variables are optimised. This is
recommended for CESX. Alternatively, you can set initial="complete"
backcasting, which means that all states (including explanatory variables)
are initialised via backcasting.
First complex smoothing parameter. Should be a complex number.
NOTE! CES is very sensitive to a and b values so it is advised either to leave them alone, or to use values from previously estimated model.
Second complex smoothing parameter. Can be real if
seasonality="partial"
. In case of seasonality="full"
must be
complex number.
The type of Loss Function used in optimization. loss
can
be:
likelihood
- the model is estimated via the maximisation 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.
In case of LASSO / RIDGE, the variables are not normalised prior to the estimation, but the parameters are divided by the mean values of explanatory variables.
Note that model selection and combination works properly only for the default
loss="likelihood"
.
Furthermore, just for fun the absolute and half analogues of multistep estimators
are available: MAEh
, TMAE
, GTMAE
, MACE
,
HAMh
, THAM
, GTHAM
, CHAM
.
Last but not least, user can provide their own function here as well, making sure
that it accepts parameters actual
, fitted
and B
. Here is an
example:
lossFunction <- function(actual, fitted, B) return(mean(abs(actual-fitted)))
loss=lossFunction
The forecast horizon. Mainly needed for the multistep loss functions.
Logical. If TRUE
, then the holdout of the size h
is taken from the data (can be used for the model testing purposes).
The type of bounds for the persistence to use in the model
estimation. Can be either admissible
- guaranteeing the stability of the
model, or none
- no restrictions (potentially dangerous).
Specifies, whether to provide the progress of the function or not.
If TRUE
, then the function will print what it does and how much it has
already done.
A previously estimated GUM model, if provided, the function will not estimate anything and will use all its parameters.
Other non-documented parameters. See adam for
details. However, there are several unique parameters passed to the optimiser
in comparison with adam
:
1. algorithm0
, which defines what algorithm to use in nloptr for the initial
optimisation. By default, this is "NLOPT_LN_BOBYQA".
2. algorithm
determines the second optimiser. By default this is
"NLOPT_LN_NELDERMEAD".
3. maxeval0 and maxeval, that determine the number of iterations for the two
optimisers. By default, maxeval0=1000
, maxeval=40*k
, where
k is the number of estimated parameters.
4. xtol_rel0 and xtol_rel, which are 1e-8 and 1e-6 respectively.
There are also ftol_rel0, ftol_rel, ftol_abs0 and ftol_abs, which by default
are set to values explained in the nloptr.print.options()
function.
The information criterion to use in the model selection.
Ivan Svetunkov, ivan@svetunkov.com
The function estimates Complex Exponential Smoothing in the state space form described in Svetunkov et al. (2022) with the information potential equal to the approximation error.
The auto.ces()
function implements the automatic seasonal component
selection based on information criteria.
ces_old()
is the old implementation of the model and will be discontinued
starting from smooth v4.5.0.
ces()
uses two optimisers to get good estimates of parameters. By default
these are BOBYQA and then Nelder-Mead. This can be regulated via ...
- see
details below.
For some more information about the model and its implementation, see the
vignette: vignette("ces","smooth")
Svetunkov I. (2023) Smooth forecasting with the smooth package in R. arXiv:2301.01790. tools:::Rd_expr_doi("10.48550/arXiv.2301.01790").
Svetunkov I. (2015 - Inf) "smooth" package for R - series of posts about the underlying models and how to use them: https://openforecast.org/category/r-en/smooth/.
Svetunkov, I. (2023). Forecasting and Analytics with the Augmented Dynamic Adaptive Model (ADAM) (1st ed.). Chapman and Hall/CRC. tools:::Rd_expr_doi("10.1201/9781003452652"), online version: https://openforecast.org/adam/.
Snyder, R. D., 1985. Recursive Estimation of Dynamic Linear Models. Journal of the Royal Statistical Society, Series B (Methodological) 47 (2), 272-276.
Hyndman, R.J., Koehler, A.B., Ord, J.K., and Snyder, R.D. (2008) Forecasting with exponential smoothing: the state space approach, Springer-Verlag. tools:::Rd_expr_doi("10.1007/978-3-540-71918-2").
Svetunkov, I., Kourentzes, N., & Ord, J. K. (2022). Complex exponential smoothing. Naval Research Logistics, 69(8), 1108–1123. https://doi.org/10.1002/nav.22074
adam, es
y <- rnorm(100,10,3)
ces(y, h=20, holdout=FALSE)
y <- 500 - c(1:100)*0.5 + rnorm(100,10,3)
ces(y, h=20, holdout=TRUE)
ces(BJsales, h=8, holdout=TRUE)
ces(AirPassengers, h=18, holdout=TRUE, seasonality="s")
ces(AirPassengers, h=18, holdout=TRUE, seasonality="p")
ces(AirPassengers, h=18, holdout=TRUE, seasonality="f")
y <- ts(rnorm(100,10,3),frequency=12)
# CES with and without holdout
auto.ces(y,h=20,holdout=TRUE)
auto.ces(y,h=20,holdout=FALSE)
# Selection between "none" and "full" seasonalities
auto.ces(AirPassengers, h=12, holdout=TRUE,
seasonality=c("n","f"), ic="AIC")
ourModel <- auto.ces(AirPassengers)
summary(ourModel)
forecast(ourModel, h=12)
Run the code above in your browser using DataLab