Over the year 2017 the smooth package has grown from v1.6.0 to v2.3.1. Now it is much more mature and has more downloads. It even now has its own hex (thanks to Fotios Petropoulos):
A lot of changes happened in 2017, and it is hard to mention all of them, but the major ones are:
- Introduction of ves() function (Vector Exponential Smoothing);
- Decrease of computation time of es(), ssarima() and other functions;
- More flexibility in es() function;
- Development of model selection mechanism for exogenous variables (this will be covered in one of the next posts in a couple of weeks);
- Development of intermittent data model for es(), ssarima(), ces() and ges() (will also be covered in one of the posts in 2018);
- Introduction of auto.ges() function, which allows selecting the most appropriate GES model for the data (once again, a post on that is planned);
- Switch to roxygen2 package for the maintenance purposes, which simplified my life substantially.
Not all of these things sound exciting, but any house is built brick by brick and some of those bricks are pretty fundamental. Now the new year has started, and I don’t have any intentions of stopping the development of smooth package. The 2018 will bring more interesting things and features, mainly driven by my research in multivariate models. At the moment I have the following list of features to implement:
- Intermittent VES model. This is driven by one of the topics I’m working together with John Boylan and Stephan Kolassa;
- Exogenous variables in VES model (also connected with that topic);
- Model selection mechanism in ves() models;
- Conditional intervals for VES model (currently only the version with independent intervals is implemented);
- State-space VARMA, which is needed for my research with Victoria Grigorieva and Yana Salihova;
- sim.iss() function, which should allow generating the occurrence part of intermittent data. This should be helpful for another research I plan to conduct together with John Boylan and Patricia Ramos;
- Vector SMA – the idea proposed by Mikhail Artukhov, this is yet another research topic;
- …And a lot of other cool things and features.
But before starting the work in those areas, I’ve decided to measure the performance of the most recent smooth functions (accuracy and computation time) and report it here. I used ets() and auto.arima() functions from forecast package as benchmarks. I have done this experiment in serial and included the following models:
- ES – the default exponential smoothing, ETS(Z,Z,Z) model produced by es() function from smooth;
- ESa – the same ETS model, but without multiplicative trends. This was needed in order to make a proper comparison with ets() function, which neglects the multiplicative trends by default. The call for this model is es(datasets[[i]],"ZXZ"). I report two versions of this thing: one from smooth v2.3.0 from CRAN and the other from smooth v2.3.1 available on GitHub. The latter has the advanced branch and bound mechanism for these types of models, while the former uses the brute force in model selection;
- SSARIMA – State-space ARIMA implemented in auto.ssarima() function from smooth;
- CES – Complex Exponential Smoothing via auto.ces() function from smooth;
- GES – Generalised Exponential Smoothing via auto.ges() function from smooth
- ETS – ETS model implemented in ets() function from forecast package;
- ETSm – ETS model with multiplicative trends, done via ets(dataset[[i]]$x, allow.multiplicative.trend=TRUE). This makes the function comparable with the default es();
- ARIMA – ARIMA model constructed using auto.arima() fucntion.
I used five error measures, some of which were discussed in the post about APEs, and aggregated them over the dataset using mean and median values. Here’s the list:
- MASE – Mean Absolute Scaled Error;
- sMAE – scaled Mean Absolute Error;
- RelMAE – Relative Mean Absolute Error (the benchmark in this case is a simple Naive and it should be aggregated using geometric mean rather than arithmetic);
- sMSE – scaled Mean Squared Error (MSE divided by the squared average actuals in-sample);
- sCE – scaled Cumulative Error (just the sum of errors divided by the average actuals in-sample);
The following code was used in the experiment, so feel free to use it for whatever purposes:
All the smooth functions can be applied to the data of class “Mcomp” directly: the in-sample data will be used for the fit of the model, the forecast of the needed length will be produced and then the accuracy of the forecast will be measured – everything in one go. Applying forecast functions is slightly trickier, and in order to have the same measurements I used Accuracy() function from smooth v2.3.1 (it is unavailable in earlier versions of the package).
I ended up having 5315 forecasts and I calculated those error measures for the whole dataset and for each of the following categories: yearly, quarterly, monthly and other data. You can find 6 tables with the results at the end of this page (the best value is in green bold). Things to notice are:
- ES performs similar to ETS, when they go through the similar models. e.g. ESa sometimes outperforms ETS and vice versa, but the difference is usually not significant (see, for example, Table 1. But this can also be observed in the other tables);
- ETS with multiplicative trends performs worse than the one without them. This holds for both es() and ets();
- SSARIMA performs (in terms of accuracy) similar to ARIMA on monthly and quarterly data, but fails on yearly data;
- CES and GES sometimes outperform other models, but this is not consistent;
- Branch and bound mechanism of es() is efficient and improves the performance of the function several times (29 minutes for the calculation of ESa v2.3.1 on the whole dataset vs 91 minutes of ESa v2.3.0) – see Table 6 for the details;
- The three fastest functions in the comparison are: ets() with the default parameters values, es() without multiplicative trends and ces()
Finally, I’ve conducted Nemenyi test using nemenyi() function from TStools package for RelMAE and for the computation time on the whole dataset in order to see if the differences between the models are on average statistically significant and how they rank (sort of average temperature in the hospital metrics). Keep in mind that this test compares the ranks of the contestants, but does not measure the distances between them. Here are the graphs produced by the function:
The graph above tells us that ETS, ES, ESa, ARIMA and ETSm overall perform similar to each other – they are in one group of models. The other models also perform very close to these, but probably slightly less accurate. In order to see if the difference between the models is indeed significant, we would need to conduct the similar experiment on a larger dataset (M4 maybe?).
This graph tells us that ets() is significantly faster than all the other functions and that ESa, ES and ARIMA have similar performance. Once again, thing to keep in mind is that 0.0001 second is faster than 0.0002 seconds, which means that the former would have rank 1 and the latter would have rank 2. This explains, why ESa is overall faster than ETS (see Table 6), but the Nemenyi test tells us the opposite.
Concluding this New Year experiment, I would say that smooth package is a good package and can now be efficiently used for automatic forecasting. But I’m biased, so don’t believe my words and give it a try yourselves ;).
Happy New Year!
|ES||ESa 2.3.0||ESa 2.3.1||SSARIMA||CES||GES||ETS||ETSm||ARIMA|