原文鏈接:http://tecdat.cn/?p=2841
此示例顯示MATLAB如何從復合條件均值和方差模型預測 和條件差異。
步驟1加載數據並擬合模型
加載工具箱附帶的納斯達克數據。將條件均值和方差模型擬合到數據中。
-
-
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);
第2步預測收益和條件差異
使用forecast
計算回報狀語從句:條件方差為1000周期的未來視界的MMSE預測。使用觀察到的回報和推斷殘差以及條件方差作為預采樣數據。
-
[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條件均值模型的無條件均值)。