全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 winbugs及其他软件专版
1208 0
2020-09-07
这是RATS有关于GARCH JUMP的代码
garch(p=1,q=1,reg,resids=u,hseries=h) end1950+1 end1969 r
# constant r{1 2}
compute ssvar=%beta(%nregmean+1)/(1-%beta(%nregmean+2)-%beta(%nregmean+3))
set u * %regstart()-1 = 0.0
set h * %regstart()-1 = ssvar
compute mu=%beta(1),a1=%beta(2),a2=%beta(3)
compute omega=%beta(%nregmean+1),alpha=%beta(%nregmean+2),beta=%beta(%nregmean+3)

compute theta=0.0,delta=sqrt(10.0*ssvar),lambda=.1
nonlin(parmset=pegomega) omega=0.0
maximize(parmset=meanparms+garchparms+jumpparms+poissonparms+pegomega,$
pmethod=simplex,piters=2,method=bfgs,$
title="Constant Intensity Jump GARCH, 1951-1969") logl end1950+1 end1969
set ustdsq = (u-lambda*theta)^2/(h+lambda*(theta^2+delta^2))
@westchotest(title="Q Test on Standardized Squared Residuals",number=15) ustdsq %regstart() %regend()
@westchotest(title="Q Test on Jump Intensity Residuals",number=15) xi %regstart() %regend()

*

另一个
compute kmax=20
*****************************************************************************************
*
* jumpGARCH(u,h,lambda,deltasq,theta) returns the log likelihood for an
* observation for a jump-GARCH model given:
*
*  u       = current residual
*  h       = base GARCH variance (before jumps)
*  lambda  = Poisson intensity for jumps
*  deltasq = variance of Normal jump process
*  theta   = mean of Normal jump process
*
function jumpgarch u h lambda deltasq theta
type real jumpgarch u h lambda deltasq theta
*
local   integer k
local   real    jsd wt jp
*
compute wt=0.0
compute jumpgarch=0.0
do k=0,kmax
   compute jsd=sqrt(h+k*deltasq)
   compute jp =exp(k*log(lambda)-%lngamma(k+1))
   compute wt =wt+jp
   compute jumpgarch=jumpgarch+jp*%density((u-k*theta)/jsd)/jsd
end do k
compute jumpgarch=log(jumpgarch/wt)

end jumpgarch
*****************************************************************************************
*
* ARJIgarch(u,h,lambda,deltasq,theta,xi) returns the log likelihood for
* an observation for a jump-GARCH model given:
*
*  u       = current residual
*  h       = base GARCH variance (before jumps)
*  lambda  = Poisson intensity for jumps
*  deltasq = variance of Normal jump process
*  theta   = mean of Normal jump process
*
* It also returns in xi the innovation in the number of jumps
* (difference between the expected value given the data and the mean),
* which can be used for computing the ARJI intensity.
*
function ARJIgarch u h lambda deltasq theta xi
type real ARJIgarch u h lambda deltasq theta *xi
*
local integer k
local real jsd wt ewt jp fr xit
*
compute wt =0.0
compute ewt=0.0
compute xit=0.0
compute ARJIgarch=0.0
do k=0,kmax
   compute jsd=sqrt(h+k*deltasq)
   compute jp =exp(k*log(lambda)-%lngamma(k+1))
   compute fr =%density((u-k*theta)/jsd)/jsd
   compute wt =wt+jp
   compute ewt=ewt+jp*fr
   compute xit=xit+k*jp*fr
   compute ARJIgarch=ARJIgarch+jp*fr

end do k
compute xi=xit/ewt-lambda
compute ARJIgarch=log(ARJIgarch/wt)
end ARJIgarch

二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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