**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

## 6.5 Examples of application

### 6.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:

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

```
## Time elapsed: 0.03 seconds
## Model estimated using adam() function: ETS(MMN)
## Distribution assumed in the model: Gamma
## Loss function type: likelihood; Loss function value: 245.3759
## Persistence vector g:
## alpha beta
## 1.0000 0.2412
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
## AIC AICc BIC BICc
## 500.7518 501.1996 515.4600 516.5664
##
## Forecast errors:
## ME: 3.217; MAE: 3.33; RMSE: 3.784
## sCE: 14.124%; Asymmetry: 91.6%; sMAE: 1.462%; sMSE: 0.028%
## MASE: 2.817; RMSSE: 2.482; rMAE: 0.925; rRMSE: 0.921
```

`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.1996`

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

`## [1] 497.2624`

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:

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

```
## Time elapsed: 0.03 seconds
## Model estimated using adam() function: ETS(MMN)
## Distribution assumed in the model: Normal
## Loss function type: likelihood; Loss function value: 245.3872
## Persistence vector g:
## alpha beta
## 1.000 0.241
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
## AIC AICc BIC BICc
## 500.7745 501.2222 515.4827 516.5890
##
## Forecast errors:
## ME: 3.217; MAE: 3.33; RMSE: 3.785
## sCE: 14.126%; Asymmetry: 91.6%; sMAE: 1.462%; sMSE: 0.028%
## MASE: 2.817; RMSSE: 2.483; rMAE: 0.925; rRMSE: 0.921
```

which are quite similar on this specific example.

### 6.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:

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

` adamModel`

```
## Time elapsed: 0.14 seconds
## Model estimated using adam() function: ETS(MMM)
## Distribution assumed in the model: Gamma
## Loss function type: likelihood; Loss function value: 468.5176
## Persistence vector g:
## alpha beta gamma
## 0.7684 0.0206 0.0000
##
## Sample size: 132
## Number of estimated parameters: 17
## Number of degrees of freedom: 115
## Information criteria:
## AIC AICc BIC BICc
## 971.0351 976.4036 1020.0428 1033.1492
##
## Forecast errors:
## ME: -5.617; MAE: 15.496; RMSE: 21.938
## sCE: -25.677%; Asymmetry: -23.1%; sMAE: 5.903%; sMSE: 0.698%
## MASE: 0.643; RMSSE: 0.7; rMAE: 0.204; rRMSE: 0.213
```

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:

```
<- forecast(adamModel,h=12,interval="prediction")
adamForecast 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
## -5.976784815 15.604809310 489.157718219 -0.017130484 0.034061888
## sCE sMAE sMSE MASE RMSSE
## -0.273232334 0.059448608 0.007099297 0.647933445 0.705885975
## rMAE rRMSE rAME asymmetry sPIS
## 0.205326438 0.214776214 0.083982925 -0.252117248 2.228001145
```

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.17 seconds
## Model estimated using adam() function: ETS(MMdM)
## Distribution assumed in the model: Gamma
## Loss function type: likelihood; Loss function value: 466.1865
## Persistence vector g:
## alpha beta gamma
## 0.7519 0.0000 0.0000
## Damping parameter: 0.9997
## Sample size: 132
## Number of estimated parameters: 18
## Number of degrees of freedom: 114
## Information criteria:
## AIC AICc BIC BICc
## 968.3730 974.4261 1020.2634 1035.0414
##
## Forecast errors:
## ME: -6.935; MAE: 15.38; RMSE: 22.011
## sCE: -31.704%; Asymmetry: -32.1%; sMAE: 5.859%; sMSE: 0.703%
## MASE: 0.639; RMSSE: 0.703; rMAE: 0.202; rRMSE: 0.214
```

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