connectedness for Stata, Part 2: Frequency, Quantile, R², LASSO and DCC-GARCH Connectedness
StataConnectednessTVP-VARSpilloversFrequency ConnectednessQuantile VARLASSODCC-GARCHEconometricsFinancial NetworksOpen Source

connectedness for Stata, Part 2: Frequency, Quantile, R², LASSO and DCC-GARCH Connectedness

Prof. Dr. Nikolaos Antonakakis
205 views

Version 0.7.2 of the free connectedness package for Stata adds frequency, joint, quantile, R² decomposed, LASSO, ridge, elastic-net and DCC-GARCH connectedness, plus redesigned network plots, with worked examples and checks against the R package.

In Part 1, I introduced connectedness, a free Stata package for the connectedness measures of Diebold and Yilmaz and their TVP-VAR extensions. That post ended with a list of extensions for future versions. They are now all in the package, together with DCC-GARCH volatility connectedness and a new look for the graphs.

This post walks through each new model with one worked example, using the datasets that ship with the package. Every number and figure below comes from running these examples in Stata 19 with version 0.7.2.

New to the package? Start with Part 1: Introducing connectedness, which explains the connectedness measures (TO, FROM, NET, NPDC, TCI and the corrected TCI) and covers static, rolling-window and TVP-VAR connectedness, group measures and asymmetric connectedness.

What is new since Part 1

Frequency connectedness

Short-run and long-run spillovers (Baruník and Křehlík 2018), also with a TVP-VAR, with approach(frequency).

Joint and extended joint

The joint spillover index of Lastrapes and Wiesen (2021) and extended joint connectedness of Balcilar, Gabauer and Umar (2021).

Quantile and LAD VARs

Connectedness in the tails with model(qvar), quantile-on-quantile connectedness, and a least absolute deviation VAR with model(lad).

R² and model-free

R² decomposed connectedness with contemporaneous and lagged parts, and model-free connectedness from squared correlations.

LASSO, ridge and elastic net

Penalized VARs with the penalty chosen by cross-validation, for large systems such as 51 housing markets.

DCC-GARCH

Volatility connectedness from a DCC-GARCH(1,1) model and its volatility impulse responses (Gabauer 2020).

New graphics

Curved, weighted network arrows, colored transmitters and receivers, and time-series graphs with dates on the axis.

Validated against R

40 new comparison cases with ConnectednessApproach; 151 certification tests pass in Stata 19.

The extensions arrived in five releases:

VersionWhat it adds
0.3.0Frequency, joint and extended joint connectedness
0.4.0Quantile VAR (including quantile-on-quantile) and LAD VAR
0.5.0R² decomposed and model-free connectedness
0.6.0LASSO, ridge and elastic-net VARs
0.7.0 to 0.7.2DCC-GARCH volatility connectedness, redesigned network plots and graphs, dates on graph axes

Install or update

If you installed the package after Part 1, the same command updates it. net get copies the 18 example datasets into the current working directory.

net install connectedness, from("https://raw.githubusercontent.com/Nikosanton82/connectedness-stata/main") replace
net get connectedness, from("https://raw.githubusercontent.com/Nikosanton82/connectedness-stata/main")
which connectedness      // should report version 0.7.2

All new models use the same command, connectedness, and the same postestimation tools, so cngraph, cnnetwork and the results frame work exactly as in Part 1.

Worked examples

1Frequency connectedness: short run versus long run

Spillovers can be fast or slow. The approach of Baruník and Křehlík (2018) splits the forecast error variance decomposition by frequency, so the TCI becomes the sum of a short-run and a long-run part. Chatziantoniou, Gabauer and Gupta (2023) combine it with a TVP-VAR. The example uses daily crude oil prices in six markets from 1996 to 2020. bands(5) sets one band of 1 to 5 days and one of more than 5 days (partition() sets the bands in radians instead).

use cn_cgg2022, clear
tsset t
connectedness Europe-OPEC, model(tvpvar) lags(1) horizon(100) window(200) ///
    approach(frequency) bands(5) datevar(date) frame(f_freq) replace
