NAR network outputing previous (t-1) value. Why?
Show older comments
Hello,
I have a problem with the MATLAB NAR network, which I have noticed elsewhere (I'll explain a bit later on). I'll explain this in layman's terms:
Basically, when I load a time series into MATLAB (for example, a stock price over time, spanning, say 5 years), I have a suitable timeseries where I would like the NAR network (say, with delay=5), to learn the past (previous) five closing prices and it's relation to the next closing price.
The NAR will learn this, one step at a time, looking at the previous 5 prices, and calculating their relation to the current price (which the network is also shown). The network will advance through all the 5 years of data, learning by example (current position price vs last 5 prices), etc., etc.
That all seems good and well. However, with data that the NAR has already seen, whenever I ask the network 5 previous prices (which it has seen), it should output (calculate) the next price (which it has also seen during training). This is what I would expect of any network (unless I'm totally wrong here).
But instead, the NAR outputs the previous (t-1) price. So, basically (where p = price):
I expect: (p(t-5), p(t-4), p(t-3), p(t-2), p(t-1)) = p(t)
but the NAR gives me: (p(t-5), p(t-4), p(t-3), p(t-2), p(t-1)) = p(t-1)
(this with data that the NAR has already seen)
Why is this?
I also built an Elman network using Encog, and got basically the same results. Tried a Deep Belief network using Accord.NET and the same thing. Tried standard feedforward, Jordan, SVM, RBF, etc. Nothing does it. Why?
They are all acting like naive predictors.
Independently from my code/data I have used, I've tried with a simple timeseries (1, 2, 3, 4, 5 .... 2000) and all networks learn perfectly, but not with stock prices.
I've also tried using deltas, log, sqrt, etc. with no luck (on stock data).
I've tried several delays: d=5, d=7, d=10, d=20, d=30, d=40, d=50, d=100 and only d=50 turned up not exactly a naive predictor, but results were significantly off using just training data.
These experiments have been made only with training data.
Why? Is stock price data "unlearnable"?
I've seen this question asked some other places, but no satisfactory answer.
As a sidenote, all MATLAB code was done using nnstart.
Thanks!
21 Comments
Greg Heath
on 6 Dec 2016
You are going to have to either post one or more data examples or their links
Greg
Greg Heath
on 7 Dec 2016
You did not post any data or data links as requested.
It doesn't have to be your data.
MATLAB NARNET examples from
help nndatasets
doc nndatsets
are acceptable as long as it exemplifies your problem.
In fact, the simpler the data, the clearer the answer to your problem.
Greg
Molasar
on 7 Dec 2016
Greg Heath
on 8 Dec 2016
Sorry, having EXCEL problems.
Please convert to *.txt or *.m
Thanks
Greg
Molasar
on 8 Dec 2016
Molasar
on 8 Dec 2016
Following this question with utmost interest. Have read various papers about stock price forecasting using ANNs but the researchers completely failed to notice their charts are time-shifted one day (ANN validation resolves to previous price). How could they miss that?
Examples:
https://arxiv.org/ftp/arxiv/papers/1502/1502.06434.pdf
https://www.duo.uio.no/bitstream/handle/10852/44765/aamodt-master.pdf?sequence=7 (page 65, 67, 69, 73, etc)
https://nseindia.com/content/research/FinalPaper206.pdf
List goes on and on.....
Molasar
on 8 Dec 2016
Bob Koren
on 14 Dec 2016
Anyone?
Molasar
on 16 Dec 2016
Greg Heath
on 4 Jan 2017
Sorry for the lack of responses. My computer and MATLAB installation do not work correctly. I haven't has sufficient time to fix either.
Hope I don't need a new machine.
Greg
Brendan Hamm
on 4 Jan 2017
Likely this would require seeing your code to determine the issue. Please post a simple example of this not working, preferably with a sample data set shipped with MATLAB like:
load Data_GlobalIdx2
or
load stockreturns
Molasar
on 4 Jan 2017
Molasar
on 5 Jan 2017
Bob Koren
on 5 Jan 2017
Unbelievable!
Brendan Hamm
on 6 Jan 2017
It is not that it is outputting the t-1 value, you can see there is a difference. A similar pattern with a lag is not the same as returning to you the previous value, so you have mislead with your original statement.
What is happening is your response is influenced by the lagged prices which is exactly what I would expect for an AR model which has positive auto-correlation at lag 1. What you've learned is that the patterns of stock prices are not a deterministic function of previous stock prices. I would not be surprised by this result.
It's not that Neural Networks are not useful for stock data, it's just that such a simplistic model is not going to give you any useful information.
Brendan Hamm
on 9 Jan 2017
I would likely consider exogenous variables. Possibly macro variables, volume/momentum, or even data derived from Twitter posts.
Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

