I was trying to run the replication file for Diebold and Yilmaz (2012) in RATS 8.2. I left the hash operator out as it is a new feature for the 9.2 version. However,the program runs smoothly until the line that initialize spillstats over the rstart and rend period "gset spillstats rstart rend = null". Have I got anything wrong? Thanks for you help in advance.
Note the code is for three variables not the 4 variable version given originally.
Code: Select all
*
* Replication file for Diebold and Yilmaz(2012), "Better to give than to receive:
* Predictive directional measurement of volatility spillovers," International
* Journal of Forecasting, vol. 28, no 1, 57-66.
*
* Sensitivity analysis
*
open data dy_ijf2012_data.xlsx
data(format=xlsx,org=columns,right=5) 1 2770 sp500 r_10y djubscom
dofor i = sp500 r_10y djubscom
set i = log(i{0})
end do i
*
*
compute usegirf=1
compute nspan=200
*********************************************************************
*
* Produce the appropriate "factor" matrix from %sigma
*
function FactorMatrix
type rect FactorMatrix
if usegirf
compute FactorMatrix=%sigma*inv(%diag(%sqrt(%xdiag(%sigma))))
else
compute FactorMatrix=%decomp(%sigma)
end
********************
compute minlag=1
compute maxlag=6
*
* Estimate the 6 lag model to get the usable range for the sensitivity analysis
*
system(model=assetvar)
variables sp500 r_10y djubscom
lags 1 to maxlag
det constant
end(system)
estimate
compute rstart=%regstart(),rend=%regend()
*
dec list[real] null
dec series[list[real]] spillstats
*
* Initialize to empty list
*
gset spillstats rstart rend = null
dec vect tovar(%nvar)
*
* Sensitivity to lag length, given horizon
*
compute nsteps=10
do nlags=minlag,maxlag
*
system(model=assetvar)
variables sp500 r_10y djubscom
lags 1 to nlags
det constant
end(system)
*
do end=rstart+nspan-1,rend
estimate(noprint) end-nspan+1 end
*
* Skip any data points where the rolling VAR has an explosive root.
*
eigen(cvalues=cv) %modelcompanion(assetvar)
if %cabs(cv(1))>=1.0 {
next
}
compute gfactor=FactorMatrix()
errors(model=assetvar,steps=nsteps,factor=gfactor,noprint,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
*
* Add the total spillover measure to the list for entry <<end>>
*
compute spillstats(end)=spillstats(end)+100.0*%sum(tovar)/%nvar
end do end
end do nlags
*
* Extract the min, max and median
*
set lower rstart+nspan-1 rend = %minvalue(spillstats(t))
set upper rstart+nspan-1 rend = %maxvalue(spillstats(t))
set median rstart+nspan-1 rend = %fractiles(spillstats(t),||.5||)(1)
*
* Graph the range as a "fan" and the median as a line
*
graph(style=line,overlay=fan,ovcount=2,ovsame,$
header="Figure A1. Sensitivity of the index to VAR Lag Structure") 3
# median
# lower
# upper
*
*******************
*
* Sensitivity to forecast horizon for the four lag model
*
* Re-initialize the spillstats
*
gset spillstats rstart rend = null
*
compute maxsteps=10
compute minsteps=5
compute nlags=1
*
system(model=assetvar)
variables sp500 r_10y djubscom
lags 1 to nlags
det constant
end(system)
*
do end=rstart+nspan-1,rend
estimate(noprint) end-nspan+1 end
*
* Skip any data points where the rolling VAR has an explosive root.
*
eigen(cvalues=cv) %modelcompanion(assetvar)
if %cabs(cv(1))>=1.0 {
next
}
compute gfactor=FactorMatrix()
do nsteps=minsteps,maxsteps
errors(model=assetvar,steps=nsteps,factor=gfactor,noprint,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
*
* Add the total spillover measure to the list for entry <<end>>
*
compute spillstats(end)=spillstats(end)+100.0*%sum(tovar)/%nvar
end do nsteps
end do end
*
* Extract the min, max and median
*
set lower rstart+nspan-1 rend = %minvalue(spillstats(t))
set upper rstart+nspan-1 rend = %maxvalue(spillstats(t))
set median rstart+nspan-1 rend = %fractiles(spillstats(t),||.5||)(1)
*
* Graph the range as a "fan" and the median as a line
*
graph(style=line,overlay=fan,ovcount=2,ovsame,$
header="Figure A2. Sensitivity of the index to Forecast Horizon") 3
# median
# lower
# upper