Introducing connectedness: TVP-VAR and Diebold-Yilmaz Connectedness Measures for Stata
StataConnectednessTVP-VARSpilloversDiebold-YilmazEconometricsFinancial NetworksOpen Source

Introducing connectedness: TVP-VAR and Diebold-Yilmaz Connectedness Measures for Stata

Prof. Dr. Nikolaos Antonakakis
789 views

connectedness is a new, free Stata package for static, rolling-window and TVP-VAR connectedness measures, with corrected, pairwise, group and asymmetric indices, graphs and network plots, and step-by-step examples that replicate published studies.

I am happy to share connectedness, a new Stata package that estimates the connectedness measures of the Diebold and Yilmaz framework and its time-varying parameter extensions. With one command you can move from a static spillover table to rolling-window measures and to TVP-VAR connectedness with the corrected total, pairwise and influence indices, and then draw the results as time-series graphs or network plots.

The package is free and open source (GPL-3), runs on Stata 16.1 or newer, and is available on GitHub: https://github.com/Nikosanton82/connectedness-stata.

Stata Journal submission. The article that describes the package, connectedness: Static, rolling-window, and time-varying parameter connectedness measures, has just been submitted to the Stata Journal. Until it is reviewed, please cite the GitHub repository (see the citation section at the end of this post).

Connectedness in a nutshell

