文档库 最新最全的文档下载
当前位置:文档库 › ARJI

ARJI

*
* Replication file for Chan and Maheu(2002), "Conditional Jump Dynamics
* in Stock Market Returns", JBES, vol 20, no. 3, 377-389.
*
* ARJI model (table 3)
*
source jumpgarch.src
*
open data djia.txt
data(format=free,org=columns) 1 18940 year month day logret logrange close low high
set r = 100.0*logret
*
* Since the data are daily with holiday skips, the following locates the
* final entry number in 1984 for the sample breaks. Since the results
* from SSTATS are real-valued, we need to FIX them to get an entry
* number.
*
sstats(max) / %if(year(t)<=1984,t,0)>>x1984
sstats(min) / %if(year(t)>=1930,t,1000000)>>x1930
compute end1984=fix(x1984),start1930=fix(x1930)
*
set u = 0.0
set h = 0.0
*
* We need these series to form the recursive estimates of the jump intensity
*
set lambda_t = 0.0
set xi_t = 0.0
*
* These save the (possibly) time-varying mean and variance of the jump process.
*
set theta_t = 0.0
set deltasq_t = 0.0
*
* Define formula for the mean model and set up its parameter set
*
nonlin(parmset=meanparms) mu a1 a2
frml uf = r-mu-a1*r{1}-a2*r{2}
*
* Define formula for the base GARCH variance and set up its parameter set
*
nonlin(parmset=garchparms) omega alpha beta
frml hf = omega+alpha*u{1}^2+beta*h{1}
*
* Define the ARJI formula for the intensity.
*
declare real lambda0 rho gamma
frml lambdaf = lambda0+rho*lambda_t{1}+gamma*xi_t{1}
****************************************************************************
*
* The parmsets and logl definitions need to change from model to model
*
****************************************************************************
*
* Constant intensity jump model through 1984 (column 1 in table 3)
*
garch(p=1,q=1,reg,resids=u,hseries=h) 4 end1984 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)
nonlin(parmset=poissonparms) lambda0
nonlin(parmset=jumpparms) zeta0 eta0
compute eta0=0.0,zeta0=sqrt(10.0*ssvar),lambda0=.1
frml logl = u=uf,h=hf,lambda_t=lambda0,deltasq_t=zeta0^2,theta_t=eta0,$
arjigarch(u,h,lambda_t,deltasq_t,theta_t,xi_t)
maximize(parmset=meanparms+garchparms+jumpparms+poissonparms,$
pmethod=simplex,piters=2,method=bfgs,$
title="Constant Intensity Jump GARCH, Full Sample") logl 4 end1984
*
* Diagnostics on squared standardized residuals (taking into account the
* mean and variance of the Poisson process) and on the jump intensity
* residuals.
*
set ustdsq = (u-lambda_t*theta_t)^2/(h+lambda_t*(theta_t^2+deltasq_t))
@westchotest(title="Q Test on Standardized Squared Residuals",number=15) ustdsq %regstart() %regend()
@westchotest(title="Q Test on Jump Intensity Residuals",number=15) xi_t %regstart() %regend()
*
* Save this for later use
*
compute lambdafixed=lambda0
************

