Diebold-Yilmaz EJ 2009

Use this forum for posting example programs or short bits of sample code.
econo
Posts: 32
Joined: Fri Sep 05, 2014 9:16 am

Re: Diebold-Yilmaz EJ 2009

Unread post by econo »

hhhaa ha
such a stupid mistake.Now I could ımport 93 columns. (the whole data I had). But what is limit here? if I collect the data for 500 stocks (columns) can I import to rats? and run the model.
even with 2500 observations?

this is important to know the limit of variables as all of my studies will depend on that.

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

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

Wouldn't it make sense to start with a more modest sized model and see whether you can make any sense out of the results? Even with just 19 countries (and two lag VAR's), DY had problems with explosive VAR estimates when they went to the 200 data point windows. Given that the data were weekly return series with relatively low serial correlation, the fact that some of the rolling VAR's went explosive is a rather good sign that those windows were too small to estimate the model well. And those were windows with 6 x the number of estimated coefficients. Also, how would you ever summarize the results from a 500 x 500 matrix?
Fisher
Posts: 6
Joined: Tue Apr 21, 2015 7:32 pm

Extract spillover with rolling window(Diebold_Yilmaz(2011))

Unread post by Fisher »

Hi,
I want to extract the spillover "to others" and "from others" for each market (country) like Diebold and Yilmaz(2011) with rolling window. How can I make this? Following is the replication code for Diebold and Yilmaz(2009, 2011).

Code: Select all

*
* Replication file 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.
*
* Analysis of returns data
*
* If you make usegirf=1, this will use the generalized spillover
* measures proposed in Diebold and Yilmaz(2011), "Better to Give than to
* Receive: Predictive Directional Measurement of Volatility Spillovers",
* IJF, to appear. usegirf=0 does the Choleski factorization used in the
* 2009 paper.
*
.........
*
* Rolling window analysis
*
compute nspan=200
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*%sum(tovar)/%nvar
end do end
graph(footer="Spillover plot. Returns. 200 week window. 10 step horizon")
# spillreturns

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

Re: Extract spillover with rolling window(Diebold_Yilmaz(201

Unread post by TomDoan »

Create a VECT[SERIES] for the "from" values outside the loop. Inside the loop, compute the "fromvar" vector and save the results into your target. That is

dec vect[series] myfromseries(%nvar)
clear(zeros) myfromseries
do end=...
...
ewise fromvar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
compute %pt(myfromseries,end,fromvar)
...
end do end
*
power23
Posts: 14
Joined: Sun Apr 17, 2016 6:34 am

Re: Diebold-Yilmaz EJ 2009

Unread post by power23 »

hi!

I apply the Diebold-Jilmaz formula to replicate the spillover index for credit default swaps. So, I employed a RATS code similar to "dieboldyilmaz_ej2009.zip". However, the RATS created the total spillover index (as an additional series) and the spillover table in the output, but it did not create "from" and "to" series as long as "net" spillovers series for each variable.

Could anyone help me about how to create them (and store them) since I want to build graphs for spillovers for each variable


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

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

See the thread starting with https://estima.com/forum/viewtopic.php?p=10982#p10982. (There were six different D&Y threads---I just consolidated them).
power23
Posts: 14
Joined: Sun Apr 17, 2016 6:34 am

Re: Diebold-Yilmaz EJ 2009

Unread post by power23 »

thanks TomDoan!

I appreciate it also if you could help me about how can I create Net pairwise spillovers

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

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

gfevdx(i,j)-gfevdx(j,i) is the net volatility spillover between i and j.
power23
Posts: 14
Joined: Sun Apr 17, 2016 6:34 am

Re: Diebold-Yilmaz EJ 2009

Unread post by power23 »

thanks for your response

I applied gfevdx(i,j)-gfevdx(j,i) either with "ewise" or "compute" but the program reports illegal combination of i,j
Can I declare i and j as the variables?

Thanks once again!
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

That's just the general formula. You have to put in the specific I and J that are of interest.
THETABETA
Posts: 1
Joined: Wed May 04, 2016 2:41 am

Re: Diebold-Yilmaz EJ 2009

Unread post by THETABETA »

I got this error message when running the sample codes from Diebold_Yilmaz paper.

##Mat14. Non-invertible matrix, using generalized inverse for symmetric.
the error occurred at location 23, line 4 of factormatrix
called from location 173, line 15 of loop/block

I need some help to solve the issue.

i appreciate your time. Thank you
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

Is this an adaptation of the DY code to your data and model? If so, you would have to post your program. However, it sounds like you're doing the rolling regressions with a window too short for your model.
power23
Posts: 14
Joined: Sun Apr 17, 2016 6:34 am

Re: Diebold-Yilmaz EJ 2009

Unread post by power23 »

Dear Tom,


I was wondering if I can use DY method for estimating a panel VAR..Is that feasible?
For instance, I want to study the spillovers between groups of countries (i.e. developed-emerging markets) ant not the spillovers from a country to another


Thanks!


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

Re: Diebold-Yilmaz EJ 2009

Unread post by TomDoan »

I'm not sure what you mean by a "panel VAR" in this context. In effect, what they're working with IS a panel data set---in the EJ 2009, it's two data series with 19 countries. Because it's a (very) big T data set, they're allowing for general cross-variable dynamics.
power23
Posts: 14
Joined: Sun Apr 17, 2016 6:34 am

Re: Diebold-Yilmaz EJ 2009

Unread post by power23 »

Dear Tom,


Thanks for the response.
I want to create a group of countries, called emerging, for which I will employ several variables such as inflation, industrial production, stock indices, etc. These variables could be analyzed in a simple panel framework that inflation for example, refers to all emerging countries. However, I specifically keen on studing the impact of such variables from developed countries (US, UK, EMU) on this block of the emerging as a whole. In DY 2009 paper, the spillovers of each country (both emerging and developed) are analyzed separately. I assume that if I can define the var model as a panel var the DY code will be applied.
In this case I would be grateful if you could hepl me about any existing panel var code in RATS.



Thanks


V
Post Reply