Diebold and Yilmaz (2012) crashes

Questions and discussions on Vector Autoregressions
veryconfusedmgarch
Posts: 7
Joined: Wed Jun 21, 2017 9:57 am

Diebold and Yilmaz (2012) crashes

Unread post by veryconfusedmgarch »

Hi,

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




TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold and Yilmaz (2012) crashes

Unread post by TomDoan »

The LIST aggregator really didn't work until 9.0. You should talk to your department about updating the software.
Post Reply