library("zoo")
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library("knitr")
## Warning: package 'knitr' was built under R version 4.3.3
library("rmgarch")
## Loading required package: rugarch
## Loading required package: parallel
## 
## Attaching package: 'rugarch'
## The following object is masked from 'package:stats':
## 
##     sigma
library("devtools")
## Loading required package: usethis
library("openxlsx")
library("relaimpo")
## Loading required package: MASS
## Loading required package: boot
## Loading required package: survey
## Loading required package: grid
## Loading required package: Matrix
## Loading required package: survival
## 
## Attaching package: 'survival'
## The following object is masked from 'package:boot':
## 
##     aml
## 
## Attaching package: 'survey'
## The following object is masked from 'package:graphics':
## 
##     dotchart
## Loading required package: mitools
## This is the global version of package relaimpo.
## If you are a non-US user, a version with the interesting additional metric pmvd is available
## from Ulrike Groempings web site at prof.beuth-hochschule.de/groemping.
library("stargazer")
## 
## Please cite as:
##  Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.3. https://CRAN.R-project.org/package=stargazer
library("RColorBrewer")
library("PerformanceAnalytics")
## Loading required package: xts
## Warning: package 'xts' was built under R version 4.3.3
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:rmgarch':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
colors = c("grey20","orange2","steelblue4","saddlebrown","springgreen4","firebrick","grey70")
palette(colors)

Please use the latest version

#install_github("GabauerDavid/ConnectednessApproach")
library("ConnectednessApproach")
## 
## Please cite as:
##  Gabauer, David (2022). ConnectednessApproach.
##  R package version 1.0.0. https://CRAN.R-project.org/package=ConnectednessApproach
data(cgp2024)
date = as.Date(cgp2024[,1])
Y = zoo(cgp2024[,-1], date)

NAMES = colnames(Y)
k = ncol(Y)
t = nrow(Y)

Figure 0: Percentage changes

