This book is in 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.3736
## Persistence vector g:
##  alpha   beta
## 0.9994 0.2429
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
##      AIC     AICc      BIC     BICc
## 500.7472 501.1950 515.4554 516.5618
##
## Forecast errors:
## ME: 3.211; MAE: 3.325; RMSE: 3.778
## sCE: 14.1%; sMAE: 1.46%; sMSE: 0.028%
## MASE: 2.813; RMSSE: 2.478; rMAE: 0.924; rRMSE: 0.92
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.195
# ETS(A,A,N)
AICc(adam(BJsales, "AAN", h=10, holdout=TRUE))
## [1] 497.3651

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.03 seconds
## Model estimated using adam() function: ETS(MMN)
## Distribution assumed in the model: Normal
## Loss function type: likelihood; Loss function value: 245.3888
## Persistence vector g:
##  alpha   beta
## 1.0000 0.2381
##
## Sample size: 140
## Number of estimated parameters: 5
## Number of degrees of freedom: 135
## Information criteria:
##      AIC     AICc      BIC     BICc
## 500.7776 501.2254 515.4858 516.5922
##
## Forecast errors:
## ME: 3.227; MAE: 3.339; RMSE: 3.795
## sCE: 14.169%; sMAE: 1.466%; sMSE: 0.028%
## MASE: 2.825; RMSSE: 2.489; rMAE: 0.928; rRMSE: 0.924

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.17 seconds
## Model estimated using adam() function: ETS(MMM)
## Distribution assumed in the model: Inverse Gaussian
## Loss function type: likelihood; Loss function value: 468.5996
## Persistence vector g:
##  alpha   beta  gamma
## 0.7723 0.0176 0.0001
##
## Sample size: 132
## Number of estimated parameters: 17
## Number of degrees of freedom: 115
## Information criteria:
##       AIC      AICc       BIC      BICc
##  971.1992  976.5676 1020.2068 1033.3133
##
## Forecast errors:
## ME: -4.422; MAE: 15.626; RMSE: 21.726
## sCE: -20.217%; sMAE: 5.953%; sMSE: 0.685%
## MASE: 0.649; RMSSE: 0.693; rMAE: 0.206; 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.779227725  15.607338470 472.467856472  -0.014629026   0.033810239
##           sCE          sMAE          sMSE          MASE         RMSSE
##  -0.218485287   0.059458243   0.006857072   0.648038459   0.693739194
##          rMAE         rRMSE          rAME         cbias          sPIS
##   0.205359717   0.211080377   0.067155425  -0.147154407   1.860702034

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.19 seconds
## Model estimated using adam() function: ETS(MMdM)
## Distribution assumed in the model: Inverse Gaussian
## Loss function type: likelihood; Loss function value: 469.1548
## Persistence vector g:
##  alpha   beta  gamma
## 0.7767 0.0214 0.0004
## Damping parameter: 0.996
## Sample size: 132
## Number of estimated parameters: 18
## Number of degrees of freedom: 114
## Information criteria:
##       AIC      AICc       BIC      BICc
##  974.3097  980.3628 1026.2001 1040.9781
##
## Forecast errors:
## ME: -0.826; MAE: 15.611; RMSE: 21.67
## sCE: -3.777%; sMAE: 5.947%; sMSE: 0.682%
## MASE: 0.648; RMSSE: 0.692; rMAE: 0.205; rRMSE: 0.21

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