SSARIMA stands for “State-space ARIMA” or “Several Seasonalities ARIMA”. Both names show what happens in the heart of the function: it constructs ARIMA in a state-space form and allows to model several (actually more than several) seasonalities. ssarima()
is a function included in smooth package. This vignette covers ssarima()
and auto.ssarima()
functions. For more details about the underlying model, read (Svetunkov and Boylan 2019).
As usual, we will use data from Mcomp
package, so it is advised to install it.
Let’s load the necessary packages:
The default call constructs ARIMA(0,1,1):
## Time elapsed: 0.03 seconds
## Model estimated: ARIMA(0,1,1)
## Matrix of MA terms:
## Lag 1
## MA(1) -0.794
## Initial values were produced using backcasting.
## 2 parameters were estimated in the process
## Residuals standard deviation: 2097.877
## Loss function type: MSE; Loss function value: 4401089.934
##
## Information criteria:
## AIC AICc BIC BICc
## 2089.553 2089.660 2095.042 2095.297
Some more complicated model can be defined using parameter orders
the following way:
## Time elapsed: 0.15 seconds
## Model estimated: SARIMA(0,1,1)[1](1,0,1)[12]
## Matrix of AR terms:
## Lag 12
## AR(1) 0.83
## Matrix of MA terms:
## Lag 1 Lag 12
## MA(1) -0.814 -0.369
## Initial values were produced using backcasting.
## 4 parameters were estimated in the process
## Residuals standard deviation: 1902.156
## Loss function type: MSE; Loss function value: 3618199.058
##
## Information criteria:
## AIC AICc BIC BICc
## 2071.027 2071.390 2082.007 2082.869
This would construct us seasonal ARIMA(0,1,1)(1,0,1)\(_{12}\).
We could try selecting orders manually, but this can also be done automatically via auto.ssarima()
function:
## Time elapsed: 4.01 seconds
## Model estimated: SARIMA(0,1,2)[1](0,0,3)[12]
## Matrix of MA terms:
## Lag 1 Lag 12
## MA(1) -0.594 0.392
## MA(2) -0.277 0.631
## MA(3) 0.000 0.049
## Initial values were produced using backcasting.
## 6 parameters were estimated in the process
## Residuals standard deviation: 1784.234
## Loss function type: MSE; Loss function value: 3183490.065
##
## Information criteria:
## AIC AICc BIC BICc
## 2060.307 2061.085 2076.777 2078.622
Automatic order selection in SSARIMA with optimised initials does not work well and in general is not recommended. This is partially because of the possible high number of parameters in some models and partially because of potential overfitting of first observations when non-zero order of AR is selected. This problem can be seen on example of another time series (which has complicated seasonality):
## Time elapsed: 8.33 seconds
## Model estimated: SARIMA(0,0,3)[1](3,1,3)[12]
## Matrix of AR terms:
## Lag 12
## AR(1) -0.700
## AR(2) -0.521
## AR(3) 0.221
## Matrix of MA terms:
## Lag 1 Lag 12
## MA(1) 0.031 -0.259
## MA(2) 0.115 0.207
## MA(3) 0.335 -0.626
## Initial values were produced using backcasting.
## 10 parameters were estimated in the process
## Residuals standard deviation: 281.532
## Loss function type: MSE; Loss function value: 79260.469
##
## Information criteria:
## AIC AICc BIC BICc
## 1544.784 1547.052 1571.605 1576.915
## Time elapsed: 11.83 seconds
## Model estimated: ARIMA(0,0,3) with constant
## Matrix of MA terms:
## Lag 1
## MA(1) 0.356
## MA(2) 0.293
## MA(3) 0.310
## Constant value is: 3786.814
## Initial values were optimised.
## 8 parameters were estimated in the process
## Residuals standard deviation: 411.517
## Loss function type: MSE; Loss function value: 169345.889
##
## Information criteria:
## AIC AICc BIC BICc
## 1622.778 1624.233 1644.235 1647.640
As can be seen from the second graph, ssarima with optimal initial does not select seasonal model and reverts to ARIMA(0,0,3) with constant. In theory this can be due to implemented order selection algorithm, however if we estimate all the model in the pool separately, we will see that this model is optimal for this time series when this type of initials is used.
A power of ssarima()
function is that it can estimate SARIMA models with multiple seasonalities. For example, SARIMA(0,1,1)(0,0,1)_6(1,0,1)_12 model can be estimated the following way:
## Time elapsed: 0.4 seconds
## Model estimated: SARIMA(0,1,1)[1](0,0,1)[6](1,0,1)[12]
## Matrix of AR terms:
## Lag 12
## AR(1) 0.751
## Matrix of MA terms:
## Lag 1 Lag 6 Lag 12
## MA(1) -0.804 -0.206 -0.311
## Initial values were produced using backcasting.
## 5 parameters were estimated in the process
## Residuals standard deviation: 1857.086
## Loss function type: MSE; Loss function value: 3448766.732
##
## Information criteria:
## AIC AICc BIC BICc
## 2067.512 2068.062 2081.236 2082.542
It probably does not make much sense for this type of data, it would make more sense on high frequency data (for example,
taylor
series from forecast
package). However, keep in mind that multiple seasonal ARIMAs are very slow in estimation and are very capricious. So it is really hard to obtain an appropriate and efficient multiple seasonal ARIMA model.
Now let’s introduce some artificial exogenous variables:
If we save model:
we can then reuse it:
## Time elapsed: 0.8 seconds
## Model estimated: SARIMAX(0,0,2)[1](0,0,3)[12] with constant
## Matrix of MA terms:
## Lag 1 Lag 12
## MA(1) 0.237 -0.143
## MA(2) 0.135 0.275
## MA(3) 0.000 0.221
## Constant value is: -719.789
## Initial values were provided by user.
## 1 parameter was estimated in the process
## 52 parameters were provided
## Residuals standard deviation: 2605.3
## Xreg coefficients were estimated in a crazy style
## Loss function type: MSE; Loss function value: 6787587.416
##
## Information criteria:
## AIC AICc BIC BICc
## 2137.376 2137.411 2140.120 2140.204
## 95% parametric prediction interval were constructed
Finally, we can combine several SARIMA models:
## Time elapsed: 0.03 seconds
## Model estimated: ARIMA(0,1,1)
## Matrix of MA terms:
## Lag 1
## MA(1) -0.794
## Initial values were produced using backcasting.
## 2 parameters were estimated in the process
## Residuals standard deviation: 2097.877
## Loss function type: MSE; Loss function value: 4401089.934
##
## Information criteria:
## AIC AICc BIC BICc
## 2089.553 2089.660 2095.042 2095.297
## 95% parametric prediction interval were constructed
Svetunkov, Ivan, and John E. Boylan. 2019. “State-space ARIMA for supply-chain forecasting.” International Journal of Production Research 0 (0). Taylor & Francis: 1–10. https://doi.org/10.1080/00207543.2019.1600764.