# garch

GARCH conditional variance time series model

## Description

Use `garch` to specify a univariate GARCH (generalized autoregressive conditional heteroscedastic) model. The `garch` function returns a `garch` object specifying the functional form of a GARCH(P,Q) model, and stores its parameter values.

The key components of a `garch` model include the:

• GARCH polynomial, which is composed of lagged conditional variances. The degree is denoted by P.

• ARCH polynomial, which is composed of the lagged squared innovations. The degree is denoted by Q.

P and Q are the maximum nonzero lags in the GARCH and ARCH polynomials, respectively. Other model components include an innovation mean model offset, a conditional variance model constant, and the innovations distribution.

All coefficients are unknown (`NaN` values) and estimable unless you specify their values using name-value pair argument syntax. To estimate models containing all or partially unknown parameter values given data, use `estimate`. For completely specified models (models in which all parameter values are known), simulate or forecast responses using `simulate` or `forecast`, respectively.

## Creation

### Syntax

``Mdl = garch``
``Mdl = garch(P,Q)``
``Mdl = garch(Name,Value)``

### Description

example

``Mdl = garch` returns a zero-degree conditional variance `garch` object.`

example

````Mdl = garch(P,Q)` creates a GARCH conditional variance model object (`Mdl`) with a GARCH polynomial with a degree of `P` and an ARCH polynomial with a degree of `Q`. The GARCH and ARCH polynomials contain all consecutive lags from 1 through their degrees, and all coefficients are `NaN` values. This shorthand syntax enables you to create a template in which you specify the polynomial degrees explicitly. The model template is suited for unrestricted parameter estimation, that is, estimation without any parameter equality constraints. However, after you create a model, you can alter property values using dot notation. ```

example

``Mdl = garch(Name,Value)` sets properties or additional options using name-value pair arguments. Enclose each name in quotes. For example, `'ARCHLags',[1 4],'ARCH',{0.2 0.3}` specifies the two ARCH coefficients in `ARCH` at lags `1` and `4`.This longhand syntax enables you to create more flexible models.`

### Input Arguments

expand all

The shorthand syntax provides an easy way for you to create model templates that are suitable for unrestricted parameter estimation. For example, to create a GARCH(1,2) model containing unknown parameter values, enter:

`Mdl = garch(1,2);`
To impose equality constraints on parameter values during estimation, set the appropriate property values using dot notation.

GARCH polynomial degree, specified as a nonnegative integer. In the GARCH polynomial and at time t, MATLAB® includes all consecutive conditional variance terms from lag t – 1 through lag t`P`.

You can specify this argument using the `garch``(P,Q)` shorthand syntax only.

If `P` > 0, then you must specify `Q` as a positive integer.

Example: `garch(1,1)`

Data Types: `double`

ARCH polynomial degree, specified as a nonnegative integer. In the ARCH polynomial and at time t, MATLAB includes all consecutive squared innovation terms from lag t – 1 through lag t`Q`.

You can specify this argument using the `garch``(P,Q)` shorthand syntax only.

If `P` > 0, then you must specify `Q` as a positive integer.

Example: `garch(1,1)`

Data Types: `double`

#### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside quotes. You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

The longhand syntax enables you to create models in which some or all coefficients are known. During estimation, `estimate` imposes equality constraints on any known parameters.

Example: `'ARCHLags',[1 4],'ARCH',{NaN NaN}` specifies a GARCH(0,4) model and unknown, but nonzero, ARCH coefficient matrices at lags `1` and `4`.

GARCH polynomial lags, specified as the comma-separated pair consisting of `'GARCHLags'` and a numeric vector of unique positive integers.

`GARCHLags(j)` is the lag corresponding to the coefficient `GARCH{j}`. The lengths of `GARCHLags` and `GARCH` must be equal.

Assuming all GARCH coefficients (specified by the `GARCH` property) are positive or `NaN` values, `max(GARCHLags)` determines the value of the `P` property.

Example: `'GARCHLags',[1 4]`

Data Types: `double`

ARCH polynomial lags, specified as the comma-separated pair consisting of `'ARCHLags'` and a numeric vector of unique positive integers.

