Diebold-Yilmaz, IJF 2012

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, IJF 2012

Unread post by TomDoan »

dieboldyilmaz_ijf2012.zip is the 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. This is a companion piece to Diebold and Yilmaz(2009). The 2012 article uses "generalized" IRF's rather than the Cholesky IRF's used in the 2009 article, though the ability to use GIRF's has been included in the DY 2009 code for several years. The 2012 uses a much smaller set of series which makes several other types of measures feasible, such as rolling net pairwise spillovers. (Those could be computed in the 2009 data set, but there would be 171 pairs for that rather than 6 for the small set.)

Detailed description
jasmina_cam
Posts: 3
Joined: Sun Aug 14, 2016 4:20 am

Re: Diebold-Yilmaz, IJF 2012

Unread post by jasmina_cam »

Hello, Since I am a newbie to RATS and code writing, my question may sound simple to you, though it is not for me.
I would like to obtain Figure 2 (Total Volatility Spillover) as a time series. How can I obtain this?

Thanks for your help,
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

That's just the TOTALSPILL series. (Anything that's graphed has to be in a series).
jasmina_cam
Posts: 3
Joined: Sun Aug 14, 2016 4:20 am

Re: Diebold-Yilmaz, IJF 2012

Unread post by jasmina_cam »

Thanks I got it.
A further question: The example code is for 4 assets, though I am doing for 2 asset classes (stocks and commodities).
I have majorly edited through the code, however I got a total spillover index series ranging between 10 to 60. Moreover, net spillover for an asset sometimes reaches to 50, which is impossible for these two asset classes. Though the table gives reasonable result on spillover index which is 3.5%. Do you have any idea why this could happen?

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

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

jasmina_cam wrote:Shall I post my edited version of the code? Would it help? Thanks,
Program and data. Why do you think the net can't be above 50?
jasmina_cam
Posts: 3
Joined: Sun Aug 14, 2016 4:20 am

Re: Diebold-Yilmaz, IJF 2012

Unread post by jasmina_cam »

I attached both the code and data.

I am quite sure net volatility spillover cannot be around 50, because this would mean that a single commodity can have an impact of around 50% on stocks (or vice versa), which is, I believe, is impossible.
For instance I check the example code you included for 4 asset classes (commodity, stocks, bonds and FX market) and if you check Figure 6 you would see that the net spillover is at most 6.0 for stocks-commodities pair.

I strongly believe something is wrong with my code, while modifying the code for 2 assets, most probably I am missing something.

Thanks for your help,
Attachments
DYCode_xy.rtf
Code
(47.43 KiB) Downloaded 2080 times
xy.xlsx
Data
(147.32 KiB) Downloaded 2186 times
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

First of all, net spillover is subtracting apples from oranges---it's not clear what a value of "10" or "-10" even means (and 90-80 is quite different from 20-10). There is nothing wrong with the calculation. However, you are doing way too many steps. There's a reason that DY do 10 step responses---at 100 steps, the FEVD will almost always be dominated by a single root. With a pair of (almost certainly) I(1) processes, that means it pretty much randomly is picking one of the two series to appear dominant. Combine that with a rather short estimation window (200 on a 5000+ observation data set) and you get strange values.
klaus86
Posts: 6
Joined: Fri Apr 24, 2015 3:20 am

Re: Diebold-Yilmaz, IJF 2012

Unread post by klaus86 »

Is there a way to implement the LASSO and elastic net shrinkage in the VAR estimation before computing the variance decompositions? The authors apply this method to a high-dimensional VAR in their most recent paper: Demirer, Diebold, Liu and Yilmaz (2017), Estimating Global Bank Network Connectedness, NBER Working Paper 23140, URL: http://www.nber.org/papers/w23140.

Thank you for your comments!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

LASSO can be done using LQPROG. See https://www.estima.com/forum/viewtopic. ... 458#p19458.
Attachments
lasso.rpf
(1.39 KiB) Downloaded 2137 times
hungufm
Posts: 13
Joined: Tue Dec 11, 2018 5:00 am

Re: Diebold-Yilmaz, IJF 2012

Unread post by hungufm »

Dear Tom,

Thanks for your comments. But i cannot run the classes of plots folowing the codes:
*

Code: Select all

graph(header="Figure 2. Total Volatility Spillovers, Four Asset Classes")
# totalspill rstart+nspan-1 rend
*
spgraph(vfields=4,hfields=2,$
  header="Figure 3. Directional Volatility Spillovers, FROM Four Asset Classes")
 do i=1,%nvar
   graph(header=longlabels(i),style=bar)
   # fromspill(i) rstart+nspan-1 rend
 end do i
spgraph(done)
*
spgraph(vfields=2,hfields=2,$
  header="Figure 4. Directional Volatility Spillovers, TO Four Asset Classes")
 do i=1,%nvar
   graph(header=longlabels(i),style=bar)
   # tospill(i) rstart+nspan-1 rend
 end do i
spgraph(done)
*
spgraph(vfields=2,hfields=2,$
  header="Figure 5. Net Volatility Spillovers, Four Asset Classes")
 do i=1,%nvar
   graph(header=longlabels(i),style=bar)
   # netspill(i) rstart+nspan-1 rend
 end do i
spgraph(done)
*
spgraph(vfields=3,hfields=2,$
  header="Figure 6. Net Pairwise Volatility Spillovers")
  do i=1,%nvar
     do j=i+1,%nvar
        graph(header=shortlabels(i)+"—"+shortlabels(j),style=bar)
        # pairspill(i,j)
     end do j
  end do i
spgraph(done)
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

I'm not sure what "I cannot run..." means, but those are all set up for four when you have five, so you've have to adjust the number of fields.
curiousresearcher
Posts: 41
Joined: Sun May 19, 2019 9:56 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by curiousresearcher »

Guys,

Is this model preferrable compared to BEKK or DCC garch in case of large multiple financial series data i.e. 21 countries stock indices return series?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

Those are completely different approaches which are similar only in the (confusing choices of) terminology. The DY analysis assumes homoscedastic errors with a model with non-trivial dynamics in the mean. The "volatility" being measured is the variance of multi-step forecast errors. BEKK GARCH assumes (conditionally) heteroscedastic errors, typically with rather trivial dynamics in the mean (returns generally have little if any serial correlation in the mean) and looks at the one-step out predictability of the variance, rather than multi-step errors in predictability of the mean.
abbas4haider
Posts: 1
Joined: Wed Oct 21, 2020 11:38 pm

Diebol and Yilmaz (2012)

Unread post by abbas4haider »

Hi, I am doing analysis in RATS and got stuck in one problem. While using Diebold and Yilmaz 2012, spillover index approach, how can I extract directional/pairwise spillovers series (From and To) in excel. Thank You
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz, IJF 2012

Unread post by TomDoan »

Are you looking at the Table 2 values (full sample) or the rolling window values. For Table 2, the simplest thing to do is probably to just reload Table 2 (Window--Report Windows selector) and export it to Excel. You can also do

write(format=xlsx,unit=copy) fromvar~tovar

which will prompt you for the file name.

For the rolling windows, you would do

copy(format=xlsx,unit=copy,dates) / fromspill tospill

Again, it will prompt you for the file name.
Post Reply