****************************************************************
*
* Simple ARJI model (column 2 in table 3). We'll just take the converged
* estimates from the constant model as our initial guesses.
*
nonlin(parmset=poissonparms) lambda0 rho gamma
compute lambda0=.05,rho=.5,gamma=.05
frml logl = u=uf,h=hf,lambda_t=lambdaf,deltasq_t=zeta0^2,theta_t=eta0,$
ARJIgarch(u,h,lambda_t,deltasq_t,theta_t,xi_t)
maximize(parmset=meanparms+garchparms+jumpparms+poissonparms,$
pmethod=simplex,piters=2,method=bfgs,title="ARJI-GARCH") logl 4 end1984
set ustdsq = (u-lambda_t*theta_t)^2/(h+lambda_t*(theta_t^2+deltasq_t))
@westchotest(title="Q Test on Standardized Squared Residuals",number=15) ustdsq %regstart() %regend()
@westchotest(title="Q Test on Jump Intensity Residuals",number=15) xi_t %regstart() %regend()
*
* Generate Figure 1
*
* For doing graphs with year labels. This divides each year into equally
* spaced values in the range [year,year+1). (This uses features added
* with RATS 8.1. To do the graphs without the year labeling, replace
* SCATTER with GRAPH and take CODEDDATE off the supplementary cards in
* all three SCATTER instructions in this group).
*
panel(group=year,id=yearid,identries=yearentries)
set codeddate = lookup=1+fix(year-yearid(1)),$
year+(t-yearentries(lookup)(1))/float(%size(yearentries(lookup)))
spgraph(vfields=3,footer="Figure 1")
scatter(header="(a) In Sample R",style=lines)
# codeddate r 4 end1984
scatter(header="(b) Lambda",style=lines)
# codeddate lambda_t 4 end1984
set onestep = sqrt(h+lambda_t*(theta_t^2+deltasq_t))
scatter(header="(c) One-step-ahead standard deviation",style=lines)
# codeddate onestep 4 end1984
spgraph(done)
*
* Generate Figure 2
* Figure out the entries for the particular y:m:d combinations
*
sstats(max) / $
%if(year(t)==1940.and.month(t)==5.and.day(t)==18,t,0)>>x19400518 $
%if(year(t)==1929.and.month(t)==11.and.day(t)==6,t,0)>>x19291106
*
* Pull out the lambda's for those entries, and compute the Poisson
* probabilities for the fixed model and the ARJI model entries.
*
compute lambda1940=lambda_t(fix(x19400518))
compute lambda1929=lambda_t(fix(x19291106))
set probfixed 1 11 = %poissonk(lambdafixed,t-1)
set prob1940 1 11 = %poissonk(lambda1940,t-1)
set prob1929 1 11 = %poissonk(lambda1929,t-1)
graph(footer="Figure 2. Probabilities of Number of Jumps",number=0,style=bar,key=below,$
klabels=||"Constant","May 18, 1940","Nov 6, 1929"||) 3
# probfixed
# prob1940
# prob1929
*
* Generate Figure 3
*
sstats(max) / $
%if(year(t)==1929.and.month(t)==10.and.day(t)==15,t,0)>>x19291015 $
%if(year(t)==1929.and.month(t)==10.and.day(t)==28,t,0)>>x19291028
spgraph(vfields=2,footer="Figure 3 ARJI, In-Sample R and Lambda")
scatter(style=line,header="(a) R")
# day r fix(x19291015) fix(x19291028)
scatter(style=line,header="(b) Lambda")
# day lambda_t fix(x19291015) fix(x19291028)
spgraph(done)
***************************************************

*************************
*
* ARJI-R{1}^2 (column 3 in table 3)
*
nonlin(parmset=jumpparms) zeta0 zeta1 eta0 eta1 eta2
compute eta1=eta2=0.0
sstats(mean) * end1984 r^2>>meanrsq
compute zeta0=.7*zeta0,zeta1=zeta0^2/meanrsq
frml logl = u=uf,h=hf,lambda_t=lambdaf,deltasq_t=zeta0^2+zeta1*r{1}^2,$
theta_t=eta0+eta1*%max(r{1},0.0)+eta2*%min(r{1},0.0),$
ARJIgarch(u,h,lambda_t,deltasq_t,theta_t,xi_t)
maximize(parmset=meanparms+garchparms+jumpparms+poissonparms,$
pmethod=simplex,piters=2,method=bfgs,title="ARJI-R{1}^2 GARCH") logl 4 end1984
set ustdsq = (u-lambda_t*theta_t)^2/(h+lambda_t*(theta_t^2+deltasq_t))
@westchotest(title="Q Test on Standardized Squared Residuals",number=15) ustdsq %regstart() %regend()
@westchotest(title="Q Test on Jump Intensity Residuals",number=15) xi_t %regstart() %regend()
****************************************************************************
*
* ARJI-h(t) (column 4 in table 3)
*
nonlin(parmset=jumpparms) zeta0 zeta1 eta0 eta1 eta2
frml logl = u=uf,h=hf,lambda_t=lambdaf,deltasq_t=zeta0^2+zeta1*h,$
theta_t=eta0+eta1*%max(r{1},0.0)+eta2*%min(r{1},0.0),$
ARJIgarch(u,h,lambda_t,deltasq_t,theta_t,xi_t)
maximize(parmset=meanparms+garchparms+jumpparms+poissonparms,$
pmethod=simplex,piters=2,method=bfgs,title="ARJI-h GARCH") logl 4 end1984
set ustdsq = (u-lambda_t*theta_t)^2/(h+lambda_t*(theta_t^2+deltasq_t))
@westchotest(title="Q Test on Standardized Squared Residuals",number=15) ustdsq %regstart() %regend()
@westchotest(title="Q Test on Jump Intensity Residuals",number=15) xi_t %regstart() %regend()


相关文档