Diebold-Yilmaz EJ 2009

Use this forum for posting example programs or short bits of sample code.

Diebold-Yilmaz EJ 2009

Postby TomDoan » Mon Mar 28, 2011 4:19 pm

This is a set of replication files for Diebold and Yilmaz(2009), "Measuring Financial Asset Return and Volatility Spillovers, with Application to Global Equity Markets," Economic Journal, vol. 119, no. 534, 158-171. This does both the full sample and rolling VAR analyses. Note that this paper does not do the "generalized" spillover indexes used in a more recent paper by the same authors. However, we have written these examples to allow an easy change (changing the setting of one variable) to compute the generalized version instead.

Updated 28 March 2011 to simplify switch to generalized spillover calculation and correct that calculation.

These are written to be adapted to other data sets with relatively little change.

returns.rpf
Program for return data
(4.25 KiB) Downloaded 447 times


volatility.rpf
Program for volatility data
(5.38 KiB) Downloaded 368 times


randomorders.rpf
Program to analyze random permutations of the Choleski factor
(2.58 KiB) Downloaded 320 times


Note well: the data set has extra header rows and columns, and can't be read as it stands using RATS 7.x or earlier. These programs use the TOP and LEFT options (added with version 8.0) to isolate the actual data table.

DY_EJ2009.xls
Data set
(1.67 MiB) Downloaded 432 times
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby dec3fc » Thu May 26, 2011 8:40 pm

Hi Tom,

Thank you very much for making this replication files available. I have managed to compute and graph both standard (Diebold and Yilmaz, 2009) and generalised (Diebold and Yilmaz, 2011) spillover indices. However, I am having a difficulty in getting the values and figures for both gross and net directional To/From indices appearring in Diebold and Yilmaz (2011). I would be most grateful if you could please advise on what need to be added or changed in this replication file in order to compute the directional measures and figures.

Many thanks

Best,
Frankie
dec3fc
 
Posts: 3
Joined: Mon Aug 18, 2008 6:51 pm
Location: UK

Re: Diebold-Yilmaz EJ 2009

Postby TomDoan » Fri May 27, 2011 10:27 am

I'm a bit confused about the question. The same measures are being used in both the 2009 and 2011 papers, and are included in the borders of the table. The one major difference with the 2011 paper is that the values are invariant to order.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby dec3fc » Fri May 27, 2011 5:58 pm

Hi Tom,

Many thanks for the prompt response. In 2011 paper, in addition to putting forward a measure which is invariant to the order of variables, the authors have also decomposed the total contribution into a few directional measures to capture the contribution 'to and from' a particular market i (as in figures 3 -6). My initial question was how could we compute these directional measures and figures using the replicated files you have kindly provided us.

Many thanks

Frankie
dec3fc
 
Posts: 3
Joined: Mon Aug 18, 2008 6:51 pm
Location: UK

Re: Diebold-Yilmaz EJ 2009

Postby TomDoan » Sat Jun 04, 2011 7:01 pm

dec3fc wrote:Hi Tom,

Many thanks for the prompt response. In 2011 paper, in addition to putting forward a measure which is invariant to the order of variables, the authors have also decomposed the total contribution into a few directional measures to capture the contribution 'to and from' a particular market i (as in figures 3 -6). My initial question was how could we compute these directional measures and figures using the replicated files you have kindly provided us.

Many thanks

Frankie


No. That's still the same information. In the N x N table, the "To"'s are in the columns and the "From"s are in the rows.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby featherhan » Wed Aug 24, 2011 8:16 am

Hi Tom,
I'm trying to compute the directional spillovers in Diebold and Yilmaz (2011), Better to give than to receive: Predictive directional measurement of volatility spillovers, http://www.sciencedirect.com/science/ar ... 701100032X
I think the program is quite similar to the rolling window analysis in your replications. However I met the following problem. (The change i made is at the end in red)

* Rolling window analysis
*
compute nspan=100
set spillreturns rstart+nspan-1 rend = 0.0
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(returnvar)
if %cabs(cv(1))>=1.0 {
compute spillreturns(end)=%na
next
}

compute gfactor=FactorMatrix()
errors(model=returnvar,steps=nsteps,factor=gfactor,stderrs=gstderrs,noprint,results=gfevd)
compute gfevdx=%xt(gfevd,nsteps)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
compute spillreturns(end)=100.0*tovar(i)/%nvar


end do end

graph(footer="Spillover plot. Returns. 100 week window. 10 step horizon")
# spillreturns
## SR5. Using Range -32765 to -32765 of Series SPILLRETURNS. (Incorrect start,end or SMPL)

Would you please tell me how to solve this problem?

Tuohan
featherhan
 
Posts: 2
Joined: Tue Jul 19, 2011 1:57 pm

Re: Diebold-Yilmaz EJ 2009

Postby TomDoan » Wed Aug 24, 2011 9:12 am

featherhan wrote: ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
compute spillreturns(end)=100.0*tovar(i)/%nvar


What does the "I" represent in the second line? In the first, it's an index across the dimensions of TOVAR.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby featherhan » Wed Aug 24, 2011 9:45 am

TomDoan wrote:
featherhan wrote: ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
compute spillreturns(end)=100.0*tovar(i)/%nvar


What does the "I" represent in the second line? In the first, it's an index across the dimensions of TOVAR.

Hi Tom,
Thank u for ur quick respond.
Actually I have tried without "i", but it reports another mistake.

