全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 EViews专版
2406 1
2009-01-05
<p>我是根据网络上有做multivariate garch model 参数估计再加以修改成为GJR-GARCH,leverage effect 参数设为theta,但theta都无法估计,希望有高手能帮我找出code的问题出在哪,先谢谢了!我的code如下:<br/>series y1 = stockreturn<br/>series y2 = futurereturn<br/>'get starting values from univariate GARCH <br/>equation eq1.arch(m=100,c=1e-5) y1 c<br/>equation eq2.arch(m=100,c=1e-5) y2 c<br/><br/>coef(2) mu<br/>mu(1) = eq1.c(1)<br/>mu(2)= eq2.c(1)<br/><br/>coef(3) omega<br/>omega(1)=(eq1.c(2))^.5<br/>omega(2)=0<br/>omega(3)=eq2.c(2)^.5<br/><br/>coef(2) alpha<br/>alpha(1) = (eq1.c(3))^.5<br/>alpha(2) = (eq2.c(3))^.5 <br/><br/>coef(2) beta <br/>beta(1)= (eq1.c(4))^.5 <br/>beta(2)= (eq2.c(4))^.5</p><p> </p><p>coef(2) theta <br/>theta(1)= (eq1.c(5))^.5 <br/>theta(2)= (eq2.c(5))^.5<br/> <br/>!mlog2pi = 2*log(2*@acos(-1))<br/> <br/>series cov_y1y2 = @cov(y1-mu(1), y2-mu(2))<br/>series var_y1 = @var(y1)<br/>series var_y2 = @var(y2)<br/><br/>series sqres1 = (y1-mu(1))^2<br/>series sqres2 = (y2-mu(2))^2<br/>series res1res2 = (y1-mu(1))*(y2-mu(2))<br/> <br/>' set up the likelihood <br/>' 1) open a new blank likelihood object (L.O.) name bvgarch<br/>' 2) specify the log likelihood model by append<br/><br/>logl bvgarch<br/>bvgarch.append @logl logl<br/>bvgarch.append sqres1 = (y1-mu(1))^2<br/>bvgarch.append sqres2 = (y2-mu(2))^2<br/>bvgarch.append res1res2 = (y1-mu(1))*(y2-mu(2))<br/><br/>' calculate the variance and covariance series</p><p>if y1-mu(1)<0 then<br/>bvgarch.append var_y1  =  omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1) + theta(1)^2*sqres1(-1)<br/>else</p><p>bvgarch.append var_y1  =  omega(1)^2 + beta(1)^2*var_y1(-1) + alpha(1)^2*sqres1(-1)</p><p>endif</p><p>if y2-mu(2)<0 then</p><p>bvgarch.append var_y2  = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1) + theta(2)^2*sqres2(-1)<br/>else</p><p>bvgarch.append var_y2  = omega(3)^2+omega(2)^2 + beta(2)^2*var_y2(-1) + alpha(2)^2*sqres2(-1)</p><p>endif</p><p>if y1-mu(1)<0 or y2-mu(2)<0 then<br/>bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)+ theta(2)*theta(1)*res1res2(-1)<br/>else</p><p>bvgarch.append cov_y1y2 = omega(1)*omega(2) + beta(2)*beta(1)*cov_y1y2(-1) + alpha(2)*alpha(1)*res1res2(-1)</p><p>endif</p><p><br/>' determinant of the variance-covariance matrix<br/>bvgarch.append deth = var_y1*var_y2 - cov_y1y2^2<br/><br/>' inverse elements of the variance-covariance matrix<br/>bvgarch.append invh1 = var_y2/deth<br/>bvgarch.append invh3 = var_y1/deth<br/>bvgarch.append invh2 = -cov_y1y2/deth<br/><br/>' log-likelihood series<br/>bvgarch.append logl =-0.5*(!mlog2pi + (invh1*sqres1+2*invh2*res1res2+invh3*sqres2) + log(deth))<br/><br/>' remove some of the intermediary series<br/>' bvgarch.append @temp invh1 invh2 invh3 sqres1 sqres2 res1res2 deth<br/><br/>' estimate the model <br/>bvgarch.ml(showopts, m=100, c=1e-5)<br/><br/>' change below to display different output<br/>show bvgarch.output<br/>graph varcov.line var_y1 var_y2 cov_y1y2<br/>show varcov<br/><br/>' LR statistic for univariate versus bivariate model<br/>scalar lr = -2*( eq1.@logl + eq2.@logl - bvgarch.@logl )<br/>scalar lr_pval = 1 - @cchisq(lr,1)</p>

[此贴子已经被作者于2009-1-5 15:29:16编辑过]

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2012-12-18 10:19:24
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群