Diebold-Yilmaz Spillover Index using R package

This post explains how to use Spillover R package to calculate Diebold-Yilmaz spillover index. It measures a return or volatility spillover across asset classes and also a time series of rolling spillover index for taking time-varying spillovers into account.


Diebold-Yilmaz Spillover Index using R package


Diebold and Yilmaz (DY;2009,2012) introduce a volatility spillover measure based on VAR model's forecast error variance decompositions (FEVD).They said that It can be used to measure spillovers in returns or return volatilities across assets or similar categories. Fortunately, Spillover R package does this job in a simple manner.



Spillover Table and Rolling Spillover Index


DY spillover is calculated based on VAR(p) model's FEVD which uses Cholesky ordering or generalized FEVD and measures total, directional, net spillovers and so on.

Given a width of a rolling window such as 200-day, repeated VAR(p) estimations with successive rolling samples and calculations of a spillover produce a series of spillovers, in other words, dynamic spillover index.



R code : Spillover Table


We can calculate DY spillover table using O.spillover() and G.spillover() functions of Spillover R package. The following R code calculates the spillover table using Diebold and Yilmaz (2012) data set with estimated VAR(4) model.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#========================================================#
# Quantitative ALM, Financial Econometrics & Derivatives 
# ML/DL using R, Python, Tensorflow by Sang-Heon Lee 
#
# https://shleeai.blogspot.com
#--------------------------------------------------------#
# Diebold-Yilmaz Spillover Index
#========================================================#
 
graphics.off(); rm(list = ls())
 
library(Spillover)
 
#--------------------------------------------------
# Data : Diebold and Yilmaz (2012)
#--------------------------------------------------
data(dy2012)
df.data <- dy2012[,-1]
date <- as.Date(dy2012$Date)
 
p.ar    <- 4  # VAR order
n.ahead <- 10 # days
 
#--------------------------------------------------
# Spillover Table
#--------------------------------------------------
 
# VAR(p) estimation
VAR.est <- VAR(df.data, p=p.ar) 
 
# based on Choleskdy FEVD
O_table <- O.spillover(x=VAR.est, n.ahead=n.ahead,
                       standardized = FALSE)
 
# based on Generalized FEVD
G_table <- G.spillover(x=VAR.est, n.ahead=n.ahead,
                       standardized = FALSE)
 
O_table
G_table
 
cs


The second spillover table is a replication of that of Diebold and Yilmaz (2012).



R code : Spillover Index


By using roll.spillover() function with the size of window being a 200-day, the rolling spillover index is calculated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#--------------------------------------------------
# Rolling Spillovers or Spillover Index
#--------------------------------------------------
 
n.window <- 200
 
# data set for rolling spillover functions
zoo.data <- zoo(df.data, date)
 
# Orthogonalized rolling spillover index
O_index <- roll.spillover(data = zoo.data, width = n.window, 
                n.ahead=n.ahead, p=p.ar)
 
# Generalized rolling spillover index
G_index<- roll.spillover(data = zoo.data, width = n.window, 
               n.ahead=n.ahead, index="generalized", p=p.ar) 
# plot
out <- cbind(O_index, G_index)
head(out)
x11(); plot(out, col=c(4,2), lwd = 2,
            main="Diebold-Yilmaz Rolling Spillover index")
 
cs


The second plot of dynamic spillover index is also a replication of that of Diebold and Yilmaz (2012).



Concluding Remarks


This post shows how to use Spillover R package to calculate Diebold-Yilmaz spillover table and dynamic rolling spillover index with only a few lines of code.


Reference


Diebold, F. X. and K. Yilmaz (2012), Better to give than to receive: Predictive directional measurement of volatility spillovers, International Journal of Forecasting 28-1, 57-66.


1 comment:

  1. Florian Kraus
    2023. 6. 12.
    Hi, there is also an insane package of David Gabauer, named "ConnectednessApproach" that allows to measure the connectedness in VAR, TVP-VAR, Lasso, DCC-GARCH and several other mutivariate models. The replications codes of Diebold Yilmaz are also available !

    Sang-Heon Lee
    2023. 6. 13.
    As you said, it is full-fledged.
    Thanks for letting me know about a very useful R package. I'll use it too.

    ReplyDelete

Tentative Topics (Keeping Track to Avoid Forgetting)

Segmented Nelson-Siegel model
Shifting Endpoints Nelson-Siegel model
Nadaraya-Watson estimator
Locally weighted scatterplot smoothing (LOWESS)
Time-Varying Parameter Vector Autoregressions (TVP-VAR)
Time-varying or Dynamic Copula
Bayesian VAR
Adrian-Crump-Moench (ACM) term premium model
GARCH-EVT-Copula approach