Estimating GARCH(1,1) model with fmincon

6 ビュー (過去 30 日間)
Alex
Alex 2016 年 4 月 22 日
編集済み: Alex 2016 年 4 月 26 日
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!

回答 (1 件)

Arnab Sen
Arnab Sen 2016 年 4 月 26 日
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:
  1 件のコメント
Alex
Alex 2016 年 4 月 26 日
編集済み: Alex 2016 年 4 月 26 日
Hello Arnab! Thank you for your answer. I doubt that machine precision could make such a big difference. Again, the difference in estimates is small, but it is not negligible. Here is the code from the link
Mdl = garch('Constant',0.0001,'GARCH',0.5,...
'ARCH',0.2);
rng default; % For reproducibility
[v,y] = simulate(Mdl,500);
ToEstMdl = garch(1,1);
EstMdl = estimate(ToEstMdl,y)
The difference in parameter estimates is larger than 0.01. If you run the code it gives the same numbers as reported in the link.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeConditional Variance Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by