# Delay issue in time series prediction

I am having an issue using neural networks to predict time series. Some predicted data fits with the expected data, as bellow: (In black the real time series and in blue the output of my neural network)

Time serie: Australia energy demand.

But with the same code, with other time series, the predicted data does not fits with the expected data, and has a delay of one unit, as bellow:

Time serie: Walmart Stock price. Time serie: Dollar libra exchange.

I found some articles about some variations of neural networks and at the results section shows the plot with the delay like my results, as bellow:

Time serie: Dollar libra exchange. (Article link: http://www.sciencedirect.com/science/article/pii/S1877050915015793)

Anyone knows if this is a common behavior or can be something wrong with my code ? I am having this issue about three months ago, and since there I am trying to figure out some bug in my code but is all right.

Thanks and I appreciate any tip.

• What type of neural network are you using and what are your parameters? – noumenal Feb 19 '16 at 20:23
• @noumenal I am using the Extreme Learning Machine. Source code ntu.edu.sg/home/egbhuang/elm_codes.html. Each data set has different parameters. – ViniciusArruda Feb 22 '16 at 13:26

## 2 Answers

Something could always be wrong with your code, but this type of behavior would be consistent with a model that was similar to a random walk.

A random walk (without drift) would be specified as follows; $$y_t = y_{t-1} + \varepsilon_t$$ where $E[e_t] = 0$. Thus $E[Y_t|y_1,...,y_{t-1}] = y_{t-1}$. So when you graph your predictions against actual observations, it will look as though your predictions are delayed by one unit, when in fact the forecasts are just using the contemporaneous observation as next periods prediction.

Not knowing anything else about your neural network model and code, my best guess would be that the model converged on something similar to a random walk (the graph does suggest that there are additional trend/drift components at work too though).

• Sorry for the delay in answering you, but I was researching about my neural network and the random walk. I have concluded that my model, for some time series, is having this issue. Can you give me some reference, if you have, about it and how to get rid of this problem in neural networks or other kind of modeling ? The unique solution for me was tune the parameters from my net, but this not helped a lot. – ViniciusArruda Apr 19 '16 at 19:42
• @ViniciusArruda I don't know if I would call this instance a "problem". It doesn't look great on a plot, but forecasting next period's value with that of the current period is sometimes one of the best predictions available. This is especially true with financial time series that do not have strong seasonal patterns. I do not have a citation for you, but modeling some equities and stock market indices as random walks over long run periods is common place and there are theoretical arguments for this behavior as well. – Zachary Blumenfeld Apr 20 '16 at 18:49
• Sorry for lack of citation but a google search into random walks in finance should get you started. If you have not done so already, you could try transforming the series to percentage changes so that it is stationary. I am not familiar enough with neural networks to know whether or not they can deal with non-stationary. My brief exposure to the basics suggests that they cannot do so directly, at least in the standard case. By transforming the series you can perhaps leverage the neural network to find non-linear relationships in percentage changes that are not apparent between price levels. – Zachary Blumenfeld Apr 20 '16 at 19:02

The problem is because of the existing overlap between the last record of train data and the first record of test data. You should simply drop the last time-stamp of train data!

train = train.iloc[:-1, :]