## Time series Ensembling using 'ForecastHybrid'

There is no comparison of R when it comes to readily available packages. Where in python, you have to write your own code for even auto.arima, R has already come up with ensembling for advance time series algorithms like Neural Nets, seasonal ARIMA, state space model and seasonal decomposition models.

In conceptual terms most of the models are nothing but an extended version of regression. you can read this article to know more about it. Any time series is made up of 3 components-

or

One equation is additive and another is multiplicative of 3 components- st is seasonal component, Tt is trend component and Rt is remainder component. Box Jenkins ( ARMA) methods, time series decomposition methods ( STL, X11, SEATS etc)  and exponential smoothing methods are based on this equation only.
Advance time series algorithms like State space model with Kalman FilterFacebook's Prophet Model and Hidden Markov Models are not based on pure linear and multiplicative relations for time series components.

To start from the beginning one should try to get time series forecasting from regression itself. If someone is looking for quick forecasting , I would recommend Forecast Hybrid model of R. By default it included the below time series methods-

A) Auto.Arima- Identify best parameter for AR, MA and difference. Can be applicable on non stationary series as long as  differentiating gives a stationary series.

B) NNetr -   1) feedforward NN with only 1 hidden layer.
2) seasonality can also be included
3) data transformation can also be done using box-cox transformation( generally  used to have data normally distributed)

C) STLM -  1) time series is deseasonlised.
2) Decompose a time series into seasonal, trend and irregular components using loess.
3) Forecast after decomposition
4) Re-seasonalizing using the last year of the seasonal component

D) Thetam - This fits an exponential smoothing state space model.

E) ETS-        1)exponential time series smoothing.
2) All the lag values get continuously reduced Weighatge in forecast.

F) TBATS-    Exponential smoothing state space model with Box-Cox transformation, ARMA                                   errors,  Trend and Seasonal components

G) SNAIVE - Returns forecasts and prediction intervals from an ARIMA(0,0,0)(0,1,0)m model                                 where m is the seasonal period ( A seasonal Arima model)

We can also specify how much weight has to be given to each time series method or we can ensemble few of these, not all if we are more confident about data.

to run the model -

ts_train contains a uni-variate time series

install.packages("forecastHybrid")
library(forecastHybrid)
hm_model <- hybridModel(ts_train, weights = "insample.errors", errorMethod = "MASE")

output

> hm_model
Hybrid forecast model comprised of the following models: auto.arima, ets, thetam, nnetar, tbats

auto.arima with weight 0.196
ets with weight 0.192
thetam with weight 0.192
nnetar with weight 0.224

tbats with weight 0.196

values can be forecasted using

n ahead forecasts-
forecasted_values <- forecast(hm_model, n)

to see the fitting of all methods involved-

plot(hm_model, type = "fit")

We can't see as values are overlapped but nnet has performed best among all methods so it has got maximum weight out of all other methods.

I would suggest people to try HybridModel on uni-variate time series . it is going to perform well as it is based on the concept of bagging.