# LSTM RNN Time-Series Residual

When making a time series forecast using LSTM RNN, how do you forecast more than one period in the future?

For instance, if I have a time series where the value $t_n$ denotes the value at interval $n$, it is straightforward to create a regressor for interval $t_n$. How then do I forecast at $t_{n+1}$? I can think of a number of ways, but they seem to have some problems:

1. Take the output at time $t_n$ and use it an an input, sliding the window to include the forecasted value.
2. Create a single model with $k$ outputs, forecasting each interval into the future.
3. Create a different regressor specifically for each of the $k$ values in the future that I want to predict.

The former seems more valuable to me than the latter as I don't have to train multiple models, saving on training time and cost of storing each of the models. The question then is, should I take this into account while training? Like, it seems that the model should find some use in knowing whether or not a data point is 'real' or 'forecasted', or potentially even how far into the future it was forecasted. For instance, pairing each input $t_{n-i}$ with the number of intervals ahead it was forecasted. So the first interval $t_n$ be based on some time-lagged, actual values, with "forecast interval" of $0$. Then the next forecast will include $t_1$ with "forecast interval" of $1$, and so on for some configured amount of intervals forward.

My questions are:

• Is this method viable? Is it necessary?
• Is there an easier way of doing this?
• How do I calculate the residuals when training?
• Do I just calculate a "full run" of all $k$ periods and calculate the RMSE (or other residual metric) of all of all of the predictions? I can then theoretically weight them based on different time scales that I need.

## 1 Answer

Have a look at different seq2seq methods out there. It is still a very new field so there will be quite a few obstacles but generally I would think 1 is the simplest to implement and it holds some general validity. You might see better results with the 2nd approach but first one is the most interesting and logical to try first

• I had seen mentions of seq2seq around, but saw it mostly in terms of language translation. Thinking on it, it seems to make sense that taking a sequence of time lagged values and outputting a sequence of forecasts could map in a similar way! I'll investigate and see if there's any literature on this, thanks! – Nate Diamond May 1 '17 at 18:03
• Literature might be challenging to find - machinelearning mastery has great mini blogs with nice code snippets though – tRosenflanz May 2 '17 at 16:00
• This is a treasure trove! Thank you for bringing this to my attention! – Nate Diamond May 2 '17 at 17:25