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

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

% Copyright 2015 The MathWorks, Inc.


%% 
% Simulate 100 observations from an EGARCH(1,1) model with known parameters. 
Mdl = egarch('Constant',0.01,'GARCH',0.6,'ARCH',0.2,...
            'Leverage',-0.2);
rng default; % For reproducibility
[v,y] = simulate(Mdl,100);

%% 
% Forecast the conditional variance 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.