This is an application of time-varying parameter frequency connectedness approach in Chatziantoniou, Gabauer & Gupta (2021).
Firstly install the ConnectednessApproach packages from github.(The “remotes” package is required)
library(remotes)
library(ConnectednessApproach)
Choose a csv file which has date index as the first column, for instance, instead of cgg2022, we can choose dy2012.csv, which is the dataset of Diebold and Yilmaz(2012) in csv format.
library(knitr)
path=file.path(file.choose())##choose the csv file
Data=read.csv(path)
The “ConnectednessApproach” package requires the file to be in zoo format, so it’s necessary to covert a data frame to time series:
Data=read.zoo(Data, header=TRUE,format = "%Y-%m-%d")
This section shows a TVP-VAR frequency connectedness approach, the setup of all the parameters is following Gabauer(2022).
partition = c(pi+0.00001, pi/5, 0)
dca = ConnectednessApproach(Data,
model="TVP-VAR",
connectedness="Frequency",
nlag=1,
nfore=100,
window.size=200,
VAR_config=list(TVPVAR=list(kappa1=0.99, kappa2=0.99,
prior="BayesPrior")),
Connectedness_config = list(
FrequencyConnectedness=list(partition=partition,
generalized=TRUE, scenario="ABS")
))
kable(dca$TABLE)
The dynamic Total Connectedness
PlotTCI(dca, ylim=c(0,100))
The Net Total Directional Connectedness
PlotNET(dca, ylim=c(-60,60))
The Net Pairwise Directional Connectedness
PlotNPDC(dca, ylim=c(-30,30))
Note that it’s capable to save the zoo file as a csv.
write.csv(as.data.frame(zoo_file_name), "filename.csv", row.names=TRUE)