此示例顯示MATLAB如何從複合條件均值和方差模型預測 和條件差別。java
加載工具箱附帶的納斯達克數據。將條件均值和方差模型擬合到數據中。工具
nasdaq = DataTable.NASDAQ; r = price2ret(nasdaq); N = length(r); model = arima('ARLa gs' 1,'Variance',garch(1,1),... 'Distrib ution','t'); fit = estimate(mode ,r,'Variance0',{'Constant0',0.001}); ARIMA(1,0,0) Model (t Distribution): Value StandardError TStatistic PValue _________ _____________ __________ __________ Constant 0.0012326 0.00018163 6.786 1.1528e-11 AR{1} 0.066389 0.021398 3.1026 0.0019182 DoF 14.839 2.2588 6.5693 5.0539e-11 GARCH(1,1) Conditional Variance Model (t Distribution): Value StandardError TStatistic PValue __________ _____________ __________ __________ Constant 3.4488e-06 8.3938e-07 4.1087 3.9788e-05 GARCH{1} 0.82904 0.015535 53.365 0 ARCH{1} 0.16048 0.016331 9.8268 8.6333e-23 DoF 14.839 2.2588 6.5693 5.0539e-11 [E0,V0] = infer(fit,r);
使用forecast
計算回報狀語從句:條件方差爲1000週期的將來視界的MMSE預測。使用觀察到的回報和推斷殘差以及條件方差做爲預採樣數據。spa
[Y,YMS E,V] = forecast(fit, 100 0,'Y 0',r,'E0', E0, 'V0' ,V0); upper = Y + 1.96*sqrt(YMSE); lower = Y - 1.96*sqrt(YMSE); figure subplot(2,1,1) plot(r,'Color',[.75,.75,.75]) hold on plot(N+1:N+1000,Y,'r','LineWidth',2) plot(N+1:N+1000,[upper,lower],'k--','LineWidth',1.5) xlim([0,N+1000]) title('Forecasted Returns') hold off subplot(2,1,2) plot(V0,'Color',[.75,.75,.75]) hold on plot(N+1:N+1000,V,'r','LineWidth',2); xlim([0,N+1000]) title('Forecasted Conditional Variances') hold off
條件方差預測收斂於GARCH條件方差模型的漸近方差。預測的收益收斂於估計的模型常數(AR條件均值模型的無條件均值)。code