ces(data, seasonality=c("none","simple","partial","full"), initial=c("backcasting","optimal"), A=NULL, B=NULL, ic=c("AICc","AIC","BIC"), cfType=c("MSE","MAE","HAM","MLSTFE","MSTFE","MSEh"), h=10, holdout=FALSE, intervals=c("none","parametric","semiparametric","nonparametric"), level=0.95, intermittent=c("none","auto","fixed","croston","tsb","sba"), bounds=c("admissible","none"), silent=c("none","all","graph","legend","output"), xreg=NULL, xregDo=c("use","select"), initialX=NULL, updateX=FALSE, persistenceX=NULL, transitionX=NULL, ...)
none
- No seasonality; simple
- Simple seasonality, using lagged CES (based on t-m
observation, where m
is the seasonality lag); partial
- Partial seasonality with real seasonal components (equivalent to additive seasonality); full
- Full seasonality with complex seasonal components (can do both multiplicative and additive seasonality, depending on the data). First letter can be used instead of full words.
Any seasonal CES can only be constructed for time series vectors.
"optimal"
, meaning that the initial states are optimised, or "backcasting"
, meaning that the initials are produced using backcasting procedure (advised for data with high frequency).
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.
seasonality="partial"
. In case of seasonality="full"
must be complex number.
cfType
can be: MSE
(Mean Squared Error), MAE
(Mean Absolute Error), HAM
(Half Absolute Moment), MLSTFE
- Mean Log Squared Trace Forecast Error, MSTFE
- Mean Squared Trace Forecast Error and MSEh
- optimisation using only h-steps ahead error. If cfType!="MSE"
, then likelihood and model selection is done based on equivalent MSE
. Model selection in this cases becomes not optimal. There are also available analytical approximations for multistep functions: aMSEh
, aMSTFE
and aMLSTFE
. These can be useful in cases of small samples.
TRUE
, holdout sample of size h
is taken from the end of the data.
none
, aka n
- do not produce prediction intervals.
parametric
, p
- use state-space structure of ETS. In case of mixed models this is done using simulations, which may take longer time than for the pure additive and pure multiplicative models.
semiparametric
, sp
- intervals based on covariance matrix of 1 to h steps ahead errors and assumption of normal / log-normal distribution (depending on error type).
nonparametric
, np
- intervals based on values from a quantile regression on error matrix (see Taylor and Bunn, 1999). The model used in this process is e[j] = a j^b, where j=1,..,h.
The parameter also accepts TRUE
and FALSE
. Former means that parametric intervals are constructed, while latter is equivalent to none
.
none
, meaning that the data should be considered as non-intermittent; 2. fixed
, taking into account constant Bernoulli distribution of demand occurancies; 3. croston
, based on Croston, 1972 method with SBA correction; 4. tsb
, based on Teunter et al., 2011 method. 5. auto
- automatic selection of intermittency type based on information criteria. The first letter can be used instead. 6. "sba"
- Syntetos-Boylan Approximation for Croston's method (bias correction) discussed in Syntetos and Boylan, 2005.
silent="none"
, then nothing is silent, everything is printed out and drawn. silent="all"
means that nothing is produced or drawn (except for warnings). In case of silent="graph"
, no graph is produced. If silent="legend"
, then legend of the graph is skipped. And finally silent="output"
means that nothing is printed out in the console, but the graph is produced. silent
also accepts TRUE
and FALSE
. In this case silent=TRUE
is equivalent to silent="all"
, while silent=FALSE
is equivalent to silent="none"
. The parameter also accepts first letter of words ("n", "a", "g", "l", "o").
xreg
should have number of observations equal either to in-sample or to the whole series. If the number of observations in xreg
is equal to in-sample, then values for the holdout sample are produced using Naive.
"use"
means that all of the data should be used, whilie "select"
means that a selection using ic
should be done. "combine"
will be available at some point in future...
xreg
is NULL.
TRUE
, transition matrix for exogenous variables is estimated, introducing non-linear interractions between parameters. Prerequisite - non-NULL xreg
.
NULL
, then estimated. Prerequisite - non-NULL xreg
.
matrix(transition,nc,nc)
, where nc
is number of components in state vector. If NULL
, then estimated. Prerequisite - non-NULL xreg
.
model
can accept a previously estimated CES model and use all its parameters.
FI=TRUE
will make the function produce Fisher Information matrix, which then can be used to calculated variances of parameters of the model.
model
- type of constructed model.
timeElapsed
- time elapsed for the construction of the model.
states
- the matrix of the components of CES. The included minimum is "level" and "potential". In the case of seasonal model the seasonal component is also included. In the case of exogenous variables the estimated coefficients for the exogenous variables are also included.
A
- complex smoothing parameter in the form a0 + ia1
B
- smoothing parameter for the seasonal component. Can either be real (if seasonality="P"
) or complex (if seasonality="F"
) in a form b0 + ib1.
initialType
- Typetof initial values used.
initial
- the intial values of the state vector (non-seasonal).
nParam
- number of estimated parameters.
fitted
- the fitted values of CES.
forecast
- the point forecast of CES.
lower
- the lower bound of prediction interval. When intervals="none"
then NA is returned.
upper
- the upper bound of prediction interval. When intervals="none"
then NA is returned.
residuals
- the residuals of the estimated model.
errors
- The matrix of 1 to h steps ahead errors.
s2
- variance of the residuals (taking degrees of freedom into account).
intervals
- type of intervals asked by user.
level
- confidence level for intervals.
actuals
- The data provided in the call of the function.
holdout
- the holdout part of the original data.
iprob
- the fitted and forecasted values of the probability of demand occurrence.
intermittent
- type of intermittent model fitted to the data.
xreg
- provided vector or matrix of exogenous variables. If xregDo="s"
, then this value will contain only selected exogenous variables.
updateX
- boolean, defining, if the states of exogenous variables were estimated as well.
initialX
- initial values for parameters of exogenous variables.
persistenceX
- persistence vector g for exogenous variables.
transitionX
- transition matrix F for exogenous variables.
ICs
- values of information criteria of the model. Includes AIC, AICc, BIC and CIC (Complex IC).
logLik
- log-likelihood of the function.
cf
- Cost function value.
cfType
- Type of cost function used in the estimation.
FI
- Fisher Information. Equal to NULL if FI=FALSE
or when FI
is not provided at all.
accuracy
- the vector or accuracy measures for the holdout sample. Includes MPE, MAPE, SMAPE, MASE, MAE/mean, RelMAE and Bias coefficient (based on complex numbers). Available only when holdout=TRUE
.
ets, forecast, ts, auto.ces
y <- rnorm(100,10,3)
ces(y,h=20,holdout=TRUE)
ces(y,h=20,holdout=FALSE)
y <- 500 - c(1:100)*0.5 + rnorm(100,10,3)
ces(y,h=20,holdout=TRUE,intervals="p",bounds="a")
library("Mcomp")
y <- ts(c(M3$N0740$x,M3$N0740$xx),start=start(M3$N0740$x),frequency=frequency(M3$N0740$x))
ces(y,h=8,holdout=TRUE,seasonality="s",intervals="sp",level=0.8)
## Not run: y <- ts(c(M3$N1683$x,M3$N1683$xx),start=start(M3$N1683$x),frequency=frequency(M3$N1683$x))
# ces(y,h=18,holdout=TRUE,seasonality="s",intervals="sp")
# ces(y,h=18,holdout=TRUE,seasonality="p",intervals="np")
# ces(y,h=18,holdout=TRUE,seasonality="f",intervals="p")## End(Not run)
## Not run: x <- cbind(c(rep(0,25),1,rep(0,43)),c(rep(0,10),1,rep(0,58)))
# ces(ts(c(M3$N1457$x,M3$N1457$xx),frequency=12),h=18,holdout=TRUE,
# intervals="np",xreg=x,cfType="MSTFE")## End(Not run)
# Exogenous variables in CES
## Not run: x <- cbind(c(rep(0,25),1,rep(0,43)),c(rep(0,10),1,rep(0,58)))
# ces(ts(c(M3$N1457$x,M3$N1457$xx),frequency=12),h=18,holdout=TRUE,xreg=x)
# ourModel <- ces(ts(c(M3$N1457$x,M3$N1457$xx),frequency=12),h=18,holdout=TRUE,xreg=x,updateX=TRUE)
# # This will be the same model as in previous line but estimated on new portion of data
# ces(ts(c(M3$N1457$x,M3$N1457$xx),frequency=12),model=ourModel,h=18,holdout=FALSE)## End(Not run)
# Intermittent data example
x <- rpois(100,0.2)
# Best type of intermittent model based on iETS(Z,Z,N)
ourModel <- ces(x,intermittent="auto")
summary(ourModel)
forecast(ourModel)
plot(forecast(ourModel))
Run the code above in your browser using DataLab