%% Filter Disturbances Through GJR Model Specifying Presample Observations
% Specify a GJR(1,2) model with Gaussian innovations.

Mdl = gjr('Constant',0.005,'GARCH',0.8,'ARCH',{0.1 0.01},...
    'Leverage',{0.05 0.01});

%
% Simulate 25 series of standard Gaussian observations for 102 periods.

rng(1); % For reproducibility
Z = randn(102,25);

% Z represents 25 paths of synchronized disturbances for 102 periods.
%
% Obtain 25, 100 period paths of conditional variances by filtering the disturbance paths through the GJR(1,2) model. Specify the first two disturbances as presample observations.

V = filter(Mdl,Z(3:end,:),'Z0',Z(1:2,:));

%
% Plot the paths of conditional variances.

figure;
plot(V);
title('Conditional Variance Paths');
xlabel('Periods');

% Copyright 2015 The MathWorks, Inc.