# ugarchsim

(To be removed) Simulate univariate GARCH(P,Q) process with Gaussian innovations

As an alternative to `ugarchsim`, use the `garch` object to create conditional variance models. For more information, see Specify GARCH Models Using garch.

`ugarchsim` is removed. Use `garch` object to create conditional variance models and the `simulate` function to generate Monte Carlo simulations from conditional variance models. For more information, see Simulate Conditional Variance Model.

## Syntax

```[U, H] = ugarchsim(Kappa, Alpha, Beta, NumSamples)
```

## Arguments

 `Kappa` Scalar constant term [[KAPPA]] of the GARCH process. `Alpha` `P`-by-`1` vector of coefficients, where `P` is the number of lags of the conditional variance included in the GARCH process. `Alpha` can be an empty matrix, in which case `P` is assumed 0; when `P = 0`, a GARCH(0,Q) process is actually an ARCH(Q) process. `Beta` `Q`-by-`1` vector of coefficients, where `Q` is the number of lags of the squared innovations included in the GARCH process. `NumSamples` Positive, scalar integer indicating the number of samples of the innovations `U` and conditional variance `H` (see below) to simulate.

## Description

`[U, H] = ugarchsim(Kappa, Alpha, Beta, NumSamples)` simulates a univariate GARCH(P,Q) process with Gaussian innovations.

`U` is a number of samples (`NUMSAMPLES`)-by-`1` vector of innovations (ɛt), representing a mean-zero, discrete-time stochastic process. The innovations time series `U` is designed to follow the GARCH(P,Q) process specified by the inputs `Kappa`, `Alpha`, and `Beta`.

`H` is a `NUMSAMPLES`-by-`1` vector of the conditional variances ( ) corresponding to the innovations vector `U`. Note that `U` and `H` are the same length, and form a "matching" pair of vectors. As shown in the following equation, ${\sigma }_{t}^{2}$ (that is, `H(t)`) represents the time series inferred from the innovations time series {ɛt} (that is, `U`).

The time-conditional variance, ${\sigma }_{t}^{2}$, of a GARCH(P,Q) process is modeled as

`${\sigma }_{t}^{2}=K+\sum _{i=1}^{P}{\alpha }_{i}{\sigma }_{t-i}^{2}+\sum _{j=1}^{Q}{\beta }_{j}{\epsilon }_{t-j}^{2},$`

where α represents the argument `Alpha`, β represents `Beta`, and the GARCH(P,Q) coefficients {Κ, α, β} are subject to the following constraints.

`$\begin{array}{l}\sum _{i=1}^{P}{\alpha }_{i}+\sum _{j=1}^{Q}{\beta }_{j}<1\\ K>0\\ \begin{array}{cc}{\alpha }_{i}\ge 0& i=1,2,\dots ,P\\ {\beta }_{j}\ge 0& j=1,2,\dots ,Q.\end{array}\end{array}$`

Note that `U` is a vector of residuals or innovations (ɛt) of an econometric model, representing a mean-zero, discrete-time stochastic process.

Although ${\sigma }_{t}^{2}$ is generated using the equation above, ɛt and ${\sigma }_{t}^{2}$ are related as

`${\epsilon }_{t}={\sigma }_{t}{\upsilon }_{t},$`

where $\left\{{\upsilon }_{t}\right\}$ is an independent, identically distributed (iid) sequence ~ N(0,1).

The output vectors `U` and `H` are designed to be steady-state sequences in which transients have arbitrarily small effect. The (arbitrary) metric used by `ugarchsim` strips the first `N` samples of `U` and `H` such that the sum of the GARCH coefficients, excluding `Kappa`, raised to the `N`th power, does not exceed 0.01.

``` 0.01 = (sum(Alpha) + sum(Beta))^N ```

Thus

``` N = log(0.01)/log((sum(Alpha) + sum(Beta))) ```
 Note   The Econometrics Toolbox™ software provides a comprehensive and integrated computing environment for the analysis of volatility in time series. For information see the Econometrics Toolbox documentation or the financial products Web page at `http://www.mathworks.com/products/finprod/`.

## Examples

This example simulates a GARCH(P,Q) process with ```P = 2``` and `Q = 1`.

```% Set the random number generator seed for reproducability. rng('default') % Set the simulation parameters of GARCH(P,Q) = GARCH(2,1) process. Kappa = 0.25; %a positive scalar. Alpha = [0.2 0.1]'; %a column vector of nonnegative numbers (P = 2). Beta = 0.4; % Q = 1. NumSamples = 500; % number of samples to simulate. % Now simulate the process. [U , H] = ugarchsim(Kappa, Alpha, Beta, NumSamples); % Estimate the process parameters. P = 2; % Model order P (P = length of Alpha). Q = 1; % Model order Q (Q = length of Beta). [k, a, b] = ugarch(U , P , Q); disp(' ') disp(' Estimated Coefficients:') disp(' -----------------------') disp([k; a; b]) disp(' ') % Forecast the conditional variance using the estimated % coefficients. NumPeriods = 10; % Forecast out to 10 periods. [VarianceForecast, H1] = ugarchpred(U, k, a, b, NumPeriods); disp(' Variance Forecasts:') disp(' ------------------') disp(VarianceForecast) disp(' ') ```
```Error using ugarchsim (line 71) UGARCHSIM has been removed. Use the GARCH model SIMULATE function in Econometrics Toolbox instead.```

## References

James D. Hamilton, Time Series Analysis, Princeton University Press, 1994