%% Simulate and Filter
% Specify an EGARCH(1,1) model with Gaussian innovations.

Mdl = egarch('Constant',-0.1,'GARCH',0.8,'ARCH',0.3,...
    'Leverage',-0.05);

%
% Simulate the model using Monte Carlo simulation. Then, standardize the simulated innovations and filter them.

[v,e] = simulate(Mdl,100,'E0',0,'V0',0.6);
Z = e./sqrt(v);
[V,E] = filter(Mdl,Z,'Z0',0,'V0',0.6);

%
% Confirm that the outputs of simulate and filter are identical.

sum(abs(v-V))

% The two series are identical to high precision.
% Copyright 2015 The MathWorks, Inc.