MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by George
on 1 Jan 2013

Hi everyone and happy new year

I am struggling to understand how to estimate the parameters of a AR-Garch model

I found on the documentation two ways which yields different results and i can't understand the difference

Below is my code:

%% Begin

clear all

clc

%% Load Variables

load data

load dates

%% Construct Variables

spotRates = data;

spotRets = [NaN(1, size(data,2)); price2ret(spotRates,[],'Periodic')];

%% First Way

model = arima('ARLags',[1 2 5 7], 'Variance',garch(1,1));

[fit,VarCov,LogL,info] = estimate(model,spotRets(2:end,1));

%% Second Way

arCoefs = cell2mat(fit.AR);

Spec = garchset('AR',arCoefs,'P',1,'Q',1);

% Here i used the coeffs from the arima estimate. I dont know how to set Lags 3 4 6

% equal to zero and the garchfit changes the AR coefficients that i gave

% Also i tried Spec = garchset('AR',arCoefs,'FixAR', [0 0 1 0 0 1 0], 'P',1,'Q',1);

% with the same results

[Coeff,Errors,LLF,Innovations,Sigmas,Summary] = garchfit(Spec,spotRets(2:end,1));

%% End

Also i can't understand the difference between the following

1) model = garch(1,1);

[fit,VarCov,LogL,info] = estimate(model, data)

and

2) spec = garchset('P',1,'Q',1);

[Coeff,Errors,LLF,Innovations,Sigmas,Summary] = garchfit(spec,data);

Also slightly different results Thank you very much for your time

## 3 Comments

## George (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/57750#comment_120102

The estimated coefficients from the two ways are:

1)disp(cell2mat(fit.AR)')

2)disp(Coeff.AR')

## George (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/57750#comment_120115

Ok i found what is wrong

I forget to set the constant in the second way

If i give the following:

Spec = garchset('AR',cell2mat(fit.AR),'FixAR', [0 0 1 1 0 1 0], 'Constant', fit.C, 'P',1,'Q',1);

[Coeff,Errors,LLF,Innovations,Sigmas,Summary] = garchfit(Spec,spotRets(2:end,1));

the results are almost the same.

I have another question:

Does it matters whether the parameter 'AR' in the 'garchset' has the estimated coefficients?

I write

Spec = garchset('AR',[0.1 0.1 0 0 0.1 0 0.1], 'FixAR', [0 0 1 1 0 1 0], 'Constant', 0.1, 'P',1,'Q',1);

[Coeff,Errors,LLF,Innovations,Sigmas,Summary] = garchfit(Spec,spotRets(2:end,1));

and the results are the same

## George (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/57750#comment_120118

I think that garchset/garchfit/garchsim/garchpred

and

garch/estimate/infer/simulate/forecast

produce the same results

I can't find the difference

Any help would be appreciated