`ARCHLags(j)` is the lag corresponding to the coefficient `ARCH{j}`. The lengths of `ARCHLags` and `ARCH` must be equal.

Assuming all ARCH coefficients (specified by the `ARCH` property) are positive or `NaN` values, `max(ARCHLags)` determines the value of the `Q` property.

Example: `'ARCHLags',[1 4]`

Data Types: `double`

## Properties

expand all

You can set writable property values when you create the model object by using name-value pair argument syntax, or after you create the model object by using dot notation. For example, to create a GARCH(1,1) model with unknown coefficients, and then specify a t innovation distribution with unknown degrees of freedom, enter:

```Mdl = garch('GARCHLags',1,'ARCHLags',1); Mdl.Distribution = "t";```

GARCH polynomial degree, specified as a nonnegative integer. `P` is the maximum lag in the GARCH polynomial with a coefficient that is positive or `NaN`. Lags that are less than `P` can have coefficients equal to 0.

`P` specifies the minimum number of presample conditional variances required to initialize the model.

If you use name-value pair arguments to create the model, then MATLAB implements one of these alternatives (assuming the coefficient of the largest lag is positive or `NaN`):

• If you specify `GARCHLags`, then `P` is the largest specified lag.

• If you specify `GARCH`, then `P` is the number of elements of the specified value. If you also specify `GARCHLags`, then `garch` uses `GARCHLags` to determine `P` instead.

• Otherwise, `P` is `0`.

Data Types: `double`

ARCH polynomial degree, specified as a nonnegative integer. `Q` is the maximum lag in the ARCH polynomial with a coefficient that is positive or `NaN`. Lags that are less than `Q` can have coefficients equal to 0.

`Q` specifies the minimum number of presample innovations required to initiate the model.

If you use name-value pair arguments to create the model, then MATLAB implements one of these alternatives (assuming the coefficient of the largest lag is positive or `NaN`):

• If you specify `ARCHLags`, then `Q` is the largest specified lag.

• If you specify `ARCH`, then `Q` is the number of elements of the specified value. If you also specify `ARCHLags`, then `garch` uses its value to determine `Q` instead.

• Otherwise, `Q` is `0`.

Data Types: `double`

Conditional variance model constant, specified as a positive scalar or `NaN` value.

Data Types: `double`

GARCH polynomial coefficients, specified as a cell vector of positive scalars or `NaN` values.

• If you specify `GARCHLags`, then the following conditions apply.

• The lengths of `GARCH` and `GARCHLags` are equal.

• `GARCH{j}` is the coefficient of lag `GARCHLags(j)`.

• By default, `GARCH` is a `numel(GARCHLags)`-by-1 cell vector of `NaN` values.

• Otherwise, the following conditions apply.

• The length of `GARCH` is `P`.

• `GARCH{j}` is the coefficient of lag `j`.

• By default, `GARCH` is a `P`-by-1 cell vector of `NaN` values.

The coefficients in `GARCH` correspond to coefficients in an underlying `LagOp` lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to `1e–12` or below, `garch` excludes that coefficient and its corresponding lag in `GARCHLags` from the model.

Data Types: `cell`

ARCH polynomial coefficients, specified as a cell vector of positive scalars or `NaN` values.

• If you specify `ARCHLags`, then the following conditions apply.

• The lengths of `ARCH` and `ARCHLags` are equal.

• `ARCH{j}` is the coefficient of lag `ARCHLags(j)`.

• By default, `ARCH` is a `numel(ARCHLags)`-by-1 cell vector of `NaN` values.

• Otherwise, the following conditions apply.

• The length of `ARCH` is `Q`.

• `ARCH{j}` is the coefficient of lag `j`.

• By default, `ARCH` is a `Q`-by-1 cell vector of `NaN` values.

The coefficients in `ARCH` correspond to coefficients in an underlying `LagOp` lag operator polynomial, and are subject to a near-zero tolerance exclusion test. If you set a coefficient to `1e–12` or below, `garch` excludes that coefficient and its corresponding lag in `ARCHLags` from the model.

Data Types: `cell`

