Documentation Center

  • Trial Software
  • Product Updates

Convert from GARCH Functions to Models

GARCH Function Conversion

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 FunctionalityExamples
1. Specify a compound ARIMA-GARCH model.
Mdl = garchset('R',3,'M',4,'P',1,'Q',2);
VarMdl = garch(1,2);
Mdl = arima(3,0,4);
Mdl.Variance = VarMdl;
2. Retrieve model properties.
garchget(Mdl,'K')
Mdl.Variance.Constant
3. Set equality constraints.
Mdl = garchset(Mdl,'K',0.75,'FixK',1);
Mdl.Variance.Constant = 0.75;
4. Estimate parameters.
EstMdl = garchfit(Mdl,y,[],e0,sigma0,y0);
[EstMdl,EstParamCov] = estimate(Mdl,y,'E0',e0,'V0',sigma0.^2,'Y0',y0)
Estimate Conditional Mean and Variance Models
5. Count the number of fitted parameters.
numParams = garchcount(EstMdl);
numParams = sum(any(EstParamCov));
 
6. 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);
7. Simulate observations.
simY = garchsim(EstMdl,100);
simY = simulate(EstMdl,100);
Simulate GARCH Models
8. Filter disturbances.
e = randn(100,1);
simY = garchsim(EstMdl,[],[],e);
e = randn(100,1);
simY = filter(EstMdl,e);
9. Forecast observations.
foreY = garchpred(EstMdl,y,15);
foreY = forecast(EstMdl,15,'Y0',y);
Forecast a Conditional Variance Model

GARCH Functionality Conversion

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 object data type, and Mdl2 is a struct data type.

    • 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 a garch, egarch, or gjr model.

  2. Specify template models to use for estimation.

    % New way
    ToEstVarMdl1 = garch(1,1);
    ToEstMdl11 = arima('ARLags',1,'MALags',1,'Variance',ToEstVarMdl1);
    ToEstMdl21 = arima('ARLags',1:2,'MALags',1,'Variance',ToEstVarMdl1);
    
    % Old way
    ToEstMdl12 = garchset('R',1,'M',1,'P',1,'Q',1,'Display','off');
    ToEstMdl22 = 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 ToEstMdl1 and ToEstMdl2 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(ToEstMdl11,...
        y1,'Display','off');
    [EstMdl21,EstParamCov21,logl21] = estimate(ToEstMdl21,...
        y1,'Display','off');
    
    % Old way
    logL2 = [0;0];       % Preallocate
    numParams2 = logL2;  % Preallocate
    [EstMdl12,~,logl12] = garchfit(ToEstMdl12,y2);
    [EstMdl22,~,logl22] = garchfit(ToEstMdl22,y2);

    The estimate method:

    • 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);

See Also

| | | | | | | | | | | | | | | | | | | | | | |

Was this topic helpful?