Diebold-Yilmaz EJ 2009

Use this forum for posting example programs or short bits of sample code.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

dieboldyilmaz_ej2009.zip 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.

Detailed description
dec3fc
Posts: 3
Joined: Mon Aug 18, 2008 6:51 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by dec3fc »

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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

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.
dec3fc
Posts: 3
Joined: Mon Aug 18, 2008 6:51 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by dec3fc »

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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

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.
timkrause
Posts: 6
Joined: Tue Nov 29, 2011 9:10 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by timkrause »

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
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

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.
timkrause
Posts: 6
Joined: Tue Nov 29, 2011 9:10 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by timkrause »

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: 6
Joined: Tue Nov 29, 2011 9:10 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by timkrause »

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
tomcy
Posts: 2
Joined: Tue Mar 27, 2012 12:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by tomcy »

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
blucey
Posts: 6
Joined: Wed Nov 08, 2006 2:48 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by blucey »

Im also wondering about the individual directional spillovers a la 2011 paper. Anybody get any further with this?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

nikosant82
Posts: 2
Joined: Wed Oct 10, 2012 12:31 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by nikosant82 »

Dear Tom,

Does it make sense to use Structural decomposition, instead of Cholesky (or GIRF), and do the spillover index analysis as in Diebold and Yilmaz (2009)?
I have amended the code by estimating an SVAR model and everything seems to work fine up to the generation of the Spillover table.
However, when I try to generate the spillover plot using rolling windows I get the following mistake:

Code: Select all

## SR5. Writing Range -32707 to 198 of Series SPILLRETURNS. (Incorrect start,end or SMPL)
Something is wrong with the data range and which I cannot understand.
I would be very grateful if you could help me finding the solution to this and whether the structural decomposition and code I've prepared make sense?

Many thanks,
Nikos
Attachments
code.RPF
Code
(4.45 KiB) Downloaded 2066 times
Data.xls
Data
(48 KiB) Downloaded 1802 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

nikosant82 wrote:Dear Tom,

Does it make sense to use Structural decomposition, instead of Cholesky (or GIRF), and do the spillover index analysis as in Diebold and Yilmaz (2009)?
You could, thought it's not particularly interesting, since you're just reading information out of a standard FEVD.
nikosant82 wrote: I have amended the code by estimating an SVAR model and everything seems to work fine up to the generation of the Spillover table.
However, when I try to generate the spillover plot using rolling windows I get the following mistake:

Code: Select all

## SR5. Writing Range -32707 to 198 of Series SPILLRETURNS. (Incorrect start,end or SMPL)
Something is wrong with the data range and which I cannot understand.
You have to move

compute rstart=%regstart(),rend=%regend()

up after the ESTIMATE instruction. Because you have an extra estimation instruction that wasn't in the original program (CVMODEL) the %REGSTART() and %REGEND() get redefined from what they were immediately after the ESTIMATE.
zy761
Posts: 13
Joined: Mon Mar 19, 2012 1:01 am

Re: Diebold-Yilmaz EJ 2009

Unread post by zy761 »

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 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.
Dear Tom,

In addition to the bilateral volatility spillover index from variable i to variable j, is it able to to calculate the index from a group of variable (e.g. a,b,c) to another group of variable (e.g. x,y,z) (The number of variables in the group is less than the total variables in the system)?

Best regards,
Jasmine
Post Reply