**Open Review**. I want your feedback to make the book better for you and other readers. To add your annotation, select some text and then click the on the pop-up menu. To see the annotations of others, click the button in the upper right hand corner of the page

## 7.5 Examples of application

### 7.5.1 Non-seasonal data

We continue our examples with the same Box-Jenkins sales case by fitting the ETS(M,M,N) model, but this time with a holdout of 10 observations:

```
adamModel <- adam(BJsales, "MMN", h=10, holdout=TRUE)
adamModel
```

```
## Time elapsed: 0.04 seconds
## Model estimated using adam() function: ETS(MMN)
## Distribution assumed in the model: Inverse Gaussian
## Loss function type: likelihood; Loss function value: 245.415
## Persistence vector g:
## alpha beta
## 1.0000 0.2377
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
## AIC AICc BIC BICc
## 500.8300 501.2777 515.5382 516.6445
##
## Forecast errors:
## ME: 3.228; MAE: 3.34; RMSE: 3.796
## sCE: 14.175%; sMAE: 1.467%; sMSE: 0.028%
## MASE: 2.826; RMSSE: 2.49; rMAE: 0.928; rRMSE: 0.924
```

`plot(adamModel,7)`

Note that the function produces the point forecast in this case, which is not equivalent to the conditional expectation! Also, the default distribution for the multiplicative erro models is \(\mathcal{IG}\). Similarly, to how it was done in the previous chapter, the output gives a general summary for the model. We can compare this model with the ETS(A,A,N) via information criteria if we want. For example, here are the AICc for the two models:

```
# ETS(M,M,N)
AICc(adamModel)
```

`## [1] 501.2777`

```
# ETS(A,A,N)
AICc(adam(BJsales, "AAN", h=10, holdout=TRUE))
```

`## [1] 497.4687`

The comparison is fair, because both models were estimated via likelihood and both likelihoods are formulated correctly, without omitting any terms (e.g. `ets()`

from `forecast`

package omits the \(-\frac{T}{2} \log\left(2\pi e \frac{1}{T}\right)\) for convenience, which makes it incomparable with other models). In this example, it seems tha the pure additive model is more suitable for the data than the pure multiplicative one. Still, if we want to produce forecasts from the model, we can do it, using the same command as in the previous chapter:

`plot(forecast(adamModel,h=10,interval="prediction",level=0.95))`

Note that, when we ask for "prediction" intervals, the `forecast()`

function will automatically decide what to use: in case of pure additive model it will use analytical solutions, while in the other cases, it will use simulations. The point forecast obtained from forecast function corresponds to the conditional expectation and is calculated based on the simulations. This also means that it will differ slightly from one run of the function to another (reflecting the uncertainty in the error term), but the difference should be negligible.

We can also compare the performance of ETS(M,M,N) with \(\mathcal{IG}\) distribution and the conventional ETS(M,M,N), assuming normality:

```
adamModelNormal <- adam(BJsales, "MMN", h=10, holdout=TRUE, distribution="dnorm")
adamModelNormal
```

```
## Time elapsed: 0.04 seconds
## Model estimated using adam() function: ETS(MMN)
## Distribution assumed in the model: Normal
## Loss function type: likelihood; Loss function value: 245.4207
## Persistence vector g:
## alpha beta
## 1.0000 0.2399
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
## AIC AICc BIC BICc
## 500.8415 501.2892 515.5497 516.6560
##
## Forecast errors:
## ME: 3.221; MAE: 3.334; RMSE: 3.789
## sCE: 14.142%; sMAE: 1.464%; sMSE: 0.028%
## MASE: 2.82; RMSSE: 2.485; rMAE: 0.926; rRMSE: 0.922
```

which are quite similar on this specific example.

### 7.5.2 Seasonal data

The `AirPassengers`

data used in the previous chapter has (as we discussed) multiplicative seasonality. So, the ETS(M,M,M) model might be more suitable than the pure additive one that we used previously:

`adamModel <- adam(AirPassengers, "MMM", h=12, holdout=TRUE, silent=FALSE)`

`adamModel`

```
## Time elapsed: 0.19 seconds
## Model estimated using adam() function: ETS(MMM)
## Distribution assumed in the model: Inverse Gaussian
## Loss function type: likelihood; Loss function value: 468.948
## Persistence vector g:
## alpha beta gamma
## 0.8326 0.0193 0.0000
##
## Sample size: 132
## Number of estimated parameters: 17
## Number of degrees of freedom: 115
## Information criteria:
## AIC AICc BIC BICc
## 971.8961 977.2645 1020.9037 1034.0102
##
## Forecast errors:
## ME: -3.889; MAE: 15.873; RMSE: 21.726
## sCE: -17.777%; sMAE: 6.047%; sMSE: 0.685%
## MASE: 0.659; RMSSE: 0.693; rMAE: 0.209; rRMSE: 0.211
```

Notice that the smoothing parameter \(\gamma=0\) in this case, which reflects the idea that we deal with the data with multiplicative seasonality and apply the correct model. Comparing the information criteria (e.g. AICc) with the ETS(A,A,A), this model does a better job at fitting the data. The conditional expectation and prediction interval from this model are better as well:

```
adamForecast <- forecast(adamModel,h=12,interval="prediction")
plot(adamForecast)
```

If we want to calculate the error measures based on the conditional expectation, we can use the `measures()`

function from `greybox`

package in the following way:

`measures(adamModel$holdout,adamForecast$mean,actuals(adamModel))`

```
## ME MAE MSE MPE MAPE
## -4.572705935 15.786475852 469.841944165 -0.014169910 0.034214960
## sCE sMAE sMSE MASE RMSSE
## -0.209044019 0.060140691 0.006818961 0.655476493 0.691808654
## rMAE rRMSE rAME cbias sPIS
## 0.207716788 0.210492982 0.064253479 -0.130608215 1.771300259
```

And the plot of the time series decomposition according to ETS(M,M,M) is:

`plot(adamModel,12)`

It shows that the residuals are more random for the model than for the ETS(A,A,A), but there still might be some structure left. The autocorrelation and partial autocorrelation functions might help in understanding this better:

```
par(mfcol=c(1,2))
plot(adamModel,10:11)
```

The plot shows that there is still some correlation left in the residuals, which could be either due to pure randomness or due to the imperfect estimation of the model. Tuning the parameters of the optimiser or selecting a different model might solve the problem.

Finally, just as an example, we can also fit the most complicated pure multiplicative model, ETS(M,Md,M):

`adam(AirPassengers, "MMdM", h=12, holdout=TRUE, silent=FALSE)`

```
## Time elapsed: 0.47 seconds
## Model estimated using adam() function: ETS(MMdM)
## Distribution assumed in the model: Inverse Gaussian
## Loss function type: likelihood; Loss function value: 469.2185
## Persistence vector g:
## alpha beta gamma
## 0.8474 0.0212 0.0000
## Damping parameter: 1
## Sample size: 132
## Number of estimated parameters: 18
## Number of degrees of freedom: 114
## Information criteria:
## AIC AICc BIC BICc
## 974.4371 980.4902 1026.3275 1041.1056
##
## Forecast errors:
## ME: -4.684; MAE: 15.676; RMSE: 21.803
## sCE: -21.412%; sMAE: 5.972%; sMSE: 0.69%
## MASE: 0.651; RMSSE: 0.696; rMAE: 0.206; rRMSE: 0.212
```

which does not seem to be better than ETS(M,M,M) on this specific time series.