Backward prediction stock time series
1 次查看(过去 30 天)
显示 更早的评论
Hello Everyone,
Im currently writing my thesis and need to backward predict the values of a stock price time series.
I have data of a stock from 2018-2020, but i want to predict the values for 2016-2017 in order to have
a full time series from 2016-2020.
Could you help me with the coding or advice on how to do this? I the data of one of the stocks.
Appreciate you time guys!
0 个评论
回答(1 个)
Sulaymon Eshkabilov
2021-8-20
In this case, you'd need to perform the followings in order to extrapolate backward:
(1) Import data, e.g.:
D = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/717269/PR1C_dailyvalues.xlsx')
(2) Select rows where nans are not present:
IDX = isnan(D.PR1C);
(3) Convert the dates to numbers:
F1 = D(IDX==1,1).Date; F1D = datenum(F1); F1D=F1D-F1D(1)+1;
F2 = D(IDX==0,1).Date; F2D = datenum(F2); F2D=F2D-F2D(1)+1;
Data = D(IDX==0,2).PR1C;
(4) Find a fit model:
FM = fit(F2D,Data,'poly3'); % Cubic polynomial
(5) Compute the extrapolation values:
FIT_Data = polyval(FM, F1D);
% etc.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!