## 13.4 Examples of application

We consider the same example from Section 13.1. Just as a reminder, in that example, both demand occurrence and demand sizes increase over time (Figure 13.1), meaning that we can try the model with the trend for both parts. This can be done using the `adam()`

function from the `smooth`

package, defining the type of occurrence to use. We will try several options and select the one that has the lowest AICc:

```
vector("list",4)
adamiETSy <-1]] <- adam(y, "MMdN", h=10, holdout=TRUE,
adamiETSy[[occurrence="odds-ratio")
2]] <- adam(y, "MMdN", h=10, holdout=TRUE,
adamiETSy[[occurrence="inverse-odds-ratio")
3]] <- adam(y, "MMdN", h=10, holdout=TRUE,
adamiETSy[[occurrence="direct")
4]] <- adam(y, "MMdN", h=10, holdout=TRUE,
adamiETSy[[occurrence="general")
adamiETSyAICcs <- setNames(sapply(adamiETSy,AICc),
c("odds-ratio", "inverse-odds-ratio",
"direct", "general"))
adamiETSyAICcs
```

```
## odds-ratio inverse-odds-ratio direct general
## 359.5494 360.5086 354.4810 371.6503
```

Based on this, we can see that the model with direct probability has the lowest AICc. We can show how the model approximates the data and produces forecasts for the holdout:

```
which.min(adamiETSyAICcs)
i <-par(mfcol=c(2,1), mar=c(2,1,2,1))
plot(adamiETSy[[i]],7)
plot(adamiETSy[[i]]$occurrence,7)
```

Figure 13.8 shows that the model captured the trend well for both the demand occurrence and demand sizes parts. It forecasts that the mean demand will increase for the holdout period. We can also explore the demand occurrence part of this model by typing:

`$occurrence adamiETSy[[i]]`

```
## Occurrence state space model estimated: Direct probability
## Underlying ETS model: oETS[D](MMdN)
## Smoothing parameters:
## level trend
## 0 0
## Vector of initials:
## level trend
## 0.0463 1.1343
##
## Error standard deviation: 1.4805
## Sample size: 110
## Number of estimated parameters: 5
## Number of degrees of freedom: 105
## Information criteria:
## AIC AICc BIC BICc
## 103.5314 104.1083 117.0338 118.3897
```

In our example, the smoothing parameters are equal to zero for the demand occurrence part, which makes sense because the selected model is the damped multiplicative trend one, which should capture the increasing probability of occurrence well.

Depending on the generated data, there might be issues in the ETS(M,Md,N) model for demand sizes, if the smoothing parameters are too big, especially for the trend component. So, we can also try out the logARIMA(1,1,2) to see how it compares with this model. Given that ARIMA is not yet implemented for the occurrence part of the model, we need to construct the oETS separately and then use in `adam()`

:

```
oes(y, "MMdN", h=10, holdout=TRUE,
oETSModel <-occurrence=names(adamiETSyAICcs)[i])
adam(y, "NNN", h=10, holdout=TRUE,
adamiARIMA <-occurrence=oETSModel,
orders=c(1,1,2),
distribution="dlnorm")
adamiARIMA
```

```
## Time elapsed: 0.15 seconds
## Model estimated using adam() function: iARIMA(1,1,2)[D]
## Occurrence model type: Direct
## Distribution assumed in the model: Mixture of Bernoulli and Log-Normal
## Loss function type: likelihood; Loss function value: 128.0496
## ARMA parameters of the model:
## AR:
## phi1[1]
## -0.209
## MA:
## theta1[1] theta2[1]
## -0.4984 0.0283
##
## Sample size: 110
## Number of estimated parameters: 6
## Number of degrees of freedom: 104
## Information criteria:
## AIC AICc BIC BICc
## 361.6306 362.4461 377.8335 379.7502
##
## Forecast errors:
## Asymmetry: -70.393%; sMSE: 46.286%; rRMSE: 1.071; sPIS: 3196.961%; sCE: -386.317%
```

Comparing the iARIMA model with the previous iETS based on AIC would not be fair because as soon as the occurrence model is provided to the `adam()`

, it does not count the parameters estimated in that part towards the overall number of estimated parameters. To make the comparison fair, we need to make ADAM iETS comparable by estimating it in a similar way:

```
adam(y, "MMdN", h=10, holdout=TRUE,
adamiETSy[[i]] <-occurrence=oETSModel)
adamiETSy[[i]]
```

```
## Time elapsed: 0.07 seconds
## Model estimated using adam() function: iETS(MMdN)[D]
## Occurrence model type: Direct
## Distribution assumed in the model: Mixture of Bernoulli and Gamma
## Loss function type: likelihood; Loss function value: 119.067
## Persistence vector g:
## alpha beta
## 0 0
## Damping parameter: 0.9985
## Sample size: 110
## Number of estimated parameters: 6
## Number of degrees of freedom: 104
## Information criteria:
## AIC AICc BIC BICc
## 343.6655 344.4810 359.8684 361.7851
##
## Forecast errors:
## Asymmetry: -88.492%; sMSE: 53.022%; rRMSE: 1.146; sPIS: 3703.305%; sCE: -542.075%
```

Comparing information criteria, the iETS model is more appropriate for this data. But this might be due to different distributional assumptions and difficulties estimating the ARIMA model. If you want to experiment more with iARIMA, you might try fine tuning its parameters (see Section 11.4.1) for the data either by increasing the `maxeval`

or changing the initialisation, for example:

```
adam(y, "NNN", h=10, holdout=TRUE,
adamiARIMA <-occurrence=oETSModel, orders=c(1,1,2),
distribution="dgamma", initial="back")
```

Finally, we can produce point and interval forecasts from either of the models via the `forecast()`

method. Here is an example:

```
forecast(adamiETSy[[i]], h=10,
interval="prediction", nsim=10000) |>
plot()
```

In Figure 13.9, the interval is expanding, reflecting the captured tendency of growth in the data. The prediction interval produced from multiplicative ETS models will typically be simulated if `interval="prediction"`

, so to make them smoother, you might need to increase the `nsim`

parameter, for example, to `nsim=100000`

.