Documentation

Using garch Objects

GARCH conditional variance time series model

A garch model object specifies the functional form and stores the parameter values of a generalized autoregressive conditional heteroscedastic (GARCH) model. GARCH models attempt to address volatility clustering in an innovations process. Volatility clustering occurs when an innovations process does not exhibit significant autocorrelation, but the variance of the process changes with time. GARCH models are appropriate when positive and negative shocks of equal magnitude contribute equally to volatility [1].

The GARCH(P,Q) conditional variance model includes:

  • P past conditional variances that compose the GARCH component polynomial

  • Q past squared innovations that compose the ARCH component polynomial

To create a garch model object, use garch. Specify only the GARCH and ARCH polynomial degrees P and Q, respectively, using the shorthand syntax garch(P,Q). Then, pass the model and time series data to estimate to fit the model to the data. Or, specify the values of some parameters, and then estimate others.

Use a completely specified model (i.e., all parameter values of the model are known) to:

  • Simulate conditional variances or responses using simulate

  • Forecast conditional variances using forecast

Examples

collapse all

Create GARCH Model

Create a garch model using name-value pair arguments.

Specify a GARCH(1,1) model. By default, the conditional mean model offset is zero. Specify that the offset is NaN.

Mdl = garch('GARCHLags',1,'ARCHLags',1,'Offset',NaN)
Mdl = 

    GARCH(1,1) Conditional Variance Model with Offset:
    --------------------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 1
               Q: 1
        Constant: NaN
           GARCH: {NaN} at Lags [1]
            ARCH: {NaN} at Lags [1]
          Offset: NaN

Mdl is a garch model object. The software sets all parameters (the properties of the model object) to NaN, except P, Q, and Distribution.

Since Mdl contains NaN values, Mdl is only appropriate for estimation only. Pass Mdl and time-series data to estimate. For a continuation of this example, see Estimate GARCH Model.

Create GARCH Model Using Shorthand Syntax

Create a garch model using the shorthand notation garch(P,Q), where P is the degree of the GARCH polynomial and Q is the degree of the ARCH polynomial.

Create a GARCH(3,2) model.

Mdl = garch(3,2)
Mdl = 

    GARCH(3,2) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 3
               Q: 2
        Constant: NaN
           GARCH: {NaN NaN NaN} at Lags [1 2 3]
            ARCH: {NaN NaN} at Lags [1 2]

Mdl is a garch model object. All properties of Mdl, except P, Q, and Distribution, are NaN values. By default, the software:

  • Includes a conditional variance model constant

  • Excludes a conditional mean model offset (i.e., the offset is 0)

  • Includes all lag terms in the ARCH and GARCH lag-operator polynomials up to lags Q and P, respectively

Mdl specifies only the functional form of a GARCH model. Because it contains unknown parameter values, you can pass Mdl and the time-series data to estimate to estimate the parameters.

Access GARCH Model Properties

Access the properties of a garch model object using dot notation.

Create a garch model object.

Mdl = garch(3,2)
Mdl = 

    GARCH(3,2) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 3
               Q: 2
        Constant: NaN
           GARCH: {NaN NaN NaN} at Lags [1 2 3]
            ARCH: {NaN NaN} at Lags [1 2]

Remove the second GARCH term from the model. That is, specify that the GARCH coefficient of the second lagged conditional variance is 0.

Mdl.GARCH{2} = 0
Mdl = 

    GARCH(3,2) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 'Gaussian'
               P: 3
               Q: 2
        Constant: NaN
           GARCH: {NaN NaN} at Lags [1 3]
            ARCH: {NaN NaN} at Lags [1 2]

The GARCH polynomial has two unknown parameters corresponding to lags 1 and 3.

Display the distribution of the disturbances.

Mdl.Distribution
ans = 

    Name: 'Gaussian'

The disturbances are Gaussian with mean 0 and variance 1.

Specify that the underlying I.I.D. disturbances have a t distribution with five degrees of freedom.

