www.gusucode.com > econ 案例源码程序 matlab代码 > econ/ForecastConditionalVariancesGarchForecastExample.m

    %% Forecast GARCH Model Conditional Variances 
% Forecast the conditional variance of simulated data over a 30-period
% horizon.

% Copyright 2015 The MathWorks, Inc.


%% 
% Simulate 100 observations from a GARCH(1,1) model with known parameters. 
Mdl = garch('Constant',0.02,'GARCH',0.8,'ARCH',0.1);
rng default; % For reproducibility
[v,y] = simulate(Mdl,100);  

%% 
% Forecast the conditional variances over a 30-period horizon, with and
% without using the simulated data as presample innovations. Plot the forecasts. 
vF1 = forecast(Mdl,30,'Y0',y);
vF2 = forecast(Mdl,30);

figure
plot(v,'Color',[.7,.7,.7])
hold on
plot(101:130,vF1,'r','LineWidth',2);
plot(101:130,vF2,':','LineWidth',2);
title('Forecasted Conditional Variances')
legend('Observed','Forecasts with Presamples',...
		'Forecasts without Presamples','Location','NorthEast')
hold off    

%%
% Forecasts made without using presample innovations equal the unconditional
% innovation variance. Forecasts made using presample innovations converge
% asymptotically to the unconditional innovation variance.