Backward prediction stock time series

1 次查看(过去 30 天)
ingCr
ingCr 2021-8-20
评论: ingCr 2021-8-24
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!

回答(1 个)

Sulaymon Eshkabilov
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.
  1 个评论
ingCr
ingCr 2021-8-24
Thanks! that helped me a lot. The only thing is that I stil cant make the backward prediction. Keeps telling me that there is a problem with the data structure.
Do you happen to know who to do the same but with a time-series model?
Appreciate your time!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Financial Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by