## 9.9 Seasonal ARIMA models

So far, we have restricted our attention to non-seasonal data and non-seasonal ARIMA models. However, ARIMA models are also capable of modelling a wide range of seasonal data.

A seasonal ARIMA model is formed by including additional seasonal terms in the ARIMA models we have seen so far. It is written as follows:

ARIMA | \(\underbrace{(p, d, q)}\) | \(\underbrace{(P, D, Q)_{m}}\) |

\({\uparrow}\) | \({\uparrow}\) | |

Non-seasonal part | Seasonal part of | |

of the model | of the model |

where \(m =\) number of observations per year. We use uppercase notation for the seasonal parts of the model, and lowercase notation for the non-seasonal parts of the model.

The seasonal part of the model consists of terms that are similar to the non-seasonal components of the model, but involve backshifts of the seasonal period. For example, an ARIMA(1,1,1)(1,1,1)\(_{4}\) model (without a constant) is for quarterly data (\(m=4\)), and can be written as \[ (1 - \phi_{1}B)~(1 - \Phi_{1}B^{4}) (1 - B) (1 - B^{4})y_{t} = (1 + \theta_{1}B)~ (1 + \Theta_{1}B^{4})\varepsilon_{t}. \]

The additional seasonal terms are simply multiplied by the non-seasonal terms.

### ACF/PACF

The seasonal part of an AR or MA model will be seen in the seasonal lags of the PACF and ACF. For example, an ARIMA(0,0,0)(0,0,1)\(_{12}\) model will show:

- a spike at lag 12 in the ACF but no other significant spikes;
- exponential decay in the seasonal lags of the PACF (i.e., at lags 12, 24, 36, …).

Similarly, an ARIMA(0,0,0)(1,0,0)\(_{12}\) model will show:

- exponential decay in the seasonal lags of the ACF;
- a single significant spike at lag 12 in the PACF.

In considering the appropriate seasonal orders for a seasonal ARIMA model, restrict attention to the seasonal lags.

The modelling procedure is almost the same as for non-seasonal data, except that we need to select seasonal AR and MA terms as well as the non-seasonal components of the model. The process is best illustrated via examples.

### Example: European quarterly retail trade

We will describe the seasonal ARIMA modelling procedure using quarterly European retail trade data from 1996 to 2011. The data are plotted in Figure 9.17.

```
eu_retail <- as_tsibble(fpp2::euretail)
eu_retail %>% autoplot(value) + ylab("Retail index") + xlab("Year")
```

The data are clearly non-stationary, with some seasonality, so we will first take a seasonal difference. The seasonally differenced data are shown in Figure 9.18. These also appear to be non-stationary, so we take an additional first difference, shown in Figure 9.19.

Our aim now is to find an appropriate ARIMA model based on the ACF and PACF shown in Figure 9.19. The significant spike at lag 1 in the ACF suggests a non-seasonal MA(1) component, and the significant spike at lag 4 in the ACF suggests a seasonal MA(1) component. Consequently, we begin with an ARIMA(0,1,1)(0,1,1)\(_4\) model, indicating a first and seasonal difference, and non-seasonal and seasonal MA(1) components. The residuals for the fitted model are shown in Figure 9.20. (By analogous logic applied to the PACF, we could also have started with an ARIMA(1,1,0)(1,1,0)\(_4\) model.)

Both the ACF and PACF show significant spikes at lag 2, and almost significant spikes at lag 3, indicating that some additional non-seasonal terms need to be included in the model. The AICc of the ARIMA(0,1,2)(0,1,1)\(_4\) model is 74.36, while that for the ARIMA(0,1,3)(0,1,1)\(_4\) model is 68.53. We tried other models with AR terms as well, but none that gave a smaller AICc value. Consequently, we choose the ARIMA(0,1,3)(0,1,1)\(_4\) model. Its residuals are plotted in Figure 9.21. All the spikes are now within the significance limits, so the residuals appear to be white noise. The Ljung-Box test also shows that the residuals have no remaining autocorrelations.

Thus, we now have a seasonal ARIMA model that passes the required checks and is ready for forecasting. Forecasts from the model for the next three years are shown in Figure 9.22. The forecasts follow the recent trend in the data, because of the double differencing. The large and rapidly increasing prediction intervals show that the retail trade index could start increasing or decreasing at any time — while the point forecasts trend downwards, the prediction intervals allow for the data to trend upwards during the forecast period.

We could have also used `ARIMA()`

without specifying the lag orders to automatically select them. It would have given the same result.

```
eu_retail %>%
model(ARIMA(value))
#> # A mable: 1 x 1
#> `ARIMA(value)`
#> <model>
#> 1 <ARIMA(0,1,3)(0,1,1)[4]>
```

The `ARIMA()`

function uses `unitroot_nsdiffs()`

to determine \(D\) (the number of seasonal differences to use), and `unitroot_ndiffs()`

to determine \(d\) (the number of ordinary differences to use). The selection of the other model parameters (\(p,q,P\) and \(Q\)) are all determined by minimizing the AICc, as with non-seasonal ARIMA models.

### Example: Corticosteroid drug sales in Australia

Our second example is more difficult. We will try to forecast monthly corticosteroid drug sales in Australia. These are known as H02 drugs under the Anatomical Therapeutic Chemical classification scheme.

```
h02 <- tsibbledata::PBS %>%
filter(ATC2 == "H02") %>%
summarise(Cost = sum(Cost)/1e6)
h02 %>%
mutate(log(Cost)) %>%
gather() %>%
ggplot(aes(x = Month, y = value)) +
geom_line() +
facet_grid(key ~ ., scales = "free_y") +
xlab("Year") + ylab("") +
ggtitle("Cortecosteroid drug scripts (H02)")
```

