## Converting from GARCH Functions to Model Objects

In R2014a, `arima`, `garch`, `egarch`, and `gjr` models and associated functionality replace the `garchfit`, `garchinfer`, `garchplot`, `garchpred`, `garchsim`, `garchcount`, `garchdisp`, `garchget`, and `garchset` functions. If you use the older GARCH data analysis functions, then you will receive an error. Use the information on this page to help you convert from the older to the newer functionality.

Suppose that you want to analyze a univariate series `y` using an ARIMA(3,4) model with GARCH(1,2) innovations, and you have presample observations (`y0`), innovations (`e0`), and conditional standard deviations (`sigma0`). This table shows both ways to complete such an analysis.

StepOld FunctionalityNew Functionality
Specify a compound ARIMA-GARCH model
```Mdl = garchset('R',3,'M',4,... 'P',1,'Q',2);```
```Mdl = arima(3,0,4); VarMdl = garch(1,2); Mdl.Variance = VarMdl; ```
Retrieve model properties
`garchget(Mdl,'K')`
`Mdl.Variance.Constant`
Set equality constraints
```Mdl = garchset(Mdl,... 'K',0.75,'FixK',1);```
`Mdl.Variance.Constant = 0.75;`
Estimate parameters
```EstMdl = garchfit(Mdl,y,[],... e0,sigma0,y0);```
```[EstMdl,EstParamCov] = ... estimate(Mdl,y,'E0',e0,... 'V0',sigma0.^2,'Y0',y0) ```
Count the number of fitted parameters
```numParams = garchcount(... EstMdl);```
```numParams = sum(any(... EstParamCov));```
Infer conditional variances (`sigma2`) and obtain the loglikelihood (`logL`)
```[e,sigma,logL] = ... garchinfer(EstMdl,y,... [],e0,sigma0,y0); sigma2 = sigma.^2;```
```[e,sigma2,logL] = infer(... EstMdl,y,'E0',e0,... 'V0',sigma0.^2,'Y0',y0);```
Simulate observations
```simY = garchsim(EstMdl,100); ```
`simY = simulate(EstMdl,100);`
Filter disturbances
```e = randn(100,1); simY = garchsim(EstMdl,[],... [],e); ```
```e = randn(100,1); simY = filter(EstMdl,e);```
Forecast observations
```fY = garchpred(EstMdl,y,... 15);```
```fY = forecast(EstMdl,15,... 'Y0',y);```

Though similar, the input and output structure of the two functionalities differ in some ways. This example shows how to determine some of the differences between the two, and might help you through the conversion. This example does not show how to reproduce equivalent results between the models, because, in general, the estimates between the two functionalities might differ.

Suppose that you want to analyze a univariate series. You suspect that the model is either an ARIMA(2,1)/GARCH(1,1) or ARIMA(1,1)/GARCH(1,1) model, and want to test which model fits to the data better. Variables representing the new functionality have the suffix `1` (e.g., `Mdl1`), and those of the older functionality have suffix `2` (e.g., `Mdl2`).

1. Simulate the data from an ARIMA(2,1) model with GARCH(1,1) innovations.

```% New way VarMdl1 = garch('GARCH',0.3,'ARCH',0.2,'Constant',0.75); Mdl1 = arima('AR',{0.5,0.3},'MA',-0.7,'Constant',0,'Variance',VarMdl1); [y1,e1,v1] = simulate(Mdl1,100); % Old way Mdl2 = garchset('AR',[0.5,0.3],'MA',-0.7,'C',0,... 'GARCH',0.3,'ARCH',0.2,'K',0.75); [e2,sd2,y2] = garchsim(Mdl2,100);```

The differences are:

• `Mdl1` is an `arima` object, and `Mdl2` is a structure array.

• `simulate` returns conditional variances, whereas `garchsim` returns conditional standard deviations.

• With the new functionality, you must:

• Specify multiple coefficient values using a cell array.

• Specify the variance model using `garch`, `egarch`, or `gjr`.

2. Specify template models to use for estimation.

```% New way VarMdl1 = garch(1,1); Mdl11 = arima('ARLags',1,'MALags',1,'Variance',VarMdl1); Mdl12 = arima('ARLags',1:2,'MALags',1,'Variance',VarMdl1); % Old way Mdl21 = garchset('R',1,'M',1,'P',1,'Q',1,'Display','off'); Mdl22 = garchset('R',2,'M',1,'P',1,'Q',1,'Display','off'); ```

The new functionality has the name-value pair arguments `'ARLags'` and `'MALags'` to set the polynomial terms of the model. You must specify each term order individually, which allows for a more flexible specification. The models `Mdl11` and `Mdl12` have properties `P` and `Q` corresponding to the autoregressive and moving average orders of the model.

3. Fit each model to the data.

```% New way logL1 = [0;0]; % Preallocate numParams1 = logL1; % Preallocate [EstMdl11,EstParamCov11,logl11] = estimate(Mdl11,y1,'Display','off'); [EstMdl12,EstParamCov12,logl12] = estimate(Mdl12,y1,'Display','off'); % Old way logL2 = [0;0]; % Preallocate numParams2 = logL2; % Preallocate [EstMdl21,~,logl12] = garchfit(Mdl21,y2); [EstMdl22,~,logl22] = garchfit(Mdl22,y2);```

The `estimate` function:

• Returns the estimated parameter covariance matrix rather than just the standard errors.

• Lets you decide to see estimates and optimization information, rather than setting it when you specify the model.

4. Count the number of fitted parameters in the estimated model.

```% New way numParams11 = sum(any(EstParamCov11)); numParams21 = sum(any(EstParamCov21)); % Old way numParams12 = garchcount(EstMdl12); numParams22 = garchcount(EstMdl22); ```

The new functionality does not contain a function that counts the number of fitted parameters in an estimated model. However, if a parameter is fixed during estimation, then the software sets all variances and covariances of the corresponding parameter estimate to `0`. The new way to count fitted parameters uses this feature.

5. Assess which model is more appropriate using information criteria.

```aic1 = aicbic(logL1,numParams1); aic2 = aicbic(logL2,numParams2);```