Is there anyone help me?
Maximum likeligood estimatin of GARCH(1,1) model
3 views (last 30 days)
Show older comments
Hello,
I have a problem in estimating GARCH(1,1) with maximum likelihood method. I hope anyone can help and give me an advice what's wrong with the following code.
%---------------------------------------- % main code with function: garch11.like param = [0.001; 0.001; 0.2; 0.6]; distr = 'normal'; T=1000; data = garch11_sim(param, distr, T);
X = ones(T,1); dataX = [data, X];
k=1; % parameter number in mean equation p=1; q=1;
lowerBounds = []; % Linear inequalities captured, c+p+q
upperBounds = []; % as lower bounds constraints.
SumConA = [-eye(k+1+p+q); ... zeros(1,k+1) ones(1,p) ones(1,q)];
SumConB = [inf;zeros(1+p+q,1); 1];
options = optimset('fmincon');
options = optimset(options , 'TolFun' , 1e-006);
options = optimset(options , 'Display' , 'iter');
options = optimset(options , 'Diagnostics' , 'on');
options = optimset(options , 'LargeScale' , 'off');
options = optimset(options , 'MaxFunEvals' , 400*(2+p+q));
SumConB = SumConB - [zeros(k+1+p+q,1); 1]*2*optimget(options, 'TolCon', 1e-6);
starting = [0.001; 0.0013; 0.2; 0.5];
[parameters, LLF, EXITFLAG, OUTPUT, LAMBDA, GRAD] = fmincon('garch11_like',starting,SumConA,SumConB,[],[],lowerBounds,upperBounds,[],options, dataX, distr);
%----------------------------------------------------
function loglike = garch11_like(param, data, distr)
T = size(data,1); et = data(:,1) - data(:,2:end)*param(1);
ht=zeros(T,1);
ht(1) = param(2)/(1-param(3)-param(4));
for t=2:T; ht(t) = param(2) + param(3)*(et(t-1)^2)+ param(4)*ht(t-1); end
switch distr
case 'normal'
loglike0 = -0.5*log(2*pi) - 0.5*(log(ht)) - 0.5*((et.^2)./ht);
loglike = sum(loglike0);
case 'tdis'
v=param(5);
loglike0 = log(gamma(0.5*(v+1))) - log(gamma(v/2)) - 0.5*log(v*pi*ht) - (v+1)/2*log(1+(et.^2)./(v*ht));
loglike = sum(loglike0);
end
loglike = -loglike;
Answers (0)
See Also
Categories
Find more on Conditional Variance Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!