Data from July 1991 to June 2008 are plotted in Figure 9.23. There is a small increase in the variance with the level, so we take logarithms to stabilise the variance.

The data are strongly seasonal and obviously non-stationary, so seasonal differencing will be used. The seasonally differenced data are shown in Figure 9.24. It is not clear at this point whether we should do another difference or not. We decide not to, but the choice is not obvious.

The last few observations appear to be different (more variable) from the earlier data. This may be due to the fact that data are sometimes revised when earlier sales are reported late.

In the plots of the seasonally differenced data, there are spikes in the PACF at lags 12 and 24, but nothing at seasonal lags in the ACF. This may be suggestive of a seasonal AR(2) term. In the non-seasonal lags, there are three significant spikes in the PACF, suggesting a possible AR(3) term. The pattern in the ACF is not indicative of any simple model.

Consequently, this initial analysis suggests that a possible model for these data is an ARIMA(3,0,0)(2,1,0)\(_{12}\). We fit this model, along with some variations on it, and compute the AICc values shown in Table 9.2.

.model | AICc |
---|---|

ARIMA(3,0,1)(0,1,2)\(_{12}\) | -485.5 |

ARIMA(3,0,1)(1,1,1)\(_{12}\) | -484.2 |

ARIMA(3,0,1)(0,1,1)\(_{12}\) | -483.7 |

ARIMA(3,0,1)(2,1,0)\(_{12}\) | -476.3 |

ARIMA(3,0,0)(2,1,0)\(_{12}\) | -475.1 |

ARIMA(3,0,2)(2,1,0)\(_{12}\) | -474.9 |

ARIMA(3,0,1)(1,1,0)\(_{12}\) | -463.4 |

Of these models, the best is the ARIMA(3,0,1)(0,1,2)\(_{12}\) model (i.e., it has the smallest AICc value).

```
fit <- h02 %>%
model(ARIMA(log(Cost) ~ 0 + pdq(3,0,1) + PDQ(0,1,2)))
report(fit)
#> Series: Cost
#> Model: ARIMA(3,0,1)(0,1,2)[12]
#> Transformation: log(.x)
#>
#> Coefficients:
#> ar1 ar2 ar3 ma1 sma1 sma2
#> -0.1603 0.5481 0.5678 0.3827 -0.5222 -0.1768
#> s.e. 0.1636 0.0878 0.0942 0.1895 0.0861 0.0872
#>
#> sigma^2 estimated as 0.004278: log likelihood=250
#> AIC=-486.1 AICc=-485.5 BIC=-463.3
```

```
#> # A tibble: 1 x 3
#> .model lb_stat lb_pvalue
#> <chr> <dbl> <dbl>
#> 1 ARIMA(log(Cost) ~ 0 + pdq(3, 0, 1) + PDQ(0, 1, 2)) 50.7 0.0104
```

The residuals from this model are shown in Figure 9.25. There are a few significant spikes in the ACF, and the model fails the Ljung-Box test. The model can still be used for forecasting, but the prediction intervals may not be accurate due to the correlated residuals.

Next we will try using the automatic ARIMA algorithm. Running `ARIMA()`

with all arguments left at their default values led to an ARIMA(2,1,0)(0,1,1)\(_{12}\) model. However, the model still fails the Ljung-Box test for 36 lags. Sometimes it is just not possible to find a model that passes all of the tests.

#### Test set evaluation:

We will compare some of the models fitted so far using a test set consisting of the last two years of data. Thus, we fit the models using data from July 1991 to June 2006, and forecast the script sales for July 2006 – June 2008. The results are summarised in the following table.

.model | RMSE |
---|---|

ARIMA(3,0,1)(1,1,1)\(_{12}\) | 0.0619 |

ARIMA(3,0,1)(0,1,2)\(_{12}\) | 0.0621 |

ARIMA(2,1,4)(0,1,1)\(_{12}\) | 0.0627 |

ARIMA(2,1,3)(0,1,1)\(_{12}\) | 0.0628 |

ARIMA(3,0,1)(0,1,1)\(_{12}\) | 0.0630 |

ARIMA(3,0,2)(0,1,1)\(_{12}\) | 0.0630 |

ARIMA(4,1,1)(2,1,2)\(_{12}\) | 0.0631 |

ARIMA(3,0,3)(0,1,1)\(_{12}\) | 0.0631 |

ARIMA(2,1,5)(0,1,1)\(_{12}\) | 0.0636 |

ARIMA(3,0,2)(2,1,0)\(_{12}\) | 0.0651 |

ARIMA(3,0,1)(2,1,0)\(_{12}\) | 0.0653 |

ARIMA(3,0,1)(1,1,0)\(_{12}\) | 0.0666 |

ARIMA(3,0,0)(2,1,0)\(_{12}\) | 0.0668 |

The models chosen manually and with `ARIMA()`

are both in the top four models based on their RMSE values.

When models are compared using AICc values, it is important that all models have the same orders of differencing. However, when comparing models using a test set, it does not matter how the forecasts were produced — the comparisons are always valid. Consequently, in the table above, we can include some models with only seasonal differencing and some models with both first and seasonal differencing, while in the earlier table containing AICc values, we only compared models with seasonal differencing but no first differencing.

None of the models considered here pass all of the residual tests. In practice, we would normally use the best model we could find, even if it did not pass all of the tests.

Forecasts from the ARIMA(3,0,1)(0,1,2)\(_{12}\) model (which has the lowest RMSE value on the test set, and the best AICc value amongst models with only seasonal differencing) are shown in Figure 9.26.

```
h02 %>%
model(ARIMA(log(Cost) ~ 0 + pdq(3,0,1) + PDQ(0,1,2))) %>%
forecast() %>%
autoplot(h02) +
ylab("H02 sales (million scripts)") + xlab("Year")
```