This vignette covers ces()
and auto.ces()
functions, which are 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)
ces()
function allows constructing Complex Exponential Smoothing either with no seasonality, or with simple / partial / full seasonality. A simple call for ces()
results in estimation of non-seasonal model:
For the same series from M3 dataset ces()
can be constructed using:
ces(M3$N2457$x, h=18, holdout=TRUE)
## Time elapsed: 0.28 seconds
## Model estimated: CES(n)
## a0 + ia1: 1.10852+1.01143i
## Initial values were produced using backcasting.
## 3 parameters were estimated in the process
## Residuals standard deviation: 1419.223
## Cost function type: MSE; Cost function value: 1951899
##
## Information criteria:
## AIC AICc BIC
## 1686.252 1686.511 1693.977
##
## Forecast errors:
## MPE: 15.7%; Bias: 76.3%; MAPE: 37.3%; SMAPE: 42.7%
## MASE: 2.635; sMAE: 107.5%; RelMAE: 1.126; sMSE: 204.4%
This output is very similar to ones printed out by es()
function. The only difference is complex smoothing parameter values which are printed out instead of persistence vector in es()
.
If we want automatic model selection, then we use auto.ces()
function:
auto.ces(M3$N2457$x, h=18, holdout=TRUE, intervals=TRUE)
## Estimating CES with seasonality: "none" "simple" "partial" "full"
## The best model is with seasonality = "partial"
## Time elapsed: 1.05 seconds
## Model estimated: CES(p)
## a0 + ia1: 1.12697+1.01336i
## b: 0
## Initial values were produced using backcasting.
## 4 parameters were estimated in the process
## Residuals standard deviation: 1345.689
## Cost function type: MSE; Cost function value: 1736204
##
## Information criteria:
## AIC AICc BIC
## 1676.894 1677.328 1687.192
##
## 95% parametric prediction intervals were constructed
## 61% of values are in the prediction interval
## Forecast errors:
## MPE: 10.2%; Bias: 67.1%; MAPE: 33.7%; SMAPE: 36.7%
## MASE: 2.333; sMAE: 95.2%; RelMAE: 0.997; sMSE: 168.7%
Note that prediction intervals are too narrow and do not include 95% of values. This is because CES is pure additive model and it cannot take into account possible heteroscedasticity.
If for some reason we want to optimise initial values then we call:
auto.ces(M3$N2457$x, h=18, holdout=TRUE, initial="o", intervals=TRUE, intervalsType="s")
## Estimating CES with seasonality: "none" "simple" "partial" "full"
## The best model is with seasonality = "none"
## Time elapsed: 0.99 seconds
## Model estimated: CES(n)
## a0 + ia1: 1.09841+1.01221i
## Initial values were optimised.
## 5 parameters were estimated in the process
## Residuals standard deviation: 1430.254
## Cost function type: MSE; Cost function value: 1940181
##
## Information criteria:
## AIC AICc BIC
## 1689.668 1690.328 1702.542
##
## 95% semiparametric prediction intervals were constructed
## 61% of values are in the prediction interval
## Forecast errors:
## MPE: 15.2%; Bias: 75.7%; MAPE: 37.3%; SMAPE: 42.5%
## MASE: 2.622; sMAE: 107%; RelMAE: 1.12; sMSE: 202.9%
Now let’s introduce some artificial exogenous variables:
x <- cbind(rnorm(length(M3$N2457$x),50,3),rnorm(length(M3$N2457$x),100,7))
ces()
allows using exogenous variables and different types of prediction intervals in exactly the same manner as es()
:
auto.ces(M3$N2457$x, h=18, holdout=TRUE, xreg=x, intervals=TRUE)
## Estimating CES with seasonality: "none" "simple" "partial" "full"
## The best model is with seasonality = "partial"
## Time elapsed: 2 seconds
## Model estimated: CES(p)
## a0 + ia1: 1.20812+1i
## b: 0.0113
## Initial values were produced using backcasting.
## 6 parameters were estimated in the process
## Residuals standard deviation: 1354.556
## Xreg coefficients were estimated in a normal style
## Cost function type: MSE; Cost function value: 1721329
##
## Information criteria:
## AIC AICc BIC
## 1680.059 1680.992 1695.507
##
## 95% parametric prediction intervals were constructed
## 61% of values are in the prediction interval
## Forecast errors:
## MPE: 21.7%; Bias: 86.4%; MAPE: 36.8%; SMAPE: 43.9%
## MASE: 2.684; sMAE: 109.5%; RelMAE: 1.146; sMSE: 209.8%
The same model but with updated parameters of exogenous variables is called:
auto.ces(M3$N2457$x, h=18, holdout=TRUE, xreg=x, updateX=TRUE, intervals=TRUE)
## Estimating CES with seasonality: "none" "simple" "partial" "full"
## The best model is with seasonality = "simple"
## Time elapsed: 4.02 seconds
## Model estimated: CES(s)
## a0 + ia1: 1.02375+1.00508i
## Initial values were produced using backcasting.
## 11 parameters were estimated in the process
## Residuals standard deviation: 1355.572
## Xreg coefficients were estimated in a crazy style
## Cost function type: MSE; Cost function value: 1629192
##
## Information criteria:
## AIC AICc BIC
## 1684.723 1687.829 1713.045
##
## 95% parametric prediction intervals were constructed
## 44% of values are in the prediction interval
## Forecast errors:
## MPE: 19.7%; Bias: 83.6%; MAPE: 37.4%; SMAPE: 44.4%
## MASE: 2.7; sMAE: 110.2%; RelMAE: 1.153; sMSE: 217.5%