MATLAB Answers


Using NN for forcasting

Asked by a
on 15 Jan 2013

Hi all,

I would like to design Feed forward NN for stock price forecasting. I've 3 years stock price datas which are consist of 2010,2011 and 2012.

I'm going to use 2010 and 2011 as training data and 2012 as forecasting.

This is an example input.

 % code
date            price
3-Jan-10	1271.87
4-Jan-10	1270.2
5-Jan-10	1276.56
6-Jan-10	1273.85
26-Dec-12	1419.83
27-Dec-12	1418.1
28-Dec-12	1402.43
31-Dec-12	1426.19

So how can I classify input, target and test data to NN ?


1 Answer

Answer by Shashank Prasanna
on 15 Jan 2013
 Accepted answer

What you are looking at is timeseries modeling and not a classification network. In order to forecast a time series such as your stock data you will need an autoregressive network which will capture the trend in the stock data.

Since you have a single time series with which you want to train a network and then forecast for future, a NARX network should work best for you. I would start by pointing you to this example in the MATLAB documentation that does exactly that. The GUI should guide you through it and generate code for future use or manipulation:

When you run ntstool, choose the NAR network since you don't have an external influence (such as another stock etc).


Greg Heath
on 16 Jan 2013

Change the 1 to 1:5


on 16 Jan 2013


In the generated code you can use the closed loop network for multi-step prediction.

Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!