Can I use matlab to curve fit/predict market price of a company? I
Show older comments
Ok, So I want to model the closing price of Apple (for educational purpose) and I am looking for mathematical tools that would make it easier. I have used excel to get a trend line of 6th degree polynomial. <https://docs.google.com/file/d/0Bz9r9M4ruXtrWjMwUmRtNTVfbGc/edit?usp=sharing>
I want my input to have the data integrated from 1990 to 2010 and with that, i want the my estimation function to be able to approximate closing price of 10 years.
I know i have to use probability and statistics theories but i wanted some specific answers about what theory I must use.
I would be glad if you could guide me to the tools that can be used in matlab for the job and also, tutorials too :D
Thanks
Answers (2)
Sean de Wolski
on 17 Sep 2013
Edited: Sean de Wolski
on 17 Sep 2013
Do you have the curve fitting toolbox? If so, either click on the curve fitting app in the apps gallery or run:
>> cftool
This will pull up an interactive environment for you to do your curve fitting.
As an aside, I highly recommend against fitting high order polynomials to anything. They're highly unstable, overfit to noise, are useless for prediction and have no place in physics. If you are trying to fit to something that does not have an analytic model, such as a stock price, use one of the data driven modeling techniques. This webinar might interest you:
2 Comments
Muthu Annamalai
on 17 Sep 2013
I've heard if you use a n+1 degree polynomial to perfectly fit any n-points :-). Complex coefficients in question in the most general case.
Image Analyst
on 17 Sep 2013
Yes, but with such Lagrange polynomials you can get wild oscillations in-between the training points. http://melissacabral.wordpress.com/2009/11/29/lagrange-interpolating-polynomial-2/, http://people.sc.fsu.edu/~jburkardt/m_src/lagrange_interp_1d/p07_lageven_16.png
Image Analyst
on 17 Sep 2013
Try this untested code:
[coeffs, s, mu] = polyfit(dates, prices, 6);
extrapolatedPrices = polyval(coeffs, extrapolatedDates, s, mu);
plot(extrapolatedDates, extrapolatedPrices, 'b-', 'LineWidth', 3);
grid on;
fontSize = 24;
title('Apple Stock', 'FontSize', fontSize);
xlabel('Date', 'FontSize', fontSize);
ylabel('Stock Price', 'FontSize', fontSize);
Of course you need to supply the arrays with the known stock prices and the dates.
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!