The model unconditional variance, specified as a positive scalar.

The unconditional variance is

`${\sigma }_{\epsilon }^{2}=\frac{\kappa }{\left(1-{\sum }_{i=1}^{P}{\gamma }_{i}-{\sum }_{j=1}^{Q}{\alpha }_{j}\right)}.$`

κ is the conditional variance model constant (`Constant`).

Data Types: `double`

Innovation mean model offset, or additive constant, specified as a numeric scalar or `NaN` value.

Data Types: `double`

Conditional probability distribution of the innovation process, specified as a string or structure array. `garch` stores the value as a structure array.

DistributionStringStructure Array
Gaussian`"Gaussian"``struct('Name',"Gaussian")`
Student’s t`"t"``struct('Name',"t",'DoF',DoF)`

The `'DoF'` field specifies the t distribution degrees of freedom parameter.

• `DoF` > 2 or `DoF` = `NaN`.

• `DoF` is estimable.

• If you specify `"t"`, `DoF` is `NaN` by default. You can change its value by using dot notation after you create the model. For example, `Mdl.Distribution.DoF = 3`.

• If you supply a structure array to specify the Student's t distribution, then you must specify both the `'Name'` and `'DoF'` fields.

Example: `struct('Name',"t",'DoF',10)`

Model description, specified as a string scalar or character vector. `garch` stores the value as a string scalar. The default value describes the parametric form of the model, for example `"GARCH(1,1) Conditional Variance Model (Gaussian Distribution)"`.

Example: `'Description','Model 1'`

Data Types: `string` | `char`

### Note

All `NaN`-valued model parameters, which include coefficients and the t-innovation-distribution degrees of freedom (if present), are estimable. When you pass the resulting `garch` object and data to `estimate`, MATLAB estimates all `NaN`-valued parameters. During estimation, `estimate` treats known parameters as equality constraints, that is,`estimate` holds any known parameters fixed at their 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 `simulate` Monte Carlo simulation of conditional variance models `summarize` Display estimation results of conditional variance model

## Examples

collapse all

Create a default `garch` model object and specify its parameter values using dot notation.

Create a GARCH(0,0) model.

`Mdl = garch`
```Mdl = garch with properties: Description: "GARCH(0,0) Conditional Variance Model (Gaussian Distribution)" Distribution: Name = "Gaussian" P: 0 Q: 0 Constant: NaN GARCH: {} ARCH: {} Offset: 0 ```

`Mdl` is a `garch` model. It contains an unknown constant, its offset is `0`, and the innovation distribution is `'Gaussian'`. The model does not have a GARCH or ARCH polynomial.

Specify two unknown ARCH coefficients for lags one and two using dot notation.

`Mdl.ARCH = {NaN NaN}`
```Mdl = garch with properties: Description: "GARCH(0,2) Conditional Variance Model (Gaussian Distribution)" Distribution: Name = "Gaussian" P: 0 Q: 2 Constant: NaN GARCH: {} ARCH: {NaN NaN} at lags [1 2] Offset: 0 ```

The `Q` and `ARCH` properties are updated to `2` and `{NaN NaN}`. The two ARCH coefficients are associated with lags 1 and 2.

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 with properties: Description: "GARCH(3,2) Conditional Variance Model (Gaussian Distribution)" 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] Offset: 0 ```

`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.

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 with properties: Description: "GARCH(1,1) Conditional Variance Model with Offset (Gaussian Distribution)" Distribution: Name = "Gaussian" P: 1 Q: 1 Constant: NaN GARCH: {NaN} at lag  ARCH: {NaN} at lag  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`.

Create a GARCH(1,1) model with mean offset,

`${y}_{t}=0.5+{\epsilon }_{t},$`

where ${\epsilon }_{t}={\sigma }_{t}{z}_{t},$

`${\sigma }_{t}^{2}=0.0001+0.75{\sigma }_{t-1}^{2}+0.1{\epsilon }_{t-1}^{2},$`

and ${z}_{t}$ is an independent and identically distributed standard Gaussian process.

```Mdl = garch('Constant',0.0001,'GARCH',0.75,... 'ARCH',0.1,'Offset',0.5)```
```Mdl = garch with properties: Description: "GARCH(1,1) Conditional Variance Model with Offset (Gaussian Distribution)" Distribution: Name = "Gaussian" P: 1 Q: 1 Constant: 0.0001 GARCH: {0.75} at lag  ARCH: {0.1} at lag  Offset: 0.5 ```

`garch` assigns default values to any properties you do not specify with name-value pair arguments.

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

Create a `garch` model object.

`Mdl = garch(3,2)`
```Mdl = garch with properties: Description: "GARCH(3,2) Conditional Variance Model (Gaussian Distribution)" 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] Offset: 0 ```

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 with properties: Description: "GARCH(3,2) Conditional Variance Model (Gaussian Distribution)" Distribution: Name = "Gaussian" P: 3 Q: 2 Constant: NaN GARCH: {NaN NaN} at lags [1 3] ARCH: {NaN NaN} at lags [1 2] Offset: 0 ```

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