Mdl.Distribution = struct('Name','t','DoF',5)
Mdl = 

    GARCH(3,2) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 't', DoF = 5
               P: 3
               Q: 2
        Constant: NaN
           GARCH: {NaN NaN} at Lags [1 3]
            ARCH: {NaN NaN} at Lags [1 2]

Specify that the ARCH coefficients are 0.2 for the first lag and 0.1 for the second lag.

Mdl.ARCH = {0.2 0.1}
Mdl = 

    GARCH(3,2) Conditional Variance Model:
    --------------------------------------  
    Distribution: Name = 't', DoF = 5
               P: 3
               Q: 2
        Constant: NaN
           GARCH: {NaN NaN} at Lags [1 3]
            ARCH: {0.2 0.1} at Lags [1 2]

To estimate the remaining parameters, you can pass Mdl and your data to estimate and use the specified parameters as equality constraints. Or, you can specify the rest of the parameter values, and then simulate or forecast conditional variances from the GARCH model by passing the fully specified model to simulate or forecast, respectively.

Estimate GARCH Model

Fit a GARCH model to an annual time series of Danish nominal stock returns from 1922-1999. The example follows from Create GARCH Model.

Load the Data_Danish data set. Plot the nominal returns (nr).

load Data_Danish;
nr = DataTable.RN;

figure;
plot(dates,nr);
hold on;
plot([dates(1) dates(end)],[0 0],'r:'); % Plot y = 0
hold off;
title('Danish Nominal Stock Returns');
ylabel('Nominal return (%)');
xlabel('Year');

The nominal return series seems to have a nonzero conditional mean offset and seems to exhibit volatility clustering. That is, the variability is smaller for earlier years than it is for later years. For this example, assume that a GARCH(1,1) model is appropriate for this series.

Create a GARCH(1,1) model. The conditional mean offset is zero by default. To estimate the offset, specify that it is NaN.

Mdl = garch('GARCHLags',1,'ARCHLags',1,'Offset',NaN);

Fit the GARCH(1,1) model to the data.

EstMdl = estimate(Mdl,nr);
 
    GARCH(1,1) Conditional Variance Model:
    ----------------------------------------
    Conditional Probability Distribution: Gaussian

                                  Standard          t     
     Parameter       Value          Error       Statistic 
    -----------   -----------   ------------   -----------
     Constant     0.00444761    0.00781404       0.569182
     GARCH{1}       0.849317      0.264946        3.20563
      ARCH{1}      0.0732495      0.149532       0.489857
       Offset       0.112266     0.0392138        2.86293

EstMdl is a fully specified garch model object. That is, it does not contain NaN values. You can assess the adequacy of the model by generating residuals using infer, and then analyzing them.

To simulate conditional variances or responses, pass EstMdl to simulate. See Simulate GARCH Model Observations and Conditional Variances.

To forecast innovations, pass EstMdl to forecast. See Forecast GARCH Model Conditional Variances.

Simulate GARCH Model Observations and Conditional Variances

Simulate conditional variance or response paths from a fully specified garch model object. That is, simulate from an estimated garch model or a known garch model in which you specify all parameter values. This example follows from Estimate GARCH Model.

Load the Data_Danish data set.

load Data_Danish;
nr = DataTable.RN;

Create a GARCH(1,1) model with an unknown conditional mean offset. Fit the model to the annual nominal return series.

Mdl = garch('GARCHLags',1,'ARCHLags',1,'Offset',NaN);
EstMdl = estimate(Mdl,nr);
 
    GARCH(1,1) Conditional Variance Model:
    ----------------------------------------
    Conditional Probability Distribution: Gaussian

                                  Standard          t     
     Parameter       Value          Error       Statistic 
    -----------   -----------   ------------   -----------
     Constant     0.00444761    0.00781404       0.569182
     GARCH{1}       0.849317      0.264946        3.20563
      ARCH{1}      0.0732495      0.149532       0.489857
       Offset       0.112266     0.0392138        2.86293

Simulate 100 paths of conditional variances and responses for each period from the estimated GARCH model.

