1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| % transform into a stationary TS with 3027 data
nasdaq = price2ret(NASDAQ);
% specifing the model
spec = garchset('VarianceModel','GJR',...
'R',1,'M',1,'P',1,'Q',1);
spec = garchset(spec,'Display','off','Distribution','T');
% taking the first 3000 values to fit the model and forecasting
% the next 27 values of nasdaq
for i = 1:1
[coeff,errors,LLF,eFit,sFit] = garchfit(spec,nasdaq(i:2999+i));
[sigmaForecast,meanForecast,sigmaTotal,meanRMSE] = ...
garchpred(coeff,nasdaq(i:2999+i),1);
sForecast(i,1) = sigmaForecast;
mForecast(i,1) = meanForecast;
sTotal(i,1) = sigmaTotal;
mRMSE(i,1) = meanRMSE;
i = i + 1;
end |
Partager