%% Estimate GARCH Model Parameters Without Initial Values
% Fit a GARCH(1,1) model to simulated data.
% Simulate 500 data points from the GARCH(1,1) model
% {y_t} = {\varepsilon _t},
% where \varepsilon_t = \sigma_tz_t and
% \sigma _t^2 = 0.0001 + 0.5\sigma _{t - 1}^2 + 0.2\varepsilon _{t - 1}^2.
% Use the default Gaussian innovation distribution for z_{t}.

Mdl0 = garch('Constant',0.0001,'GARCH',0.5,...
    'ARCH',0.2);
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 a GARCH(1,1) model with unknown coefficients, and fit it to the series y.

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

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