par(mfcol = c(ceiling(k/2),2), oma = c(0, 1, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (i in 1:k) {
  plot(date,Y[,i],type='l',las=1,xaxs='i',yaxs='i',ylim=c(-11,11),xlab='',ylab='',main=paste(NAMES[i]),tck=-.02,col='steelblue4')
  grid(NA,NULL)
  lines(date,Y[,i],col='steelblue4')
  abline(h=0,lty=3)
  box()
}

Table 1: Summary statistics

kable(SummaryStatistics(Y, nlag=20))
## The following statistics are used:
## 
##           Skewness: D'Agostino, R.B. (1970). Transformation to Normality of the Null Distribution of G1. Biometrika, 57, 3, 679-681.
## 
##           Excess Kurtosis: Anscombe, F.J., Glynn, W.J. (1983) Distribution of kurtosis statistic for normal statistics. Biometrika, 70, 1, 227-234
## 
##           Normality test: Jarque, C. M., & Bera, A. K. (1980). Efficient tests for normality, homoscedasticity and serial independence of regression residuals. Economics Letters, 6(3), 255-259.
## 
##           ERS unit-root test: Elliott, G., Rothenberg, T. J., & Stock, J. H. (1996). Efficient Tests for an Autoregressive Unit Root. Econometrica, 64(4), 813-836.
## 
##           Weighted Portmanteau statistics: Fisher, T. J., & Gallagher, C. M. (2012). New weighted portmanteau statistics for time series goodness of fit testing. Journal of the American Statistical Association, 107(498), 777-787.
## 
## 
GRE SOL WIN GEO
Mean 0.039* 0.071* 0.053* 0.027
(0.055) (0.059) (0.082) (0.362)
Variance 1.311 4.39 2.934 2.852
Skewness -0.517*** -0.175*** -0.137*** 0.718***
(0.000) (0.000) (0.002) (0.000)
Ex.Kurtosis 9.089*** 4.599*** 3.734*** 14.437***
(0.000) (0.000) (0.000) (0.000)
JB 10990.261*** 2794.169*** 1840.851*** 27644.162***
(0.000) (0.000) (0.000) (0.000)
ERS -6.053 -9.569 -11.933 -11.570
(0.000) (0.000) (0.000) (0.000)
Q(20) 88.310*** 54.452*** 34.461*** 30.105***
(0.000) (0.000) (0.000) (0.000)
Q2(20) 2312.705*** 1585.716*** 247.003*** 324.849***
(0.000) (0.000) (0.000) (0.000)
kendall GRE SOL WIN GEO
GRE 1.000*** 0.483*** 0.360*** 0.309***
SOL 0.483*** 1.000*** 0.269*** 0.242***
WIN 0.360*** 0.269*** 1.000*** 0.185***
GEO 0.309*** 0.242*** 0.185*** 1.000***
spec = NULL
for (i in 1:k) {
  u = GARCHselection(Y[,i],
                     distributions=c("norm","std","sstd","ged","sged"),
                     models=c("sGARCH","gjrGARCH","eGARCH","iGARCH","AVGARCH","TGARCH"))
  spec = c(spec, u$best_ugarch)
}
## The optimal univariate GARCH selection procedure is implemented according to:
##  Antonakakis, N., Chatziantoniou, I., & Gabauer, D. (2021). The impact of Euro through time: Exchange rate dynamics under different regimes. International Journal of Finance & Economics, 26(1), 1375-1408.
## -sGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -gjrGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -eGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -iGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -AVGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -TGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## The optimal univariate GARCH selection procedure is implemented according to:
##  Antonakakis, N., Chatziantoniou, I., & Gabauer, D. (2021). The impact of Euro through time: Exchange rate dynamics under different regimes. International Journal of Finance & Economics, 26(1), 1375-1408.
## -sGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -gjrGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -eGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -iGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -AVGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -TGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## The optimal univariate GARCH selection procedure is implemented according to:
##  Antonakakis, N., Chatziantoniou, I., & Gabauer, D. (2021). The impact of Euro through time: Exchange rate dynamics under different regimes. International Journal of Finance & Economics, 26(1), 1375-1408.
## -sGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -gjrGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -eGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -iGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -AVGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -TGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## The optimal univariate GARCH selection procedure is implemented according to:
##  Antonakakis, N., Chatziantoniou, I., & Gabauer, D. (2021). The impact of Euro through time: Exchange rate dynamics under different regimes. International Journal of Finance & Economics, 26(1), 1375-1408.
## -sGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -gjrGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -eGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -iGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -AVGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
## -TGARCH
## --norm
## --std
## --sstd
## --ged
## --sged
fit = BivariateDCCGARCH(Y, spec)
H = fit$H_t
R = fit$R_t

uGARCH_table = NULL
for (i in 1:k) {
  fit = ugarchfit(spec[[i]], Y[,i])
  gt = GARCHtests(fit, lag=20)
  uGARCH_table = rbind(uGARCH_table, gt$TABLE)
}

Table 4: Evaluation of univariate GARCH performance

kable(uGARCH_table)
SignBias WARCH(20) VaR CVaR VaR Dur.
statistics 1.1110335 12.7748576 1.9553339 -678.0323 1.1146497
pvalues 0.2666388 0.2480858 0.1620132 0.9460 0.7695997
statistics 1.6177286 15.3280950 2.6728169 -686.6968 1.1337580
pvalues 0.1058213 0.1082819 0.1020752 0.9360 0.9334754
statistics 0.7533639 4.9271610 2.4216628 -683.8143 1.1273885
pvalues 0.4512876 0.9587172 0.1196678 0.8690 0.5395426
statistics 0.5100092 6.6085201 0.0010678 -627.9288 1.0063694
pvalues 0.6100808 0.8569645 0.9739319 0.6920 0.5833666

Figure 1: Dynamic conditional variance-covariances

par(mfcol = c(ceiling(k/2),2), oma = c(0, 0, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (j in 1:k) {
  plot(date,H[j,j,],type='l',las=1,xaxs='i',yaxs='i',xlab='',ylab='',main=paste(NAMES[j]),tck=-.02,col=j,ylim=c(-0.2,14))
  grid(NA,NULL)
  for (i in 1:k) {
    lines(date,H[j,i,],col=i)
    abline(h=0,lty=3)
  }
  box()
  legend("topleft",NAMES,fill=1:k,bty="n",cex=0.75,ncol=1)
}

Figure 3: Dynamic conditional correlations

par(mfcol = c(ceiling(k/2),2), oma = c(0, 1, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (j in 1:k) {
  plot(date,R[j,j,],type='l',las=1,xaxs='i',yaxs='i',xlab='',ylab='',main=paste(NAMES[j]),tck=-.02,col=j,ylim=c(-0.1,1))
  grid(NA,NULL)
  for (i in 1:k) {
    lines(date,R[j,i,],col=i)
    abline(h=0,lty=3)
    box()
  }
  legend("bottom",NAMES[-j],fill=c(1:k)[-j],bty="n",cex=0.75,ncol=k)
}

Table 5: Averaged connectedness measures

dca = R2Correlations(R)
kable(dca$TABLE)
GRE SOL WIN GEO FROM
GRE 100.00 29.53 15.47 9.93 54.93
SOL 31.42 100.00 8.71 6.30 46.42
WIN 17.38 8.95 100.00 3.58 29.92
GEO 11.25 6.58 3.62 100.00 21.45
TO 60.05 45.06 27.79 19.81 152.72
Inc.Own 160.05 145.06 127.79 119.81 cTCI/TCI
NET 5.12 -1.36 -2.13 -1.63 50.91/38.18
NPT 3.00 2.00 1.00 0.00

Figure 4: Dynamic conditional R2 decomposed measures

r2c = apply(dca$CT,c(1,3),sum)-1
par(mfcol = c(ceiling(k/2),2), oma = c(0, 1, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (j in 1:k) {
  r2dd = matrix(0,ncol=k,nrow=t)
  for (i in 1:t) {
    ded = rep(0,k)
    ded[j] = 1
    r2dd[i,] = cumsum(dca$CT[j,,i]-ded)
  }
  plot(date,100*r2c[j,]*NA,type="l",las=1,xlab="",ylab="",ylim=c(0,100),xaxs="i",tck=-0.01,yaxs="i",main=NAMES[j])
  grid(NA,NULL)
  for (i in k:1) {
    polygon(c(date, rev(date)), c(c(rep(0, t)), rev(100*r2dd[,i])), col=i, border=i)
  }
  box()
  legend("topleft",NAMES[-j],fill=c(1:k)[-j],bty="n",cex=0.75,ncol=1)
}

Figure 5: Dynamic total connectedness

par(mfcol = c(1,1), oma = c(0, 1, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
plot(date,dca$TCI*NA,type='l',las=1,xaxs='i',yaxs='i',xlab='',ylab='',main='',tck=-.01, ylim=c(0,80))#c(max(c(0,min(TCI)-10)),max(TCI)+10))
grid(NA,NULL)
polygon(c(date, rev(date)), c(c(rep(0, t)), rev(dca$TCI)), col=1, border=1)
box()

Figure 6: Net total directional connectedness

par(mfcol = c(ceiling(k/2),2), oma = c(0, 0, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (i in 1:k) {
  plot(date,dca$NET[,i]*NA,type='l',las=1,xaxs='i',yaxs='i',ylim=c(-20,20),xlab='',ylab='',main=paste("NET",NAMES[i]),tck=-.025)
  grid(NA,NULL)
  polygon(c(date, rev(date)), c(c(rep(0, t)), rev(dca$NET[,i])), col=1, border=1)
  abline(h=0,lty=3)
  box()
}

Table 7: Hedge ratios

method = "cumsum"
statistics = "Fisher"
metric = "StdDev"
hr = HedgeRatio(Y/100, H, statistics=statistics, method=method, metric=metric, digit=3)
## Hedge ratios are implemented according to:
##  Kroner, K. F., & Sultan, J. (1993). Time-varying distributions and dynamic hedging with foreign currency futures. Journal of Financial and Quantitative Analysis, 28(4), 535-551.
## 
##           Hedging effectiveness is calculated according to:
##  Ederington, L. H. (1979). The hedging performance of the new futures markets. The Journal of Finance, 34(1), 157-170.
## 
##           Statistics of the hedging effectiveness measure are implemented according to:
##  Antonakakis, N., Cunado, J., Filis, G., Gabauer, D., & de Gracia, F. P. (2020). Oil and asset classes implied volatilities: Investment strategies and hedging effectiveness. Energy Economics, 91, 104762.
kable(hr$TABLE)
Mean Std.Dev. 5% 95% HE p-value Return Std.Dev SR
GRE/SOL 0.336 0.146 0.144 0.612 0.536 0.000 0.057 0.124 0.460
GRE/WIN 0.308 0.114 0.165 0.533 0.345 0.004 0.058 0.147 0.391
GRE/GEO 0.290 0.149 0.108 0.593 0.278 0.000 0.083 0.154 0.537
SOL/GRE 1.400 0.440 0.734 2.194 0.468 0.000 -0.015 0.243 -0.064
SOL/WIN 0.472 0.174 0.224 0.824 0.195 0.004 0.063 0.298 0.210
SOL/GEO 0.459 0.212 0.170 0.841 0.169 0.000 0.117 0.303 0.386
WIN/GRE 0.950 0.338 0.477 1.614 0.280 0.000 0.010 0.231 0.044
WIN/SOL 0.352 0.163 0.127 0.644 0.205 0.000 0.070 0.242 0.290
WIN/GEO 0.325 0.149 0.150 0.624 0.098 0.000 0.089 0.258 0.344
GEO/GRE 0.696 0.300 0.274 1.207 0.227 0.000 -0.045 0.236 -0.190
GEO/SOL 0.264 0.124 0.087 0.497 0.176 0.000 -0.021 0.243 -0.087
GEO/WIN 0.255 0.105 0.126 0.457 0.098 0.004 -0.002 0.255 -0.007

Table 8: Multivariate hedging portfolios

mhp = MultivariateHedgingPortfolio(Y/100, H, statistics=statistics, method=method, digit=3)
kable(mhp$TABLE)
Mean Std.Dev. 5% 95% HE p-value Return Risk SR
GRE/SOL 0.251 0.123 0.086 0.490 0.605 0.000 0.042 0.114 0.364
GRE/WIN 0.158 0.054 0.086 0.264 0.605 0.000 0.042 0.114 0.364
GRE/GEO 0.122 0.074 0.021 0.257 0.605 0.000 0.042 0.114 0.364
SOL/GRE 1.234 0.492 0.571 2.154 0.474 0.000 -0.013 0.241 -0.055
SOL/WIN 0.090 0.170 -0.173 0.353 0.474 0.000 -0.013 0.241 -0.055
SOL/GEO 0.088 0.136 -0.126 0.317 0.474 0.000 -0.013 0.241 -0.055
WIN/GRE 0.804 0.351 0.304 1.383 0.291 0.000 0.025 0.229 0.107
WIN/SOL 0.094 0.168 -0.168 0.397 0.291 0.000 0.025 0.229 0.107
WIN/GEO 0.064 0.076 -0.049 0.208 0.291 0.000 0.025 0.229 0.107
GEO/GRE 0.521 0.288 0.119 1.003 0.228 0.000 -0.050 0.236 -0.214
GEO/SOL 0.083 0.119 -0.101 0.289 0.228 0.000 -0.050 0.236 -0.214
GEO/WIN 0.059 0.074 -0.046 0.184 0.228 0.000 -0.050 0.236 -0.214

Figure 3: Dynamic conditional betas

par(mfcol = c(ceiling(k/2),2), oma = c(0, 1, 0, 0) + 0.5, mar = c(1, 1, 1, 1) + 0.5, mgp = c(1, 0.4, 0))
for (j in 1:k) {
  plot(date,mhp$Beta[j,j,]*NA,type='l',las=1,xaxs='i',yaxs='i',xlab='',ylab='',
       main=paste(NAMES[j]),tck=-.02,col=j,ylim=c(-0.5,3))
  grid(NA,NULL)
  coefs = lm(Y[,j]~Y[,-j])$coefficients[-1]
  for (i in 1:k) {
    if (i!=j) {
      lines(date,mhp$Beta[j,i,],col=i)
      abline(h=0,lty=3)
      box()
    }
  }
  col = 1:k
  col = col[-j]
  abline(h=coefs,lty=3,col=col)
  legend("bottom",NAMES[-j],fill=c(1:k)[-j],bty="n",cex=0.6,ncol=k)
}