%% Estimate EGARCH Model Parameters Without Initial Values
% Fit an EGARCH(1,1) model to simulated data.
% Simulate 500 data points from an EGARCH(1,1) model
% {y_t} = {\varepsilon _t},
% where {\varepsilon _t} = {\sigma _t}{z_t}, and
% \log \sigma _t^2 = 0.001 + 0.7\log \sigma _{t - 1}^2 + 0.5\left[ {\frac{{\left| {{\varepsilon _{t - 1}}} \right|}}{{{\sigma _{t - 1}}}} - \sqrt {\frac{2}{\pi }} } \right] - 0.3\left( {\frac{{{\varepsilon _{t - 1}}}}{{{\sigma _{t - 1}}}}} \right)
% (the distribution of z_{t} is Gaussian).

Mdl0 = egarch('Constant',0.001,'GARCH',0.7,...
               'ARCH',0.5,'Leverage',-0.3);

rng default % For reproducibility 
[v,y] = simulate(Mdl0,500);

% The output v contains simulated conditional variances. y is a column vector of simulated responses (innovations).
%
% Specify an EGARCH(1,1) model with unknown coefficients, and fit it to the series y.

Mdl = egarch(1,1);
EstMdl = estimate(Mdl,y)

% The result is a new egarch model called EstMdl. The parameter estimates in EstMdl resemble the parameter values that generated the simulated data.
% Copyright 2015 The MathWorks, Inc.