---
title: "ves() - Vector Exponential Smoothing"
author: "Ivan Svetunkov"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{ves() - Vector Exponential Smoothing}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
bibliography: library.bib
---

```{r global_options, include=FALSE}
knitr::opts_chunk$set(fig.width=6, fig.height=5.5, fig.path='Figs/', fig.show='hold',
                      warning=FALSE, message=FALSE)
```

This vignette covers `ves()` function, which is a part of [smooth package](smooth.html). In this vignette we will use data from `Mcomp` package, so it is advised to install it.

Let's load the necessary packages:

```{r load_libraries, message=FALSE, warning=FALSE}
require(smooth)
require(Mcomp)
```

We will use to time series from the M3 united in a vector:
```{r form_the_vector, message=FALSE, warning=FALSE}
Y <- cbind(M3$N2570$x,M3$N2571$x);
```

`ves()` function allows constructing Vector Exponential Smoothing [aka "VISTS" discussed by @Silva2010] in either pure additive or pure multiplicative form. The function has several elements that can either be individual or grouped. The former means that all the time series use the same value. For example, `persistence="g"` means that the smoothing parameters for all the series are the same. A simple call for `ves()` results in estimation of VES(A,N,N) with grouped smoothing parameters, transition matrix and individual initials:
```{r ves_basic}
ves(Y, h=18, holdout=TRUE, silent=FALSE)
```

The output tells us how much time the estimation took, what model we estimated, how many parameters were estimated, the cost function type used and its value and finally the information criteria. Currently we do not provide error measures for the holdout, this functionality will be available with newer releases of `smooth`.

In some cases we may decide that the series should be connected with each other. In this case we can ask function to use "dependent" persistence. This means that along with the individual smoothing parameters, we will estimate cross-series ones. Here's the example:
```{r ves_AAN_persistence_dep}
ourModel <- ves(Y, "AAN", persistence="d", h=18, holdout=TRUE, silent=FALSE)
```

The resulting persistence matrix contains more values than the individual one:
```{r ves_AAN_persistence_dep_value}
ourModel$persistence
```

Note that some of the values of smoothing parameters are negative and the others are greater than one. This is a normal behaviour for VES model in this implementation. Currently we only have bounds derived from the stability region (`bounds="admissible"`) and we do not do traditional restrictions yet (and not sure if we ever will).

Currently we have pure additive and pure multiplicative models only, and I don't intend introducing mixed models for VES at all, because I think that they are evil. The multiplicative model implemented in VES is in fact just an additive model applied to the data in logarithms. Let's see how the damped trend multiplicative seasonal model with individual damping and smoothing parameters looks like:
```{r ves_MMdM}
ourModel <- ves(Y, "MMdM", phi="i", persistence="i", h=18, holdout=TRUE)
```

There are different options for the seasonal models. For example, you can set a common seasonal component between the series with the equal weights:
```{r ves_MMdM_CCAC}
ourModel <- ves(Y, "MMdM", persistence="c", seasonal="c", h=18, holdout=TRUE, silent=F)
```

Number of estimated parameters in the model can be extracted via `nparam()` method. However, when it comes to the calculation of the number of degrees of freedom in the model, this value is divided by the number of series [@Lutkepohl2005]. So both `ourModel$Sigma` and all the information criteria rely on the $df = T - k_m$, where $T$ is the number of observations and $k_m = \frac{k}{m}$ is the number of parameters $k$ per series ($m$ is the number of series).

AICc and BICc for the vector models are calculated as proposed in [@Bedrick1994] and [@Tremblay2004].

Currently we don't do model selection, don't have exogenous variables and don't produce conditional prediction interval. But at least it works and allows you to play around with it :).

### References