connectedness, band(1)          // the table of the short-run band
cngraph tci, legend(order(1 "Total" 2 "Short run (1 to 5 days)" 3 "Long run (over 5 days)"))
Band (periods)           TCI   corrected TCI
--------------------------------------------
1-5                    37.31           44.78
5-Inf                  22.55           27.05
--------------------------------------------
Total                  59.86           71.83
Total, short-run and long-run connectedness of six crude oil markets
Figure 1. TVP-VAR frequency connectedness of crude oil prices. Short-run spillovers usually dominate, but between 2013 and 2015 the long-run band rose to about 70% while the short-run band fell below 10%.

On average, 37.31 of the 59.86 percentage points of total connectedness come from the short run. Malaysia is the main net receiver in both bands. The two bands always add up to the total, so the figure shows when persistent shocks, rather than daily noise, drive the system.

The same estimation works with static and rolling VARs, and scenario(wth) reports within-band instead of absolute measures. Joint connectedness and extended joint connectedness use the same syntax:

* joint connectedness, Lastrapes and Wiesen (2021)
use cn_lw2021, clear
tsset t
connectedness energy-utilities, lags(2) horizon(30) approach(joint) replace

* extended joint connectedness, Balcilar, Gabauer and Umar (2021)
use cn_bgu2021, clear
tsset t
connectedness CrudeOil-Wheat, model(tvpvar) horizon(20) prior(minnesota) gamma(0.1) ///
    approach(extjoint) datevar(date) replace

2Quantile connectedness: what happens in the tails

A standard VAR describes the average response to shocks. A quantile VAR estimates each equation by quantile regression, so connectedness can be measured for large negative shocks (a low quantile), for large positive shocks (a high quantile) or around the median (Chatziantoniou, Gabauer and Stenfors 2021; see also Ando, Greenwood-Nimmo and Shin 2022). The example uses daily 1-year interest rate swap rates in US dollars, euros, pounds and yen, with 200-day rolling windows and the corrected TCI.

