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

    %% Simulate and Filter  
% This example illustrates the relationship between |simulate| and |filter|.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Specify a GJR(1,1) model with Gaussian innovations. 
model = gjr('Constant',0.005,'GARCH',0.8,'ARCH',0.1,...
    'Leverage',0.05);  

%% 
% Simulate the model via Monte Carlo simulation. Then, standardize the simulated
% innovations and filter. 
rng(1); % For reproducibility
[v,e] = simulate(model,100,'E0',0,'V0',0.05);
Z = e./sqrt(v);
[V,E] = filter(model,Z,'Z0',0,'V0',0.05);  

%% 
% Confirm that the outputs of |simulate| and |filter| are identical. 
isequal(v,V) 

%%
% The logical value |1| confirms the two outputs are identical.