Function constructs an advanced Single Source of Error model, based on ETS taxonomy and ARIMA elements
adam(data, model = "ZXZ", lags = c(frequency(data)), orders = list(ar =
c(0), i = c(0), ma = c(0), select = FALSE), constant = FALSE,
formula = NULL, regressors = c("use", "select", "adapt"),
occurrence = c("none", "auto", "fixed", "general", "odds-ratio",
"inverse-odds-ratio", "direct"), distribution = c("default", "dnorm",
"dlaplace", "ds", "dgnorm", "dlnorm", "dinvgauss", "dgamma"),
loss = c("likelihood", "MSE", "MAE", "HAM", "LASSO", "RIDGE", "MSEh",
"TMSE", "GTMSE", "MSCE"), outliers = c("ignore", "use", "select"),
level = 0.99, h = 0, holdout = FALSE, persistence = NULL,
phi = NULL, initial = c("backcasting", "optimal", "two-stage",
"complete"), arma = NULL, ic = c("AICc", "AIC", "BIC", "BICc"),
bounds = c("usual", "admissible", "none"), silent = TRUE, ...)# S3 method for adam
simulate(object, nsim = 1, seed = NULL,
obs = nobs(object), ...)
auto.adam(data, model = "ZXZ", lags = c(frequency(data)),
orders = list(ar = c(3, 3), i = c(2, 1), ma = c(3, 3), select = TRUE),
formula = NULL, regressors = c("use", "select", "adapt"),
occurrence = c("none", "auto", "fixed", "general", "odds-ratio",
"inverse-odds-ratio", "direct"), distribution = c("dnorm", "dlaplace",
"ds", "dgnorm", "dlnorm", "dinvgauss", "dgamma"), outliers = c("ignore",
"use", "select"), level = 0.99, h = 0, holdout = FALSE,
persistence = NULL, phi = NULL, initial = c("backcasting", "optimal",
"two-stage", "complete"), arma = NULL, ic = c("AICc", "AIC", "BIC",
"BICc"), bounds = c("usual", "admissible", "none"), silent = TRUE,
parallel = FALSE, ...)
# S3 method for adam
sm(object, model = "YYY", lags = NULL, orders = list(ar =
c(0), i = c(0), ma = c(0), select = FALSE), constant = FALSE,
formula = NULL, regressors = c("use", "select", "adapt"), data = NULL,
persistence = NULL, phi = NULL, initial = c("optimal", "backcasting"),
arma = NULL, ic = c("AICc", "AIC", "BIC", "BICc"), bounds = c("usual",
"admissible", "none"), silent = TRUE, ...)
Object of class "adam" is returned. It contains the list of the following values:
model
- the name of the constructed model,
timeElapsed
- the time elapsed for the estimation of the model,
data
- the in-sample part of the data used for the training of the model. Includes
the actual values in the first column,
holdout
- the holdout part of the data, excluded for purposes of model evaluation,
fitted
- the vector of fitted values,
residuals
- the vector of residuals,
forecast
- the point forecast for h steps ahead (by default NA is returned). NOTE
that these do not always correspond to the conditional expectations for ETS models. See ADAM
textbook, Section 6.4. for details (https://openforecast.org/adam/ETSTaxonomyMaths.html),
states
- the matrix of states with observations in rows and states in columns,
persisten
- the vector of smoothing parameters,
phi
- the value of damping parameter,
transition
- the transition matrix,
measurement
- the measurement matrix with observations in rows and state elements
in columns,
initial
- the named list of initial values, including level, trend, seasonal, ARIMA
and xreg components,
initialEstimated
- the named vector, defining which of the initials were estimated in
the model,
initialType
- the type of initialisation used (backcasting/optimal/two-stage/complete/provided),
orders
- the orders of ARIMA used in the estimation,
constant
- the value of the constant (if it was included),
arma
- the list of AR / MA parameters used in the model,
nParam
- the matrix of the estimated / provided parameters,
occurrence
- the oes model used for the occurrence part of the model,
formula
- the formula used for the explanatory variables expansion,
loss
- the type of loss function used in the estimation,
lossValue
- the value of that loss function,
logLik
- the value of the log-likelihood,
distribution
- the distribution function used in the calculation of the likelihood,
scale
- the value of the scale parameter,
lambda
- the value of the parameter used in LASSO / dalaplace / dt,
B
- the vector of all estimated parameters,
lags
- the vector of lags used in the model construction,
lagsAll
- the vector of the internal lags used in the model,
profile
- the matrix with the profile used in the construction of the model,
profileInitial
- the matrix with the initial profile (for the before the sample values),
call
- the call used in the evaluation,
bounds
- the type of bounds used in the process,
res
- result of the model estimation, the output of the nloptr()
function, explaining
how optimisation went,
other
- the list with other parameters, such as shape for distributions or ARIMA
polynomials.
Function estimates ADAM in a form of the Single Source of Error state space model of the following type:
$$y_{t} = o_t (w(v_{t-l}) + h(x_t, a_{t-1}) + r(v_{t-l}) \epsilon_{t})$$
$$v_{t} = f(v_{t-l}, a_{t-1}) + g(v_{t-l}, a_{t-1}, x_{t}) \epsilon_{t}$$
Where \(o_{t}\) is the Bernoulli distributed random variable (in case of normal data it equals to 1 for all observations), \(v_{t}\) is the state vector and \(l\) is the vector of lags, \(x_t\) is the vector of exogenous variables. w(.) is the measurement function, r(.) is the error function, f(.) is the transition function, g(.) is the persistence function and \(a_t\) is the vector of parameters for exogenous variables. Finally, \(\epsilon_{t}\) is the error term.
The implemented model allows introducing several seasonal states and supports
intermittent data via the occurrence
variable.
The error term \(\epsilon_t\) can follow different distributions, which
are regulated via the distribution
parameter. This includes:
default
- Normal distribution is used for the Additive error models,
Gamma is used for the Multiplicative error models.
dnorm - Normal distribution,
dlaplace - Laplace distribution,
ds - S distribution,
dgnorm - Generalised Normal distribution,
dlnorm - Log-Normal distribution,
dgamma - Gamma distribution,
dinvgauss - Inverse Gaussian distribution,
For some more information about the model and its implementation, see the
vignette: vignette("adam","smooth")
. The more detailed explanation
of ADAM is provided by Svetunkov (2021).
The function auto.adam()
tries out models with the specified
distributions and returns the one with the most suitable one based on selected
information criterion.
sm.adam method estimates the scale model for the already estimated adam. In order for ADAM to take the SM model into account, the latter needs to be recorded in the former, amending the likelihood and the number of degrees of freedom. This can be done using implant method.
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/.
Svetunkov, I., 2023. Smooth Forecasting with the Smooth Package in R. arXiv. tools:::Rd_expr_doi("10.48550/arXiv.2301.01790")
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., Boylan, J.E., 2023a. iETS: State Space Model for Intermittent Demand Forecastings. International Journal of Production Economics. 109013. tools:::Rd_expr_doi("10.1016/j.ijpe.2023.109013")
Teunter R., Syntetos A., Babai Z. (2011). Intermittent demand: Linking forecasting to inventory obsolescence. European Journal of Operational Research, 214, 606-615.
Croston, J. (1972) Forecasting and stock control for intermittent demands. Operational Research Quarterly, 23(3), 289-303.
Kolassa, S. (2011) Combining exponential smoothing forecasts using Akaike weights. International Journal of Forecasting, 27, pp 238 - 251.
Svetunkov, I., Boylan, J.E., 2023b. Staying Positive: Challenges and Solutions in Using Pure Multiplicative ETS Models. IMA Journal of Management Mathematics. p. 403-425. tools:::Rd_expr_doi("10.1093/imaman/dpad028")
Taylor, J.W. and Bunn, D.W. (1999) A Quantile Regression Approach to Generating Prediction Intervals. Management Science, Vol 45, No 2, pp 225-237.
Lichtendahl Kenneth C., Jr., Grushka-Cockayne Yael, Winkler Robert L., (2013) Is It Better to Average Probabilities or Quantiles? Management Science 59(7):1594-1611. DOI: tools:::Rd_expr_doi("10.1287/mnsc.1120.1667")
es, msarima
### The main examples are provided in the adam vignette, check it out via:
if (FALSE) vignette("adam","smooth")
# Model selection using a specified pool of models
ourModel <- adam(rnorm(100,100,10), model=c("ANN","ANA","AAA"), lags=c(5,10))
adamSummary <- summary(ourModel)
xtable(adamSummary)
forecast(ourModel)
par(mfcol=c(3,4))
plot(ourModel, c(1:11))
# Model combination using a specified pool
ourModel <- adam(rnorm(100,100,10), model=c("ANN","AAN","MNN","CCC"),
lags=c(5,10))
# ADAM ARIMA
ourModel <- adam(rnorm(100,100,10), model="NNN",
lags=c(1,4), orders=list(ar=c(1,0),i=c(1,0),ma=c(1,1)))
# Fit ADAM to the data
ourModel <- adam(rnorm(100,100,10), model="AAdN")
# Simulate the data
x <- simulate(ourModel)
# Automatic selection of appropriate distribution and orders of ADAM ETS+ARIMA
ourModel <- auto.adam(rnorm(100,100,10), model="ZZN", lags=c(1,4),
orders=list(ar=c(2,2),ma=c(2,2),select=TRUE))
Run the code above in your browser using DataLab