- Joined
- 10/29/09
- Messages
- 2
- Points
- 11
I tried to write a code to estimate the variables for NGARCH model:
\(\sigma(t+1)^2=\omega+\alpha*(Return(t)-\theta*\sigma(t))^2+\beta*\sigma(t)^2\) where \(\omega=\sigma*(1-\alpha*(1+\theta^2)-\beta)\)
I wrote a function as
then use fmincon to call it. But seems that it doesn't converge. The matlab just keep searching and searching and never stops.
Anyone can give me some advice?
Thank you
\(\sigma(t+1)^2=\omega+\alpha*(Return(t)-\theta*\sigma(t))^2+\beta*\sigma(t)^2\) where \(\omega=\sigma*(1-\alpha*(1+\theta^2)-\beta)\)
I wrote a function as
Code:
function f=osllh(x)
r=xlsread('HW_3_Data','old vix','j4:j1257');
ovix=xlsread('HW_3_Data','old vix','f4:f1257');
sigma=var(r);
omega=sigma*(1-x(1)*(1+x(3)^2)-x(2));
llh=zeros(1254,1);
for n=1:1254
opsigma=ones(1254,1);
opsigma(1,1)=sigma;
for t=1:1253
opsigma(t+1,1)=omega+x(1)*(r(t,1)-x(3)*opsigma(t,1)^0.5)^2+x(2)*opsigma(t,1)+x(4)*ovix(t,1)^2/252;
end
ollh(n,1)=-0.5*log(2*3.1415926)-0.5*log(opsigma(n,1))-0.5*(r(n,1)^2/opsigma(n,1));
end
f=-sum(ollh);
end
Anyone can give me some advice?
Thank you