ges()
constructs Generalised Exponential Smoothing - pure additive state-space model. It is a part of smooth package.
In this vignette we will use data from Mcomp
package, so it is adviced to install it.
Let’s load the necessary packages:
require(smooth)
require(Mcomp)
You may note that Mcomp
depends on forecast
package and if you load both forecast
and smooth
, then you will have a message that forecast()
function is masked from the environment. There is nothing to be worried about - smooth
uses this function for consistency purposes and has exactly the same original forecast()
as in the forecast
package. The inclusion of this function in smooth
was done only in order not to include forecast
in dependencies of the package.
Generalised Exponential Smoothing is a next step from CES. It is a state-space model in which all the matrices and vectors are estimated. It is very demanding in sample size, but is also insanely flexible.
A simple call by default constructs GES\((1^1,1^m)\), where \(m\) is frequency of the data. So for our example with monthly data N2457, we will have GES\((1^1,1^{12})\):
ges(M3$N2457$x, h=18, holdout=TRUE)
## Time elapsed: 0.86 seconds
## Model estimated: GES(1[1],1[12])
## Persistence vector g:
## [,1] [,2]
## [1,] 0.257 -1.883
## Transition matrix F:
## [,1] [,2]
## [1,] 0.923 0.003
## [2,] 4.224 1.100
## Measurement vector w: 1.01, 0.102
## Initial values were optimised.
## 22 parameters were estimated in the process
## Residuals standard deviation: 1301.123
## Cost function type: MSE; Cost function value: 1308960
##
## Information criteria:
## AIC AICc BIC
## 1685.494 1699.170 1742.138
## Forecast errors:
## MPE: -6.7%; Bias: 29.6%; MAPE: 38%; SMAPE: 34.2%
## MASE: 2.185; sMAE: 89.2%; RelMAE: 0.934; sMSE: 129.2%
But some different orders and lags can be specified. For example:
ges(M3$N2457$x, h=18, holdout=TRUE, orders=c(2,1), lags=c(1,12))
## Time elapsed: 0.64 seconds
## Model estimated: GES(2[1],1[12])
## Persistence vector g:
## [,1] [,2] [,3]
## [1,] 0.14 0.091 0.118
## Transition matrix F:
## [,1] [,2] [,3]
## [1,] 0.371 -0.298 0.491
## [2,] 0.541 0.701 -0.041
## [3,] 0.397 -0.054 0.973
## Measurement vector w: 0.22, 0.939, 0.643
## Initial values were optimised.
## 30 parameters were estimated in the process
## Residuals standard deviation: 1573.055
## Cost function type: MSE; Cost function value: 1709191
##
## Information criteria:
## AIC AICc BIC
## 1727.373 1755.554 1804.614
## Forecast errors:
## MPE: 20.3%; Bias: 81.9%; MAPE: 36.1%; SMAPE: 42.5%
## MASE: 2.561; sMAE: 104.5%; RelMAE: 1.094; sMSE: 187.8%
Function auto.ges()
is not yet implemented in smooth
, but manual selection allows to conclude that GES\((1^1)\) has the lowest AIC amongst other possible GES models:
ges(M3$N2457$x, h=18, holdout=TRUE, orders=c(1), lags=c(1), intervals=TRUE)
## Time elapsed: 0.22 seconds
## Model estimated: GES(1[1])
## Persistence vector g:
## [,1]
## [1,] 0.137
## Transition matrix F:
## [,1]
## [1,] 1.011
## Measurement vector w: 0.714
## Initial values were optimised.
## 5 parameters were estimated in the process
## Residuals standard deviation: 1430.36
## Cost function type: MSE; Cost function value: 1940469
##
## Information criteria:
## AIC AICc BIC
## 1689.683 1690.342 1702.556
## 95% parametric prediction intervals were constructed
## 56% of values are in the prediction interval
## Forecast errors:
## MPE: 15.7%; Bias: 76.4%; MAPE: 37.4%; SMAPE: 42.7%
## MASE: 2.636; sMAE: 107.5%; RelMAE: 1.126; sMSE: 204.4%
In theory inclusion of more orders and lags should lead to decrease of MSE. However this is not the case in our implementation, because currently we use linear programming optimisers, which may leave us with suboptimal values in cases when parameter space is wide.
In addition to standard values that other functions accept, GES accepts predefined values for transition matrix, measurement and persistence vectors. For example, something more common can be passed to the function:
transition <- matrix(c(1,0,0,1,1,0,0,0,1),3,3)
measurement <- c(1,1,1)
ges(M3$N2457$x, h=18, holdout=TRUE, orders=c(2,1), lags=c(1,12), transition=transition, measurement=measurement)
## Time elapsed: 0.36 seconds
## Model estimated: GES(2[1],1[12])
## Persistence vector g:
## [,1] [,2] [,3]
## [1,] 0.172 0.004 0.083
## Transition matrix F:
## [,1] [,2] [,3]
## [1,] 1 1 0
## [2,] 0 1 0
## [3,] 0 0 1
## Measurement vector w: 1, 1, 1
## Initial values were optimised.
## 30 parameters were estimated in the process
## Residuals standard deviation: 1693.661
## Cost function type: MSE; Cost function value: 1981327
##
## Information criteria:
## AIC AICc BIC
## 1741.704 1769.886 1818.945
## Forecast errors:
## MPE: 14.4%; Bias: 74.6%; MAPE: 34.5%; SMAPE: 39.1%
## MASE: 2.456; sMAE: 100.2%; RelMAE: 1.049; sMSE: 183.6%
The resulting model will be equivalent to ETS(A,A,A). However due to different initialisation of optimisers and different method of number of parameters calculation, ges()
above and es(y, "AAA", h=h, holdout=TRUE)
will lead to different models.