use cn_cgs2021, clear
tsset t
foreach q in 0.05 0.95 0.5 {
    local s = 100*`q'
    connectedness USD1Y EUR1Y GBP1Y JPY1Y, model(qvar) quantile(`q') lags(1) ///
        horizon(20) window(200) corrected datevar(date) frame(f_q`s') replace
    estimates store q`s'
}
cngraph tci, compare(q5 q95) ///
    legend(order(1 "Median (tau = 0.5)" 2 "Lower tail (tau = 0.05)" 3 "Upper tail (tau = 0.95)"))
Corrected total connectedness at the median and in both tails
Figure 2. Corrected TCI of interest rate swaps at three quantiles. Connectedness in the tails stays between about 65% and 100%, far above the median, which ranges from about 5% to 50%.

The average corrected TCI is 27.87% at the median but 85.05% in the lower tail and 84.23% in the upper tail. Large shocks, of either sign, spread across these markets far more than ordinary ones, which a mean-based VAR would miss.

Two related options: model(lad) estimates a least absolute deviation VAR, and quantile() with one value per variable gives quantile-on-quantile connectedness (Gabauer and Stenfors 2024), for example quantile(0.05 0.05 0.95 0.95).

3R² decomposed connectedness: contemporaneous and lagged spillovers

R² decomposed connectedness (Naeem et al. 2024) does not use a forecast error variance decomposition. It splits the R² of a regression of each variable on all the others, so each share is the part of a variable's variation explained by another variable. With lags() above zero, Balli et al. (2023) add the lagged values, and the TCI splits into a contemporaneous and a lagged part. The data are the volatilities of US stocks, bonds, commodities and the dollar from Diebold and Yilmaz (2012), as in Part 1.

use cn_dy2012, clear
tsset t
connectedness SP500 R_10Y DJUBSCOM USDX, approach(r2) lags(1) window(200) ///
    datevar(date) frame(f_r2) replace
connectedness, component(lagged)     // the table of the lagged part
cngraph tci
Component                TCI   corrected TCI
--------------------------------------------
Contemporaneous         9.86           13.15
Lagged                  3.04            4.06
--------------------------------------------
Overall                12.90           17.21
Overall, contemporaneous and lagged R-squared connectedness
Figure 3. Rolling R² connectedness with one lag. The overall TCI peaks at about 36% in late 2008, and most of the rise is contemporaneous.

About three quarters of the spillovers are contemporaneous: markets react within the same day. The lagged part is small but rises in the 2008 crisis, when shocks also took longer to work through the system.

approach(modelfree) gives the model-free measures of Gabauer, Chatziantoniou and Stenfors (2023), built from squared correlations, and cormethod(pearson|spearman|kendall) chooses the correlation for both approaches.

4LASSO, ridge and elastic-net VARs for large systems

With many variables, a VAR has more coefficients than the data can pin down. Gabauer, Gupta, Marfatia and Miller (2024) estimate the VAR equations with a LASSO, ridge or elastic-net penalty, chosen by 10-fold cross-validation. model(lasso), model(ridge) and model(elasticnet) reproduce R's glmnet (Friedman, Hastie and Tibshirani 2010) and cv.glmnet(), and seed() makes the random folds reproducible. The first example compares rolling LASSO and ridge VARs with the TVP-VAR on the four exchange rates of Part 1.

use cn_acg2020, clear
tsset month
connectedness EUR GBP JPY CHF, model(lasso) horizon(12) window(200) seed(2024) frame(f_lasso) replace
estimates store LASSO
connectedness EUR GBP JPY CHF, model(ridge) horizon(12) window(200) seed(2024) frame(f_ridge) replace
estimates store ridge
connectedness EUR GBP JPY CHF, model(tvpvar) horizon(12) window(200) kappa2(0.96) frame(f_tvp) replace
cngraph tci, compare(LASSO ridge) ///
    legend(order(1 "TVP-VAR" 2 "Rolling LASSO VAR" 3 "Rolling ridge VAR"))
TVP-VAR, rolling LASSO and rolling ridge total connectedness of four currencies
Figure 4. TCI of four exchange rates from a TVP-VAR and from rolling LASSO and ridge VARs. With only four variables and one lag, the LASSO and ridge estimates are very close, so their paths almost coincide.

The average TCI is 53.08% with LASSO, 53.04% with ridge and 52.06% with the TVP-VAR. The rolling estimates are smoother and start only after the first 200 months, while the TVP-VAR follows turning points more closely.

Penalization matters most in large systems. The second example estimates a LASSO VAR for monthly house prices in the 50 US states and the District of Columbia, 51 variables in all, and draws the strongest links:

use cn_gghm2022, clear
tsset t
connectedness AK-WY, model(lasso) lags(1) horizon(10) seed(2024) nofevd notable ///
    datevar(date) frame(f_states) replace
cnnetwork, threshold(0.5)
Network of net pairwise connectedness among 51 US housing markets
Figure 5. LASSO VAR network of 51 housing markets (TCI 86.15%, corrected 87.88%). Only links stronger than half the largest one are drawn, so the main channels stand out. With many variables, cnnetwork places the names outside the circle.

model(elasticnet) searches a grid of mixing parameters (nalpha()) or uses a fixed alpha(), and nfolds(), loss(mae|mse) and folds(random|interleaved) control the cross-validation.

5DCC-GARCH volatility connectedness

Gabauer (2020) measures how volatility, rather than returns, spreads between markets. A DCC-GARCH(1,1) model (Engle 2002) gives the conditional covariance matrix in every period, and its volatility impulse responses give a volatility forecast error variance decomposition. model(dccgarch) estimates the GARCH margins and the DCC correlations in two steps by maximum likelihood, following the conventions of R's rugarch and rmgarch. The data are daily exchange rates of the euro, pound, Swiss franc and yen from 2002 to 2018.

use cn_g2020, clear
tsset t
connectedness EUR GBP CHF JPY, model(dccgarch) horizon(10) datevar(date) frame(f_dcc) replace
matrix list e(garch)
cngraph tci
cngraph net
Model:  DCC-GARCH(1,1), full sample             Forecast horizon    =       10
FEVD:   volatility FEVD                         Observations used   =     4200
Sample: 02jan2002 to 18sep2018                  Periods measured    =     4200
DCC(1,1): a = 0.0621, b = 0.8333                Log likelihood =  -11153.223

e(garch)[4,4]
          mu    omega    alpha     beta
EUR   0.0107   0.0013   0.0319   0.9646
GBP   0.0056   0.0028   0.0550   0.9384
CHF   0.0333   0.0043   0.0461   0.9494
JPY  -0.0038   0.0038   0.0387   0.9526
DCC-GARCH volatility total connectedness of four currencies
Figure 6. Volatility TCI from the DCC-GARCH model. It moves mostly between 35% and 55%, with sharp, short-lived spikes.
Net total directional volatility connectedness of four currencies
Figure 7. Net volatility connectedness. Dark blue areas mark periods in which a currency is a net transmitter of volatility, mustard areas periods in which it is a net receiver.

The average TCI is 43.89% (58.51% corrected). The Swiss franc is the main net transmitter of volatility (NET = 22.30) and the pound the main net receiver (−16.94). Figure 7 shows that these roles hold for most of the sample. A clear exception is mid-2016, around the Brexit referendum, when the pound briefly became a strong net transmitter.

standardize gives standardized volatility impulse responses, and dccparams() uses given parameters instead of estimating them. The estimates are stored in e(garch), e(dcc), e(ll) and e(converged).

A new look for the graphs

cnnetwork has been redesigned. Edges are curved arrows whose width and shade grow with the strength of the link, net transmitters are dark blue and net receivers mustard, nodes are slightly larger for larger NET, and a subtitle gives the period. With up to 12 short names, the names sit inside the nodes. The example uses crude oil and Islamic sectoral stocks from Adekoya et al. (2022), the data of the asymmetric example in Part 1.

use cn_aaacgo2022, clear
tsset t
foreach v of varlist Brent-UTI {
    generate double r_`v' = 100*(`v' - L.`v')/L.`v'
    drop `v'
    rename r_`v' `v'
}
connectedness Brent-UTI, model(tvpvar) lags(1) horizon(10) prior(minnesota) gamma(0.1) ///
    datevar(date) frame(f_net) replace
