Diebold Yilmaz EJ 2009 |
This is a description of the specific analysis done in the replication for Diebold and Yilmaz(2009). There's a separate page for the companion piece Diebold and Yilmaz(2012). See "Diebold Yilmaz spillover papers" for a description of the common structure of the programs and analysis.
There are two data files and two or three separate programs for each. Since the data, data transformations and VAR model setup are the same for each program that uses a particular data file, there are source files (dy_ejreturnssetup.src and dy_ejvolatilitysetup.src) which do those common operations. These are fairly complicated because it's a large model (19 series)—a smaller model (for instance the 2012 paper uses just 4) won't need anything like this. The source file for returns is described below.
RETURNS.RPF
Creates the full-sample "spillover" table for the returns data.
RETURNS_ROLLING.RPF
Generates several graphs based upon rolling sample estimates for the returns data.
VOLATILITY.RPF
Creates the full-sample "spillover" table for the volatility data.
VOLATILITY_ROLLING.RPF
Generates several graphs based upon rolling sample estimates for the volatility data. Because the volatility data is closer to having a unit root than the returns (which are close to white noise), some of the rolling sample estimates are unstable and are left out of the graph.
RANDOMORDERS.RPF (for Cholesky factors only)
Analyzes random orders for the volatility data to get limits on contributions. (Because there are 19 series, an exhaustive analysis isn't feasible.)
This sets the number of lags in the VAR.
compute nlags=2
This pulls the data off the weekly_realreturns sheet on the spreadsheet. The TOP and LEFT options on DATA skip the non-data numbers in the first row and left column.
open data dy_ej2009.xls
calendar(w) 1992:1:10
data(format=xls,org=columns,sheet="weekly_realreturns",top=2,left=2) 1992:01:10 2007:11:23 $
rrdjia rrftse rrfra rrger rrhkg rrjpn rraus rridn rrkor rrmys rrphl rrsgp rrtai rrtha rrarg $
rrbra rrchl rrmex rrtur
This sets up a list of the return series being used in the model.
dec vect[int] returns
enter(varying) returns
# rrdjia rrftse rrfra rrger rrhkg rrjpn rraus rridn rrkor rrmys rrphl rrsgp rrtai rrtha $
rrarg rrbra rrchl rrmex rrtur
This sets up a list of longer descriptive labels for the series (which need to be in the same order as in RETURNS):
dec vect[string] longlabels(%size(returns))
enter longlabels
# "United States" "United Kingdom" "France" "Germany" "Hong Kong" "Japan" "Australia" $
"Indonesia" "South Korea" "Malaysia" "Philippines" "Singapore" "Taiwan" "Thailand" $
"Argentina" "Brazil" "Chile" "Mexico" "Turkey"
And these are shorter labels for use in tables (again, in order)
dec vect[string] shortlabels(%size(returns))
enter shortlabels
# "US" "UK" "FRA" "GER" "HKG" "JPN" "AUS" "IDN" "KOR" "MYS" "PHL" "SGP" "TAI" "THA" $
"ARG" "BRA" "CHL" "MEX" "TUR"
And this sets up and estimates the (full sample) VAR:
system(model=returnvar)
variables returns
lags 1 to nlags
det constant
end(system)
Technical Notes
The RESULTS option for the ERRORS instruction saves the decomposition (in decimals) in a RECT[SERIES]. If you use RESULTS=GFEVD, then GFEVD(i,j) is a series running from entries 1 to NSTEPS with, at each step, the fraction of series i explained by shock j. The "cross-section" of that at entry NSTEPS can be pulled with %XT(GFEVD,NSTEPS), returning an \(m \times m\) array with variables in the rows and shocks in the columns. The various spillover measures will be sums of non-diagonal elements in this matrix. The rows represent the target variable, and the columns represent the shock variable. So the following, which sum either a row or column and subtract the diagonal, will give the spillover to and spillover from each variable.
dec vect tovar(%nvar) fromvar(%nvar)
ewise tovar(i)=%sum(%xrow(gfevdx,i))-gfevdx(i,i)
ewise fromvar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
This is graphing the ten step total "TO" spillover measure. If you want to graph some other quantity (quantities), you need to set up the target series before the loop (here it was the SET SPILLVOLS instruction) and change the two COMPUTE's inside the loop to save the value you want. For instance, in this case, if you wanted the U.S. (variable 1) to France (variable 3) spillover measure, you would change this to something like
set us_to_fra rstart+nspan-1 rend = 0.0
and then
compute us_to_fra(end)=%na
when the sample is rejected and
compute us_to_fra(end)=100.0*gfevdx(3,1)
when it's accepted. (Again, the target is the first subscript and the source is the second in the GFEVDX array). You can, of course, compute multiple statistics by just doing multiple series like this. See, for instance, the later code with a width 75 window, which keeps both 2 and 10 step ahead results. The net spillover (which can be either positive or negative) between U.S. and France would be computed as something like
compute us_fra_net(end)=100.0*(gfevdx(1,3)-gfevdx(3,1))
(You would have to set up the US_FRA_NET series outside the loop).
If you want the total spillover to France specifically, after
ewise tovar(i)=%sum(%xcol(gfevdx,i))-gfevdx(i,i)
save the value of tovar(3) into the END entry of the series you are creating.
Copyright © 2025 Thomas A. Doan