Function constructs vector ETS model and returns forecast, fitted values, errors and matrix of states along with other useful variables.
ves(data, model = "ANN", persistence = c("group", "independent",
"dependent"), transition = c("group", "independent", "dependent"),
phi = c("group", "individual"), initial = c("individual", "group"),
initialSeason = c("group", "individual"), cfType = c("likelihood",
"diagonal", "trace"), ic = c("AICc", "AIC", "BIC"), h = 10,
holdout = FALSE, intervals = c("none", "conditional", "unconditional",
"independent"), level = 0.95, cumulative = FALSE,
intermittent = c("none", "fixed", "logistic"), imodel = "ANN",
iprobability = c("dependent", "independent"), bounds = c("admissible",
"none"), silent = c("all", "graph", "output", "none"), ...)
The matrix with data, where series are in columns and observations are in rows.
The type of ETS model. Can consist of 3 or 4 chars: ANN
,
AAN
, AAdN
, AAA
, AAdA
, MMdM
etc.
ZZZ
means that the model will be selected based on the chosen
information criteria type.
ATTENTION! ONLY PURE ADDITIVE AND PURE MULTIPLICATIVE MODELS ARE CURRENTLY
AVAILABLE + NO MODEL SELECTION IS AVAILABLE AT THIS STAGE!
Pure multiplicative models are done as additive model applied to log(data).
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 matrix \(G\), containing smoothing parameters. Can be:
independent
- each series has its own smoothing parameters
and no interactions are modelled (all the other values in the matrix are set
to zero);
dependent
- each series has its own smoothing parameters, but
interactions between the series are modelled (the whole matrix is estimated);
group
each series has the same smoothing parameters for respective
components (the values of smoothing parameters are repeated, all the other values
in the matrix are set to zero).
provided by user as a vector or as a matrix. The value is used by the model.
Transition matrix \(F\). Can be:
independent
- each series has its own preset transition matrix
and no interactions are modelled (all the other values in the matrix are set
to zero);
dependent
- each series has its own transition matrix, but
interactions between the series are modelled (the whole matrix is estimated). The
estimated model behaves similar to VAR in this case;
group
each series has the same transition matrix for respective
components (the values are repeated, all the other values in the matrix are set to
zero).
provided by user as a vector or as a matrix. The value is used by the model.
In cases of damped trend this parameter defines whether the \(phi\)
should be estimated separately for each series (individual
) or for the whole
set (group
). If vector or a value is provided here, then it is used by the
model.
Can be either character or a vector / matrix of initial states.
If it is character, then it can be "individual"
, individual values of
the initial non-seasonal components are used, 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.
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.
Type of Cost Function used in optimization. cfType
can
be:
likelihood
- which assumes the minimisation of the determinant
of the covariance matrix of errors between the series. This implies that the
series could be correlated;
diagonal
- the covariance matrix is assumed to be diagonal with
zeros off the diagonal. The determinant of this matrix is just a product of
variances. This thing is minimised in this situation in logs.
trace
- the trace of the covariance matrix. The sum of variances
is minimised in this case.
The information criterion used in the model selection procedure.
Length of forecasting horizon.
If TRUE
, holdout sample of size h
is taken from
the end of the data.
Type of intervals to construct. NOT AVAILABLE YET!
This can be:
none
, aka n
- do not produce prediction
intervals.
conditional
, c
- produces multidimensional elliptic
intervals for each step ahead forecast.
unconditional
, u
- produces separate bounds for each series
based on ellipses for each step ahead. These bounds correspond to min and max
values of the ellipse assuming that all the other series but one take values in
the centre of the ellipse. This leads to less accurate estimates of bounds
(wider intervals than needed), but these could still be useful.
independent
, i
- produces intervals based on variances of
each separate series. This does not take vector structure into account.
The parameter also accepts TRUE
and FALSE
. The former means that
conditional intervals are constructed, while the latter is equivalent to
none
.
Confidence level. Defines width of prediction interval.
If TRUE
, then the cumulative forecast and prediction
intervals are produced instead of the normal ones. This is useful for
inventory control systems.
Defines type of intermittent model used. Can be:
none
, meaning that the data should be considered as non-intermittent;
fixed
, taking into account constant Bernoulli distribution of
demand occurrences;
tsb
, based on Teunter et al., 2011 method.
auto
- automatic selection of intermittency type based on information
criteria. The first letter can be used instead.
Either character specifying what type of VES / ETS model should be used for probability modelling, or a model estimated using viss function.
Type of multivariate probability used in the model. Can be
either "independent"
or "dependent"
. In the former case it is
assumed that non-zeroes occur in each series independently. In the latter case
each possible outcome is treated separately.
What type of bounds to use in the model estimation. The first
letter can be used instead of the whole word. Currently only "admissible"
bounds are available.
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").
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.
Object of class "vsmooth" is returned. It contains the following list of values:
model
- The name of the fitted model;
timeElapsed
- The time elapsed for the construction of the model;
states
- The matrix of states with components in columns and time in rows;
persistence
- The persistence matrix;
transition
- The transition matrix;
measurement
- The measurement matrix;
phi
- The damping parameter value;
coefficients
- The vector of all the estimated coefficients;
initial
- The initial values of the non-seasonal components;
initialSeason
- The initial values of the seasonal components;
nParam
- The number of estimated parameters;
actuals
- The matrix with the original data;
fitted
- The matrix of the fitted values;
holdout
- The matrix with the holdout values (if holdout=TRUE
in
the estimation);
residuals
- The matrix of the residuals of the model;
Sigma
- The covariance matrix of the errors (estimated with the correction
for the number of degrees of freedom);
forecast
- The matrix of point forecasts;
PI
- The bounds of the prediction intervals;
intervals
- The type of the constructed prediction intervals;
level
- The level of the confidence for the prediction intervals;
ICs
- The values of the information criteria;
logLik
- The log-likelihood function;
cf
- The value of the cost function;
cfType
- The type of the used cost function;
accuracy
- the values of the error measures. Currently not available.
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 on the additive model see Hyndman et al. (2008), chapter 17.
In case of multiplicative model, instead of the vector y_t we use its logarithms. As a result the multiplicative model is much easier to work with.
de Silva A,, Hyndman R.J. and Snyder, R.D. (2010). The vector innovations structural time series framework: a simple approach to multivariate forecasting. Statistical Modelling, 10 (4), pp.353-374
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.
# NOT RUN {
Y <- ts(cbind(rnorm(100,100,10),rnorm(100,75,8)),frequency=12)
# The simplest model applied to the data with the default values
ves(Y,model="ANN",h=10,holdout=TRUE)
# Damped trend model with the dependent persistence
ves(Y,model="AAdN",persistence="d",h=10,holdout=TRUE)
# Multiplicative damped trend model with individual phi
ves(Y,model="MMdM",persistence="i",h=10,holdout=TRUE,initialSeason="g")
Y <- cbind(c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)),
c(rpois(25,0.1),rpois(25,0.5),rpois(25,1),rpois(25,5)))
# Intermittent VES with logistic probability
ves(Y,model="MNN",h=10,holdout=TRUE,intermittent="l")
# }
Run the code above in your browser using DataLab