numObs = numel(nr); % Sample size (T)
numPaths = 100;     % Number of paths to simulate
rng(1);             % For reproducibility
[VSim,YSim] = simulate(EstMdl,numObs,'NumPaths',numPaths);

VSim and YSim are T-by- numPaths matrices. Rows correspond to a sample period, and columns correspond to a simulated path.

Plot the average and the 97.5% and 2.5% percentiles of the simulated paths. Compare the simulation statistics to the original data.

VSimBar = mean(VSim,2);
VSimCI = quantile(VSim,[0.025 0.975],2);
YSimBar = mean(YSim,2);
YSimCI = quantile(YSim,[0.025 0.975],2);

figure;
subplot(2,1,1);
h1 = plot(dates,VSim,'Color',0.8*ones(1,3));
hold on;
h2 = plot(dates,VSimBar,'k--','LineWidth',2);
h3 = plot(dates,VSimCI,'r--','LineWidth',2);
hold off;
title('Simulated Conditional Variances');
ylabel('Cond. var.');
xlabel('Year');

subplot(2,1,2);
h1 = plot(dates,YSim,'Color',0.8*ones(1,3));
hold on;
h2 = plot(dates,YSimBar,'k--','LineWidth',2);
h3 = plot(dates,YSimCI,'r--','LineWidth',2);
hold off;
title('Simulated Nominal Returns');
ylabel('Nominal return (%)');
xlabel('Year');
legend([h1(1) h2 h3(1)],{'Simulated path' 'Mean' 'Confidence bounds'},...
    'FontSize',7,'Location','NorthWest');

Forecast GARCH Model Conditional Variances

Forecast conditional variances from a fully specified garch model object. That is, forecast from an estimated garch model or a known garch model in which you specify all parameter values. The example follows from Estimate GARCH Model.

Load the Data_Danish data set.

load Data_Danish;
nr = DataTable.RN;

Create a GARCH(1,1) model with an unknown conditional mean offset, and fit the model to the annual, nominal return series.

Mdl = garch('GARCHLags',1,'ARCHLags',1,'Offset',NaN);
EstMdl = estimate(Mdl,nr);
 
    GARCH(1,1) Conditional Variance Model:
    ----------------------------------------
    Conditional Probability Distribution: Gaussian

                                  Standard          t     
     Parameter       Value          Error       Statistic 
    -----------   -----------   ------------   -----------
     Constant     0.00444761    0.00781404       0.569182
     GARCH{1}       0.849317      0.264946        3.20563
      ARCH{1}      0.0732495      0.149532       0.489857
       Offset       0.112266     0.0392138        2.86293

Forecast the conditional variance of the nominal return series 10 years into the future using the estimated GARCH model. Specify the entire returns series as presample observations. The software infers presample conditional variances using the presample observations and the model.

numPeriods = 10;
vF = forecast(EstMdl,numPeriods,'Y0',nr);

Plot the forecasted conditional variances of the nominal returns. Compare the forecasts to the observed conditional variances.

v = infer(EstMdl,nr);

figure;
plot(dates,v,'k:','LineWidth',2);
hold on;
plot(dates(end):dates(end) + 10,[v(end);vF],'r','LineWidth',2);
title('Forecasted Conditional Variances of Nominal Returns');
ylabel('Conditional variances');
xlabel('Year');
legend({'Estimation sample cond. var.','Forecasted cond. var.'},...
    'Location','Best');

Related Examples

Properties

Conditional Variance Model Properties Specify conditional variance model functional form and parameter values

Object Functions

estimate Fit conditional variance model to data
filter Filter disturbances through conditional variance model
forecast Forecast conditional variances from conditional variance models
infer Infer conditional variances of conditional variance models
print Display parameter estimation results for conditional variance models
simulate Monte Carlo simulation of conditional variance models

Create Object

Create garch models using garch.

You can specify a garch model as part of a composition of conditional mean and variance models. For details, see arima.

Introduced in R2012a

Was this topic helpful?