Display the distribution of the disturbances.

`Mdl.Distribution`
```ans = struct with fields: 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 with properties: Description: "GARCH(3,2) Conditional Variance Model (t Distribution)" 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] Offset: 0 ```

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 with properties: Description: "GARCH(3,2) Conditional Variance Model (t Distribution)" 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] Offset: 0 ```

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.

Fit a GARCH model to an annual time series of Danish nominal stock returns from 1922-1999.

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 with Offset (Gaussian Distribution): Value StandardError TStatistic PValue _________ _____________ __________ _________ Constant 0.0044476 0.007814 0.56918 0.56923 GARCH{1} 0.84932 0.26495 3.2056 0.0013477 ARCH{1} 0.07325 0.14953 0.48986 0.62423 Offset 0.11227 0.039214 2.8629 0.0041974 ```

`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`.

To forecast innovations, pass `EstMdl` to `forecast`.

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.

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 with Offset (Gaussian Distribution): Value StandardError TStatistic PValue _________ _____________ __________ _________ Constant 0.0044476 0.007814 0.56918 0.56923 GARCH{1} 0.84932 0.26495 3.2056 0.0013477 ARCH{1} 0.07325 0.14953 0.48986 0.62423 Offset 0.11227 0.039214 2.8629 0.0041974 ```

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 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 with Offset (Gaussian Distribution): Value StandardError TStatistic PValue _________ _____________ __________ _________ Constant 0.0044476 0.007814 0.56918 0.56923 GARCH{1} 0.84932 0.26495 3.2056 0.0013477 ARCH{1} 0.07325 0.14953 0.48986 0.62423 Offset 0.11227 0.039214 2.8629 0.0041974 ```

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,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');``` expand all

## Tips

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

 Tsay, R. S. Analysis of Financial Time Series. 3rd ed. Hoboken, NJ: John Wiley & Sons, Inc., 2010.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7204538,"math_prob":0.97870314,"size":2715,"snap":"2020-24-2020-29","text_gpt3_token_len":581,"char_repetition_ratio":0.17336775,"word_repetition_ratio":0.019950125,"special_character_ratio":0.18968692,"punctuation_ratio":0.12579957,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.993682,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,2,null,2,null,2,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-06-04T15:53:42Z\",\"WARC-Record-ID\":\"<urn:uuid:3c50fd8d-ea3d-4209-a4d4-0a30e354d495>\",\"Content-Length\":\"166635\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:43cb148f-f53a-4ccf-a833-f4cdd45f03c3>\",\"WARC-Concurrent-To\":\"<urn:uuid:232c373d-5d71-4d2e-be82-602a8babf576>\",\"WARC-IP-Address\":\"104.110.193.39\",\"WARC-Target-URI\":\"https://kr.mathworks.com/help/econ/garch.html\",\"WARC-Payload-Digest\":\"sha1:7EAGDA5CMBXOJMZMB7SQNEY7NMXPCOJV\",\"WARC-Block-Digest\":\"sha1:MCUSLUHNYWC6LTTF6SVXWU4TN766ZYWO\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347441088.63_warc_CC-MAIN-20200604125947-20200604155947-00001.warc.gz\"}"}