compute spillreturns(end)=100.0*tovar/%nvar
## SX22. Expected Type REAL, Got MATRIX(REAL) Instead
>>>>=100.0*tovar/%nvar<<<<
end do end

Tuohan
featherhan
 
Posts: 2
Joined: Tue Jul 19, 2011 1:57 pm

Re: Diebold-Yilmaz EJ 2009

Postby TomDoan » Sun Aug 28, 2011 12:04 pm

The original program had:

Code: Select all
   compute spillvols(end)=100.0*%sum(tovar)/%nvar


That computes the average of the "TO" contributions across variables. You seem to be trying to do something other than using %SUM(...), but I can't tell what you're trying to do with that.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby timkrause » Tue Jul 17, 2012 12:42 pm

Hi,

I just started looking at this since I am also interested in using the 2011 program. I believe Frankie is referring to Figure 6 in DY2011 where they create and chart the time series of net pairwise volatility spillovers. I will try to modify the code to extract these variables. Any other suggestions would be appreciated.

Thanks,

Tim
timkrause
 
Posts: 8
Joined: Tue Nov 29, 2011 10:10 pm

Re: Diebold-Yilmaz EJ 2009

Postby TomDoan » Wed Jul 18, 2012 3:15 pm

The directional values are obtained using

ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)

where gfevdx is the extracted value for a particular horizon. 100.0*fromvar(i) is the contribution from other variables to variable i(in percentages). 100.0*tovar(i) is the total contribution to all other variables from variables to i. The bilateral i to j is 100.0*gfevdx(j,i)/%sum(%xrow(gfevdx,j)). Whichever calculations you need for the rolling calculations have to be saved into a slot in a series so they can be graphed later.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby timkrause » Wed Jul 18, 2012 8:36 pm

Thanks Tom,

Yes, I figured out that the needed values were in "gfevdx", so I'm trying to add code to pull them out of that matrix and into series' during each iteration.

Tim
timkrause
 
Posts: 8
Joined: Tue Nov 29, 2011 10:10 pm

Re: Diebold-Yilmaz EJ 2009

Postby timkrause » Thu Jul 19, 2012 8:50 pm

Got it. I have a 10 x 10 matrix and I was interested in the spill from column one to row two. So I inserted this statement in the rolling window analysis, just below compute spillvols(end)...

compute tovol2(end)=100.0*gfevdx(2,1)

I also needed to initialize the series with "set tovol1 rstart+nspan-1 rend = 0.0" just below "set spillvols rstart..."

Hope that helps,

Tim
timkrause
 
Posts: 8
Joined: Tue Nov 29, 2011 10:10 pm

Re: Diebold-Yilmaz EJ 2009

Postby tomcy » Wed Aug 01, 2012 10:07 am

Hi Tim and Tom,

Thanks for the information above, it is really useful. Similar to other posts above, I am trying to replicate the directional spillover charts plotted in Figure 3 to Figure 6 of the Diebold and Yilmaz (2011) paper. To start, I am looking at the directional spillovers to others and from others (figs 3 and 4). I understand how the values I need come from gfevdx but I have been struggling a bit with saving and graphing the series from the rolling regression. I think I have almost figured out the code and wanted to check here that I am doing this correctly. To obtain the spillovers from variable (1) to all other variables (from stocks to others as in top left panel of Figure 3 in DY 2011 paper), I have added the following two lines to the original code (as well as set vol1 rstart+….to initialise the series):

ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
compute vol1(end)=100.0*fromvar(1)

My code looks like this (my additions to original code in red):

ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
compute spillreturns(end)=100.0*%sum(tovar)/%nvar
compute vol1(end)=100.0*fromvar(1)
end do end
graph(footer="Spillover plot. Returns. 200 week window. 10 step horizon")
# vol1

Similarly to obtain the directional spillovers to variable (1) from others (Fig 4) I use:

ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
compute vol2(end)=100.0*tovar(1)

To obtain the spillovers to variables (2),(3),(4), I use compute vol2(end)=100.0*tovar(2) etc and so on for variables (3) and (4). Is this the appropriate way to calculate the directional spillovers to and from the four variables? Any advice would be greatly appreciated.

Thank you,
Tom
tomcy
 
Posts: 2
Joined: Tue Mar 27, 2012 12:36 pm

Re: Diebold-Yilmaz EJ 2009

Postby zy761 » Mon Oct 15, 2012 3:57 am

TomDoan wrote:The directional values are obtained using

ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)

where gfevdx is the extracted value for a particular horizon. 100.0*fromvar(i) is the contribution of variable i to all other variables (in percentages). 100.0*tovar(i) is the total contribution of all other variables to i. The bilateral i to j is 100.0*gfevdx(j,i)/%sum(%xrow(gfevdx,j)). Whichever calculations you need for the rolling calculations have to be saved into a slot in a series so they can be graphed later.


Sorry Tom I am a little confused here. I thought 100.0*tovar(i) is the contribution of variable i to all other variables and 100.0*fromvar(i) is the total contribution of all other variables to i. Because in the program you use 100*tovar for "Contribution to others" and 100.0*fromvar for "From others".

Could you please confirm about this? Thanks a lot for your reply in advance.
zy761
 
Posts: 7
Joined: Mon Mar 19, 2012 1:01 am

Next

Return to Examples and Sample Code

Who is online

Users browsing this forum: No registered users and 2 guests