I've got a question about stationarity: let's say I've made seasonal & trend adjustment for my time series input, scaled it and then passed this data to some NN model (e.g., LSTM or windowed-MLP), how do I add seasonal & trend components to the final answer?

  • 1
    $\begingroup$ This comment raises a rhetorical question. The authors of the paper Statistical and Machine Learning forecasting methods: Concerns and ways forward found that machine learning time series models, at a minimum, did not improve predictions over statistical models and in many cases were less computationally efficient (journals.plos.org/plosone/article/file?id=10.1371/…) Given these fairly conclusive findings, does it make sense to proceed with a NN model of time series at all when statistical models are so much more tractable, efficient, etc.? $\endgroup$
    – user78229
    Commented May 28, 2018 at 14:10
  • $\begingroup$ Well, I've found a lot of articles on arxiv.org that say NN models performs better than ARIMA-like methods. The issue is that I cannot integrate ARIMA into my Go code, and I can easily do it with NN model (just hardcode the weight of the model). $\endgroup$ Commented May 28, 2018 at 14:13
  • $\begingroup$ @AlexKornakov can you link to some of those articles? $\endgroup$
    – Skander H.
    Commented May 28, 2018 at 14:20
  • 1
    $\begingroup$ @Alex, well, one of the first articles I was able to google: researchgate.net/publication/… $\endgroup$ Commented May 28, 2018 at 14:31
  • $\begingroup$ @DJohnson anyway, what's the best way (aside from ARIMA and LR) to forecast time series than? One more article: eng.uber.com/neural-networks $\endgroup$ Commented May 28, 2018 at 14:32

1 Answer 1


To answer the main question:

how do I add seasonal & trend components to the final answer?

First you need to be careful with the terminology. Making a series stationary and removing trend and seasonality from a series are not the same thing - even though they are related.

More specifically - removing trend and seasonality might make a series stationary, but there is also the possibility that even after removing the trend and the seasonality, the series is still not stationary (for the variance is still no constant even after detrending and deseasonalising).

Bringing back the seasonality and the trend into the forecast after removing them also depends on what transformation you used to detrend and deseasonalize the signal in the first place.

If differencing was used to make the series stationary (the way it usually is in ARIMA models) then cumulative summing is how you reverse transform the data back to it's original shape. Note that when differencing is used, then the trend and seasonality are being removed implicitly not explicitly.

For example if your differencing order is one:

Original series:


Differenced series:

$Y_1 = X_1$

and for $n>1$

$Y_n = X_{n+1} - X_n$

Initial forecast series:


Final (summed) forecast series:

$\hat{X}_1 = \hat{Y}_1$

For $n>1$

$\hat{X}_n = \hat{Y}_1+\hat{Y}_2+...+\hat{Y}_n$

Other approaches such as Facebook Prophet (GAM based) or STL() try to model the trend $T$, the seasonal component $S$ and the residuals $R$ individually and then add them back together.

In such cases, you try to explicitly model the trend $\hat{T}$, the seasonality $\hat{S}$, and the residuals $\hat{R}$ and then you simply add them back together:

$\hat{X}_n = \hat{T}_n +\hat{S}_n+\hat{R}_n$.

A note on the use of Neural Networks based on the discussion in the comments on the OP (Full disclosure: I am more of a practitioner of time series - I do demand forecasting for retail - than an academic).

From what I see, the idea of Neural Networks - especially LSTM - outperforming traditional methods like ARIMA and exponential smoothing seems to driven mainly by the current overall hype for using Neural Networks and Tensorflow to try to solve every single data science problem out there. Google (and Amazon with their DeepAR model) have been pushing for this since it brings more customers to their cloud platform.

The results in the academic literature seem to be more nuanced and mixed.

In theory, for an LSTM to perform better than Triple Exponential Smoothing, Seasonal ARIMA or TBATS, means that your time series has to have highly complex non linear patterns beyond the seasonal and trend components. In practice, I've found such time series to be rare, and anything that can be modeled by an LSTM can also be modeled by a simpler statistical model with considerably less computational cost and the additional benefit of being easier to interpret.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.