Connectedness measures ask a simple question: when one variable is hit by a shock, how much of the forecast error variance of the other variables does that shock explain? The answer comes from the forecast error variance decomposition (FEVD) of a vector autoregression (VAR). Collecting the shares wij (the part of variable i's forecast error variance due to shocks in variable j) in a table gives the full map of spillovers in a system.

From this table the framework builds a family of measures:

  • TO and FROM: how much a variable transmits to, and receives from, all others.
  • NET = TO − FROM: positive values mark net transmitters of shocks, negative values net receivers.
  • NPDC, the net pairwise directional connectedness between two variables, and NPT, the number of other variables that a variable dominates.
  • TCI, the total connectedness index, which summarizes the degree of interconnection of the whole system.

The literature that the package covers developed in four steps:

ContributionWhat it addsIn the package
Diebold and Yilmaz (2009, 2012)Spillover tables from a VAR, with the generalized FEVD of Koop, Pesaran and Potter (1996) and Pesaran and Shin (1998) so that results do not depend on the ordering of the variables; directional and net measuresmodel(var), generalized or orthogonalized
Rolling-window VARTime-varying measures from a VAR re-estimated on moving windowswindow(#)
Antonakakis, Chatziantoniou and Gabauer (2020)A TVP-VAR estimated with a Kalman filter and forgetting factors: no lost observations, no arbitrary window and less sensitivity to outliersmodel(tvpvar), kappa1(), kappa2(), prior()
Chatziantoniou and Gabauer (2021); Gabauer (2021)A corrected TCI that lies between 0 and 100, the pairwise connectedness index (PCI) and the pairwise influence indexcorrected, stored ctci, pci_i_j, inf_i_j

For readers who like formulas: with k variables, TCI = (1/k) Σi FROMi and the corrected index is TCI × k/(k−1). For a pair of variables i and j, PCIij = 200 (wij + wji) / (wii + wij + wji + wjj) and the influence index is 100 |wij − wji| / (wij + wji).

What the package does

Three estimators

Static VAR, rolling-window VAR and TVP-VAR with Bayes, Minnesota or uninformative priors.

Generalized or Cholesky FEVD

Generalized decomposition by default; orthogonalized (Cholesky) on request.

Full set of measures

TO, FROM, NET, NPDC, NPT, TCI, corrected TCI, PCI and the influence index, period by period.

Group measures

Aggregated, conditional, inclusive, exclusive, internal and external connectedness with estat group.

Asymmetric connectedness

Separate systems for positive and negative changes with the asymmetric option.

Graphs and networks

cngraph for time-varying measures and cnnetwork for network plots.

Results you can reuse

Every measure is stored in a Stata frame with dates and in e() matrices.

18 replication datasets

Data from 18 published applications are installed with the package.

Installation

Install the package directly from GitHub. Run the lines below together from a do-file, so that the local macro repo is defined when the commands use it. net get copies the replication datasets into your current working directory, so change to a project folder first.

* where the package lives
local repo "https://raw.githubusercontent.com/Nikosanton82/connectedness-stata/main"

* install (or update) the commands and help files
net install connectedness, from("`repo'") replace

* copy the 18 example datasets (cn_*.dta) to the current folder
cd "C:/my/project/folder"
net get connectedness, from("`repo'")

* read the help files
help connectedness
help connectedness postestimation
help cngraph
help cnnetwork

Before estimation, the data must be tsset and the estimation sample must be contiguous in time. Each example dataset is ready to tsset through the index variable t (monthly data also carry month) and has a date variable for nicer graph axes.

Step-by-step examples

The examples below replicate published studies with the datasets that come with the package. You can copy each block into a do-file and run it as is. Graph options such as title() and legend() are standard Stata options and are optional.

1A static spillover table: Diebold and Yilmaz (2012)

The first example uses the daily volatilities of US stocks, bonds, commodities and the dollar from Diebold and Yilmaz (2012). A VAR(4) with a 10-step horizon gives the static connectedness table:

use cn_dy2012, clear
tsset t
connectedness SP500 R_10Y DJUBSCOM USDX, lags(4) horizon(10) datevar(date)
Connectedness approach                          Number of variables =        4
Model:  VAR(4), static                          Forecast horizon    =       10
FEVD:   generalized                             Observations used   =     2771
Sample: 25jan1999 to 29jan2010                  Periods measured    =        1

-------------+-------------------------------------------------
             |    SP500     R_10Y  DJUBSCOM      USDX      FROM
-------------+-------------------------------------------------
       SP500 |    88.76      7.29      0.35      3.61     11.24
       R_10Y |    10.21     81.45      2.73      5.61     18.55
    DJUBSCOM |     0.47      3.70     93.69      2.14      6.31
        USDX |     5.69      7.03      1.55     85.73     14.27
          TO |    16.37     18.01      4.62     11.36     50.37
     Inc_Own |   105.13     99.46     98.31     97.10
         NET |     5.13     -0.54     -1.69     -2.90     12.59
         NPT |     3.00      2.00      0.00      1.00
-------------+-------------------------------------------------
Rows: variance of the row variable explained by the column variable (percent).
TCI =  12.59    corrected TCI =  16.79

Read the table row by row: 10.21% of the forecast error variance of bond volatility is due to shocks in stocks. The stock market is the main net transmitter (NET = 5.13) and the dollar is the main net receiver (−2.90). The total connectedness index is 12.59%, or 16.79% once corrected.

2Rolling-window connectedness

Adding window(200) re-estimates the VAR on 200-day windows. The frame() option names the Stata frame that will hold the time-varying measures, and notable suppresses the table of averages. cngraph tci then plots the total connectedness index over time.

connectedness SP500 R_10Y DJUBSCOM USDX, lags(4) horizon(10) ///
    window(200) datevar(date) frame(dy2012) replace notable
cngraph tci, title("Total connectedness, rolling VAR(4), 200-day windows")
Rolling-window total connectedness index, 1999 to 2010
Figure 1. Rolling-window TCI for the Diebold and Yilmaz (2012) data. The index averages 16.5%, falls to about 7% in June 2002 and peaks at 34.3% on 19 March 2008, in the run-up to the global financial crisis.

3TVP-VAR connectedness: Antonakakis, Chatziantoniou and Gabauer (2020)

The TVP-VAR replaces the moving window by a Kalman filter with a forgetting factor kappa1() for the coefficients and a decay factor kappa2() for the error covariance. With model(tvpvar), window() sets the size of the training sample for the prior. The example below uses monthly exchange rates of the euro, pound, yen and Swiss franc against the dollar, and compares the TVP-VAR index with rolling windows of 50, 100 and 200 months. Stored estimates are overlaid with the compare() option.

use cn_acg2020, clear
tsset month

* rolling-window benchmarks, stored for comparison
foreach w in 50 100 200 {
    quietly connectedness EUR GBP JPY CHF, horizon(12) ///
        window(`w') frame(roll`w') replace
    estimates store roll`w'
}

* TVP-VAR with forgetting factor 0.99 and decay factor 0.96
connectedness EUR GBP JPY CHF, model(tvpvar) horizon(12) window(200) ///
    kappa1(0.99) kappa2(0.96) datevar(date) frame(acg_tvp) replace

cngraph tci, compare(roll50 roll100 roll200) ///
    title("TVP-VAR versus rolling-window TCI") legend(position(6) rows(1))
TVP-VAR and rolling-window total connectedness for four currencies
Figure 2. TVP-VAR and rolling-window TCIs. The TVP-VAR series starts at the first observation, while each rolling series loses a full window, and longer windows give visibly smoother and more delayed paths.

On average, the TCI is 52.06% (69.42% corrected). The euro (NET = 7.27) and the Swiss franc (9.85) are net transmitters, while the pound and the yen are net receivers. Two more graphs are one line each:

cngraph net                 // net total directional connectedness, one panel per currency
cngraph npdc, select(EUR)   // net pairwise connectedness, only the pairs with EUR

4Corrected TCI, pairwise connectedness and a network plot: Chatziantoniou and Gabauer (2021)

The corrected option reports the corrected TCI, which lies between 0 and 100. The results frame stores the pairwise connectedness index pci_i_j and the influence index inf_i_j for every pair, and cnnetwork draws the average network of net pairwise connectedness. Here the data are 10-year government bond yields of 11 euro area countries.

use cn_cg2021, clear
tsset t
connectedness Austria-Spain, model(tvpvar) window(200) corrected ///
    datevar(date) frame(cg2021) replace notable

* pairwise connectedness: Germany-Ireland and Netherlands-Spain
frame cg2021: summarize ctci pci_5_7 pci_9_11

cnnetwork, threshold(0.25) legend(position(6) rows(1))
Network of net pairwise directional connectedness among euro area bond yields
Figure 3. Net pairwise directional connectedness, averaged over 2003 to 2018. Filled circles are net transmitters, hollow circles net receivers; arrows point from transmitter to receiver and wider arrows mean stronger links. threshold(0.25) hides the weakest links.

The TCI is 77.72%, or 85.50% after the correction. Core countries such as Germany, the Netherlands, Belgium and Finland transmit shocks to the rest of the system, while Greece and Portugal are the largest net receivers. The pairwise index separates strongly linked pairs (Netherlands and Spain, mean PCI 84) from weakly linked ones (Germany and Ireland, mean PCI 40). Use cnnetwork, method(pci) to draw the PCI network instead, or cnnetwork, at(td(15sep2008)) for a single date.

5Internal and external connectedness: Gabauer and Gupta (2018)

Group measures are computed after estimation with estat group. Each group is written as "name: variables". Internal connectedness keeps only spillovers within each group, and external connectedness only those between groups; the two add up to the total. This example uses fiscal, monetary, trade and currency policy uncertainty for the United States and Japan.

use cn_gg2018, clear
tsset month
connectedness US_FPU-JP_CPU, model(tvpvar) window(200) datevar(date) ///
    frame(gg2018) replace notable

local US "US: US_FPU US_MPU US_TPU US_CPU"
local JP "JP: JP_FPU JP_MPU JP_TPU JP_CPU"
estat group, type(internal) groups("`US'" "`JP'") frame(gg_int) replace
estat group, type(external) groups("`US'" "`JP'") frame(gg_ext) replace notable

cngraph gtci, frame(gg_int) ///
    title("Internal connectedness: United States and Japan") legend(position(6) rows(1))
Internal group connectedness for the United States and Japan
Figure 4. Group TCIs of internal connectedness. Japan's internal index jumps to about 14% in August 2011.

The total TCI of 27.27% splits into 18.97% internal and 8.30% external connectedness, so most uncertainty spillovers stay within each country.

6Conditional and aggregated connectedness: Stenfors, Chatziantoniou and Gabauer (2022)

Conditional connectedness looks only inside one group, and aggregated connectedness treats each group as a single unit. The data are 2-, 5- and 10-year government bond yields for six European currencies, 18 series in all.

use cn_cgs2022, clear
tsset t
connectedness X2YCHF-X10YSEK, model(tvpvar) window(250) corrected ///
    datevar(date) frame(cgs2022) replace notable

* connectedness within the Norwegian yield curve
estat group, type(conditional) groups(X2YNOK X5YNOK X10YNOK) ///
    frame(cgs_nok) replace notable

* one node per currency
estat group, type(aggregated) frame(cgs_cur) replace digits(1) ///
    groups("CHF: X2YCHF X5YCHF X10YCHF" "DKK: X2YDKK X5YDKK X10YDKK" ///
    "EUR: X2YEUR X5YEUR X10YEUR" "GBP: X2YGBP X5YGBP X10YGBP" ///
    "NOK: X2YNOK X5YNOK X10YNOK" "SEK: X2YSEK X5YSEK X10YSEK")

cnnetwork, frame(cgs_cur) ///
    title("Aggregated connectedness between six currencies") legend(position(6) rows(1))
Aggregated connectedness network between six European currencies
Figure 5. Aggregated connectedness between the yield curves of six currencies.

The aggregated TCI is 66.2% (79.5% corrected). The euro curve is the largest net transmitter (NET = 15.3), followed by the Danish krone (9.2), while the Norwegian krone is the largest net receiver (−15.1).

7Inclusive and exclusive connectedness: Chatziantoniou, Elsayed, Gabauer and Gozgor (2023)

Inclusive connectedness keeps every spillover that involves a group, and exclusive connectedness removes it. This example also shows the Minnesota prior with tightness gamma(0.1).

use cn_cegg2022, clear
tsset t
connectedness Demand_Shock-Japan, model(tvpvar) horizon(20) ///
    prior(minnesota) gamma(0.1) corrected datevar(date) frame(cegg) replace notable

local oil Demand_Shock Supply_Shock Risk_Shock
estat group, type(inclusive) groups(`oil') frame(cegg_inc) replace notable
estat group, type(exclusive) groups(`oil') frame(cegg_exc) replace notable

The TCI of 36.57% splits into 16.09% that involves the three oil shocks and 20.48% that does not.

8Asymmetric connectedness: Adekoya et al. (2022)

With asymmetric, the package also estimates separate systems for the positive and the negative changes of the variables, so that you can see whether bad news spreads more than good news. The data are crude oil prices and Islamic sectoral stock indices.

use cn_aaacgo2022, clear
tsset t
foreach v of varlist Brent-UTI {
    quietly generate double r_`v' = 100*(`v' - L.`v')/L.`v'
}
connectedness r_*, model(tvpvar) prior(minnesota) gamma(0.1) ///
    asymmetric datevar(date) frame(aaacgo) replace notable

connectedness, part(negative)   // table for the negative changes
cngraph tci, title("Total connectedness of all, positive and negative returns") ///
    legend(position(6) rows(1))
Total connectedness of all, positive and negative returns
Figure 6. Asymmetric TCIs. Connectedness of negative returns exceeds that of positive returns on 95% of the days.

On average, the TCI is 72.69% for all returns, 69.89% for positive returns and 74.41% for negative returns.

Working with the results

Nothing is hidden inside the graphs. Each estimation leaves its measures in a frame with one row per period (tci, ctci, to_i, from_i, net_i, npt_i, npdc_i_j, pci_i_j, inf_i_j and, by default, the full decomposition fevd_i_j), where i and j index the variables in the order you listed them and variable labels carry the names. The averaged tables are in e(table) and e(fevd).

ereturn list                                   // all stored results
matrix list e(table)                           // averaged connectedness table
frame acg_tvp: describe                        // the time-varying measures
frame acg_tvp: list date tci ctci net_1 in 1/5
frame acg_tvp: export excel using tvp_results.xlsx, firstrow(variables) replace

Because the measures are ordinary Stata variables, you can merge them with other data, run regressions on them or plot them with any twoway command.

Checked against the R package

The package is a port of David Gabauer's R package ConnectednessApproach (version 1.0.4), and I am grateful for that work. It follows the same conventions, so the results are directly comparable. Across 24 test cases (static, rolling and TVP-VAR models, generalized and orthogonalized decompositions, the three priors, group and asymmetric measures), the Stata results agree with the R results to a relative difference below 10−9, the largest being 5.4 × 10−10. A certification script with 64 tests is included in the test/ folder of the repository, so you can rerun the checks yourself.

How it was built

The package was developed with the assistance of Claude Code. I guided the work, reviewed, corrected and proofread everything, tested it, and confirmed that it matches the results of the R package.

What comes next

This first release covers the time-domain connectedness approach. Further extensions of the methodology will be added in newer versions, including:

  • Quantile connectedness (Ando, Greenwood-Nimmo and Shin 2022), to study spillovers in the tails of the distribution;
  • Frequency connectedness (Baruník and Křehlík 2018), to separate short-run from long-run spillovers;
  • Joint and extended joint connectedness;
  • R²-decomposed connectedness;
  • Regularized VARs (LASSO, ridge and elastic net) for large systems.

How to cite

If you use the package in your research, please cite the repository:

Antonakakis, N. (2026). connectedness: Static, rolling-window and TVP-VAR connectedness measures for Stata (Version 0.2.1) [Computer software]. GitHub. https://github.com/Nikosanton82/connectedness-stata
@software{antonakakis2026connectedness,
  author  = {Antonakakis, Nikolaos},
  title   = {connectedness: Static, rolling-window and {TVP-VAR} connectedness measures for {Stata}},
  year    = {2026},
  version = {0.2.1},
  url     = {https://github.com/Nikosanton82/connectedness-stata}
}

Please also cite the methodological papers behind the measures you report (listed below) and the ConnectednessApproach R package on which the implementation is based.

Feedback and feature requests

This is version 0.2.1, and your feedback will shape the next releases. If you find a bug, have a question, or would like to see a feature or a model in a future version, please open an issue on GitHub Issues or get in touch with me directly. Results from your own applications, good or bad, are just as welcome.

References

  1. Adekoya, O. B., Akinseye, A. B., Antonakakis, N., Chatziantoniou, I., Gabauer, D., and Oliyide, J. (2022). Crude oil and Islamic sectoral stocks: Asymmetric TVP-VAR connectedness and investment strategies. Resources Policy, 78, 102877. https://doi.org/10.1016/j.resourpol.2022.102877
  2. Ando, T., Greenwood-Nimmo, M., and Shin, Y. (2022). Quantile connectedness: Modeling tail behavior in the topology of financial networks. Management Science, 68, 2401–2431. https://doi.org/10.1287/mnsc.2021.3984
  3. Antonakakis, N., Chatziantoniou, I., and Gabauer, D. (2020). Refined measures of dynamic connectedness based on time-varying parameter vector autoregressions. Journal of Risk and Financial Management, 13, 84. https://doi.org/10.3390/jrfm13040084
  4. Baruník, J., and Křehlík, T. (2018). Measuring the frequency dynamics of financial connectedness and systemic risk. Journal of Financial Econometrics, 16, 271–296. https://doi.org/10.1093/jjfinec/nby001
  5. Chatziantoniou, I., Elsayed, A. H., Gabauer, D., and Gozgor, G. (2023). Oil price shocks and exchange rate dynamics: Evidence from decomposed and partial connectedness measures for oil importing and exporting economies. Energy Economics, 120, 106627. https://doi.org/10.1016/j.eneco.2023.106627
  6. Chatziantoniou, I., and Gabauer, D. (2021). EMU risk-synchronisation and financial fragility through the prism of dynamic connectedness. Quarterly Review of Economics and Finance, 79, 1–14. https://doi.org/10.1016/j.qref.2020.12.003
  7. Diebold, F. X., and Yilmaz, K. (2009). Measuring financial asset return and volatility spillovers, with application to global equity markets. Economic Journal, 119, 158–171. https://doi.org/10.1111/j.1468-0297.2008.02208.x
  8. Diebold, F. X., and Yilmaz, K. (2012). Better to give than to receive: Predictive directional measurement of volatility spillovers. International Journal of Forecasting, 28, 57–66. https://doi.org/10.1016/j.ijforecast.2011.02.006
  9. Gabauer, D. (2021). Dynamic measures of asymmetric & pairwise connectedness within an optimal currency area: Evidence from the ERM I system. Journal of Multinational Financial Management, 60, 100680. https://doi.org/10.1016/j.mulfin.2021.100680
  10. Gabauer, D. (2025). ConnectednessApproach: Connectedness approach. R package version 1.0.4. https://CRAN.R-project.org/package=ConnectednessApproach
  11. Gabauer, D., and Gupta, R. (2018). On the transmission mechanism of country-specific and international economic uncertainty spillovers: Evidence from a TVP-VAR connectedness decomposition approach. Economics Letters, 171, 63–71. https://doi.org/10.1016/j.econlet.2018.07.007
  12. Koop, G., Pesaran, M. H., and Potter, S. M. (1996). Impulse response analysis in nonlinear multivariate models. Journal of Econometrics, 74, 119–147. https://doi.org/10.1016/0304-4076(95)01753-4
  13. Pesaran, M. H., and Shin, Y. (1998). Generalized impulse response analysis in linear multivariate models. Economics Letters, 58, 17–29. https://doi.org/10.1016/S0165-1765(97)00214-0
  14. Stenfors, A., Chatziantoniou, I., and Gabauer, D. (2022). Independent policy, dependent outcomes: A game of cross-country dominoes across European yield curves. Journal of International Financial Markets, Institutions and Money, 81, 101658. https://doi.org/10.1016/j.intfin.2022.101658

Share this post

Written by

Prof. Dr. Nikolaos Antonakakis