84 views (last 30 days)

Show older comments

Hello!

I have the script that estimates GARCH(1,1) model, but for some reason I obtain parameter estimates that are a little different from the parameters estimated for the same model at http://www.mathworks.com/help/econ/cvm.estimate.html

Although the difference is rather small, it is not negligible. Can someone explain why the estimates from my code are different. The following is the code that estimates GARCH(1,1). First, generate data

% variance(t) = omega + alpha*y(t-1)^2 + beta*variance(t-1)

rng default; % Fix the random number generator (for reproducibility)

numData = 500; % Length of time series

errors = randn(numData,1); % Normally distributed numbers

% GARCH coefficients

omega = 0.0001;

alpha = 0.2;

beta = 0.5;

% Create an array for conditional variance

sigma = zeros(numData,1);

sigma(1) = sqrt(2.6709e-04); % Initial volatility (sqrt(variance)) value

% Evaluate conditional volatility

for i=2:numData

sigma(i) = sqrt( omega + alpha*(errors(i-1)*sigma(i-1))^2 + beta*sigma(i-1).^2 );

end

% Data that follows GARCH(1,1) process

initData = errors.*sigma;

Second, the function that evaluates the loglikelihood

function y = garchFunction(x)

Data; % Generate GARCH data

omega = x(1);

alpha = x(2);

beta = x(3);

numData = size(initData(:,1),1);

sigma = zeros(numData,1);

uSq = initData.^2;

sigma(2) = sqrt( uSq(2) );

likelihood = 0;

for i=3:numData

sigma(i) = sqrt( omega + alpha*uSq(i-1) + beta*sigma(i-1)^2 );

likelihood = likelihood + (-log(sigma(i)^2) - uSq(i)/sigma(i)^2);

end

y = -likelihood;

And the following command gives the estimates

[x,fval]=fmincon(@garchFunction,[0.1,0.2,0.5],[0 1 1],1)

However, why these estimates are not the same as at http://www.mathworks.com/help/econ/cvm.estimate.html

Thank you!

Arnab Sen
on 26 Apr 2016

Hello Alex,

I am not able to see the same example in the link you provided. However there is a possible explanation for this minor difference between the outputs of the same operation. Note that the in the code you provided there are floating point variables (For example, sigma). When there are floating point operation the machine approximate that and accuracy of approximation depends on particular machine architecture. Hence we can see small different in result from different machine.

For more detail regarding floating point relative accuracy, refer to the following link:

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!