Learn R Programming

smooth (version 1.9.9)

ves: NOT AVAILABLE YET: Vector Exponential Smoothing in SSOE state-space model

Description

Function constructs vector ETS model and returns forecast, fitted values, errors and matrix of states along with other useful variables. THIS IS CURRENTLY UNDER CONSTRUCTION!

Usage

ves(data, model = "ANN", persistence = c("individual", "group"),
  transition = c("individual", "group"), measurement = c("individual",
  "group"), initial = c("individual", "group"),
  initialSeason = c("individual", "group"), cfType = c("MSE", "MAE", "HAM",
  "GMSTFE", "MSTFE", "MSEh", "TFL"), ic = c("AICc", "AIC", "BIC"), h = 10,
  holdout = FALSE, intervals = c("none", "parametric", "semiparametric",
  "nonparametric"), level = 0.95, intermittent = c("none", "auto", "fixed",
  "croston", "tsb", "sba"), bounds = c("usual", "admissible", "none"),
  silent = c("none", "all", "graph", "legend", "output"), xreg = NULL,
  xregDo = c("use", "select"), initialX = NULL, updateX = FALSE,
  persistenceX = NULL, transitionX = NULL, ...)

Arguments

data

is the matrix with data, where series are in columns and observations are in rows.

model

The type of ETS model. Can consist of 3 or 4 chars: ANN, AAN, AAdN, AAA, AAdA, MAdM etc. ZZZ means that the model will be selected based on the chosen information criteria type. ATTENTION! NO MODEL SELECTION IS AVAILABLE AT THIS STAGE!

Also model can accept a previously estimated VES model and use all its parameters.

Keep in mind that model selection with "Z" components uses Branch and Bound algorithm and may skip some models that could have slightly smaller information criteria.

persistence

Persistence vector \(g\), containing smoothing parameters. Can either be individual for each series or group, equal to all the time series. If a value is provided, then it is used by the model.

transition

Transition matrix \(F\). Can either be individual for each series or group, equal to all the time series. If vector or a matrix is provided here, then it is used by the model.

measurement

Measurement vector \(w\). Can either be individual for each series or group, equal to all the time series. If vector is provided here, then it is used by the model.

initial

Can be either character or a vector / matrix of initial states. If it is character, then it can be "individual", individual values of the intial non-seasonal components are udes, or "group", meaning that the initials for all the time series are set to be equal to the same value. If vector of states is provided, then it is automatically transformed into a matrix, assuming that these values are provided for the whole group.

initialSeason

Can be either character or a vector / matrix of initial states. Treated the same way as initial. This means that different time series may share the same initial seasonal component.

cfType

Type of Cost Function used in optimization. cfType can be: MSE (Mean Squared Error), MAE (Mean Absolute Error), HAM (Half Absolute Moment), GMSTFE - Mean Log Squared Trace Forecast Error, MSTFE - Mean Squared Trace Forecast Error and MSEh - optimisation using only h-steps ahead error, TFL - trace forecast likelihood. 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 aGMSTFE. These can be useful in cases of small samples.

ic

The information criterion used in the model selection procedure.

h

Length of forecasting horizon.

holdout

If TRUE, holdout sample of size h is taken from the end of the data.

intervals

Type of intervals to construct. This can be:

  • 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.

level

Confidence level. Defines width of prediction interval.

intermittent

Defines type of intermittent model used. Can be: 1. 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.

bounds

What type of bounds to use in the model estimation. The first letter can be used instead of the whole word.

silent

If 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

Vector (either numeric or time series) or matrix (or data.frame) of exogenous variables that should be included in the model. If matrix included than columns should contain variables and rows - observations. Note that 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 es function.

xregDo

Variable defines what to do with the provided xreg: "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...

initialX

Vector of initial parameters for exogenous variables. Ignored if xreg is NULL.

updateX

If TRUE, transition matrix for exogenous variables is estimated, introducing non-linear interractions between parameters. Prerequisite - non-NULL xreg.

persistenceX

Persistence vector \(g_X\), containing smoothing parameters for exogenous variables. If NULL, then estimated. Prerequisite - non-NULL xreg.

transitionX

Transition matrix \(F_x\) for exogenous variables. Can be provided as a vector. Matrix will be formed using the default matrix(transition,nc,nc), where nc is number of components in state vector. If NULL, then estimated. Prerequisite - non-NULL xreg.

...

Other non-documented parameters. For example FI=TRUE will make the function also produce Fisher Information matrix, which then can be used to calculated variances of smoothing parameters and initial states of the model. Parameters C, CLower and CUpper can be passed via ellipsis as well. In this case they will be used for optimisation. C sets the initial values before the optimisation, CLower and CUpper define lower and upper bounds for the search inside of the specified bounds. These values should have exactly the length equal to the number of parameters to estimate.

Value

Object of class "smooth" is returned. It contains a list of values.

Details

Function estimates vector ETS in a form of the Single Source of Error State-space model of the following type:

$$ \mathbf{y}_{t} = \mathbf{o}_{t} (\mathbf{W} \mathbf{v}_{t-l} + \mathbf{x}_t \mathbf{a}_{t-1} + \mathbf{\epsilon}_{t}) $$

$$ \mathbf{v}_{t} = \mathbf{F} \mathbf{v}_{t-l} + \mathbf{G} \mathbf{\epsilon}_{t} $$

$$\mathbf{a}_{t} = \mathbf{F_{X}} \mathbf{a}_{t-1} + \mathbf{G_{X}} \mathbf{\epsilon}_{t} / \mathbf{x}_{t}$$

Where \(y_{t}\) is the vector of time series on observation \(t\), \(o_{t}\) is the vector of Bernoulli distributed random variable (in case of normal data it becomes unit vector for all observations), \(\mathbf{v}_{t}\) is the matrix of states and \(l\) is the matrix of lags, \(\mathbf{x}_t\) is the vector of exogenous variables. \(\mathbf{W}\) is the measurement matrix, \(\mathbf{F}\) is the transition matrix and \(\mathbf{G}\) is the persistence matrix. Finally, \(\epsilon_{t}\) is the vector of error terms.

Conventionally we formulate values as:

$$\mathbf{y}'_t = (y_{1,t}, y_{2,t}, \dots, y_{m,t})$$ where \(m\) is the number of series in the group. $$\mathbf{v}'_t = (v_{1,t}, v_{2,t}, \dots, v_{m,t})$$ where \(v_{i,t}\) is vector of components for i-th time series. $$\mathbf{W}' = (w_{1}, \dots , 0; \vdots , \ddots , \vdots; 0 , \vdots , w_{m})$$ is matrix of measurement vectors.

For the details see Hyndman et al. (2008), chapter 17.

References

  • 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. http://www.exponentialsmoothing.net.

  • 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.

  • Syntetos, A., Boylan J. (2005) The accuracy of intermittent demand estimates. International Journal of Forecasting, 21(2), 303-314.

  • Kolassa, S. (2011) Combining exponential smoothing forecasts using Akaike weights. International Journal of Forecasting, 27, pp 238 - 251.

  • 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.

See Also

es, ets, forecast

Examples

Run this code

library(Mcomp)

es(M3$N2568$x,model="MAM",h=18,holdout=TRUE)


Run the code above in your browser using DataLab