cnnetwork
Network of net pairwise connectedness among Brent oil and nine Islamic sector indices
Figure 8. Average net pairwise connectedness of Brent and nine Islamic sector indices. Industrials (IND) are the largest net transmitter (NET = 22.37), while utilities (UTI) and Brent are the largest net receivers. The strongest single link runs from the oil and gas sector (OG) to Brent.

A few options change the look:

  • straight draws straight edges, and curvature(#) sets how much they bend.
  • colors(navy maroon) changes the colors of transmitters and receivers.
  • labels(inside|outside) overrides the placement of the names, and nonote drops the note.
  • threshold(#), method(pci) and at() work as before.

cngraph now matches the networks: a light background, muted axes, a fixed palette, and NET and NPDC panels in dark blue above zero and mustard below zero, as in Figure 7. Dates appear on the horizontal axis, labeled by year for daily, monthly and quarterly data, and connectedness picks up a date variable named date automatically. nostyle brings back the look of your graph scheme.

Checked against the R package

As in Part 1, every model is a port of David Gabauer's ConnectednessApproach R package (version 1.0.4) and is tested against it. The new releases add 40 comparison cases:

ModelR casesLargest difference from R
Frequency, joint and extended joint131.4 × 10−12 (static and rolling); 2.6 × 10−8 (TVP-VAR)
Quantile and LAD VARs76.0 × 10−12
R² decomposed and model-free10below 10−12
LASSO, ridge and elastic net71.3 × 10−11
DCC-GARCH31.9 × 10−12 with R's parameters; estimates within 5.3 × 10−6 and measures within 8.0 × 10−4 when Stata estimates the model

The DCC-GARCH differences come from the optimizers: given R's parameter estimates, Stata reproduces R's measures and log likelihood to machine precision, and the remaining gap reflects the precision with which R's optimizer stops. The full certification script, now with 151 tests, passes in Stata 19 and is in the test/ folder of the repository, so you can rerun the checks yourself.

How it was built

As with the first release, the extensions were developed with the assistance of Claude Code. I guided the work, reviewed, corrected and proofread everything, tested it in Stata 18 and 19, and confirmed that it matches the results of the R package.

Feedback and what comes next

The Part 1 roadmap is now complete. The article on the core package is under review at the Stata Journal. If you use the new models, I would like to hear how they work in your applications. Please report bugs, questions or requests for new models on GitHub Issues or get in touch with me directly.

How to cite

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

Antonakakis, N. (2026). connectedness: VAR-type, TVP-VAR and DCC-GARCH connectedness measures for Stata (Version 0.7.2) [Computer software]. GitHub. https://github.com/Nikosanton82/connectedness-stata
@software{antonakakis2026connectedness,
  author  = {Antonakakis, Nikolaos},
  title   = {connectedness: {VAR}-type, {TVP-VAR} and {DCC-GARCH} connectedness measures for {Stata}},
  year    = {2026},
  version = {0.7.2},
  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.

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. Balcilar, M., Gabauer, D., and Umar, Z. (2021). Crude oil futures contracts and commodity markets: New evidence from a TVP-VAR extended joint connectedness approach. Resources Policy, 73, 102219. https://doi.org/10.1016/j.resourpol.2021.102219
  5. Balli, F., Balli, H. O., Dang, T. H. N., and Gabauer, D. (2023). Contemporaneous and lagged R2 decomposed connectedness approach: New evidence from the energy futures market. Finance Research Letters, 57, 104168. https://doi.org/10.1016/j.frl.2023.104168
  6. Baruník, J., and Křehlík, T. (2018). Measuring the frequency dynamics of financial connectedness and systemic risk. Journal of Financial Econometrics, 16(2), 271–296. https://doi.org/10.1093/jjfinec/nby001
  7. Chatziantoniou, I., Gabauer, D., and Gupta, R. (2023). Integration and risk transmission in the market for crude oil: New evidence from a time-varying parameter frequency connectedness approach. Resources Policy, 84, 103729. https://doi.org/10.1016/j.resourpol.2023.103729
  8. Chatziantoniou, I., Gabauer, D., and Stenfors, A. (2021). Interest rate swaps and the transmission mechanism of monetary policy: A quantile connectedness approach. Economics Letters, 204, 109891. https://doi.org/10.1016/j.econlet.2021.109891
  9. 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
  10. Engle, R. (2002). Dynamic conditional correlation: A simple class of multivariate generalized autoregressive conditional heteroskedasticity models. Journal of Business & Economic Statistics, 20(3), 339–350. https://doi.org/10.1198/073500102288618487
  11. Friedman, J., Hastie, T., and Tibshirani, R. (2010). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software, 33(1), 1–22. https://doi.org/10.18637/jss.v033.i01
  12. Gabauer, D. (2020). Volatility impulse response analysis for DCC-GARCH models: The role of volatility transmission mechanisms. Journal of Forecasting, 39(5), 788–796. https://doi.org/10.1002/for.2648
  13. Gabauer, D. (2025). ConnectednessApproach: Connectedness approach. R package version 1.0.4. https://CRAN.R-project.org/package=ConnectednessApproach
  14. Gabauer, D., Chatziantoniou, I., and Stenfors, A. (2023). Model-free connectedness measures. Finance Research Letters, 54, 103804. https://doi.org/10.1016/j.frl.2023.103804
  15. Gabauer, D., Gupta, R., Marfatia, H. A., and Miller, S. M. (2024). Estimating U.S. housing price network connectedness: Evidence from dynamic Elastic Net, Lasso, and ridge vector autoregressive models. International Review of Economics & Finance, 89, 349–362. https://doi.org/10.1016/j.iref.2023.10.013
  16. Gabauer, D., and Stenfors, A. (2024). Quantile-on-quantile connectedness measures: Evidence from the US treasury yield curve. Finance Research Letters, 60, 104852. https://doi.org/10.1016/j.frl.2023.104852
  17. Lastrapes, W. D., and Wiesen, T. F. P. (2021). The joint spillover index. Economic Modelling, 94, 681–691. https://doi.org/10.1016/j.econmod.2020.02.010
  18. Naeem, M. A., Chatziantoniou, I., Gabauer, D., and Karim, S. (2024). Measuring the G20 stock market return transmission mechanism: Evidence from the R2 connectedness approach. International Review of Financial Analysis, 91, 102986. https://doi.org/10.1016/j.irfa.2023.102986

Share this post

Written by

Prof. Dr. Nikolaos Antonakakis