Skip to contents

Hedge and Safe Haven Testning

The package/repo is developed to test hedge and safe haven hypotheses (Baur and McDermott 2010), estimate the hedge ratio, hedge effectiveness, and optimal portfolio weights (Basher and Sadorsky 2016), cross-quantilogram-based predictability (Han et al. 2016) and the conditional diversification benefits (Christoffersen et al. 2012, 2018).

Background & Motivation

The role of assets such as gold and bitcoin as potential hedges or safe havens for equity markets has attracted increasing scholarly attention (e.g., Ali et al. (2020); Shahzad et al. (2019); Shahzad et al. (2020); Mujtaba et al. (2024)) amid heightened global economic uncertainty, persistent inflationary pressures, and evolving monetary policy regimes.

Market Context (as of late 2025)

  • Gold has surged to record highs above $4,000 per ounce, driven by central-bank purchases and portfolio diversification away from fiat currencies.
    (BeInCrypto, 2025)
  • Bitcoin climbed above $110,000 amid U.S. dollar weakness and renewed “digital-gold” narratives.
    (Forbes, 2025)
  • Short-term divergences have appeared — gold rallies while bitcoin retreats — highlighting their differing safe-haven mechanisms.
    (CoinDesk, 2025)

The HedgeSafeHaven package provides econometric tools to quantify such behaviors using regression-based safe-haven models, cross-quantile dependence, and conditional diversification benefits (CDB).


Example Workflow — Gold and Bitcoin

We illustrate how to use gold (GLD) and bitcoin (BTC) as potential hedges or safe havens for the U.S. stock market (S&P 500).

1️⃣ Hedge / Safe-Haven Classification

library(HedgeSafeHaven)
# Regression-based hedge/safe-haven estimation
# SP500 and Gold
data("hedgedata")
res_gld <- hedge_safehaven_bm10(hedgedata$SP, hedgedata$GLD)
print(res_gld)
##   Hedge Coefficient    p_value
## 1    c0  0.04988263 0.06089549
## 2  0.10 -0.07209026 0.27142322
## 3  0.05 -0.11405518 0.01072091
## 4  0.01  0.03023066 0.56524296
# SP500 and Gold
res_btc <- hedge_safehaven_bm10(hedgedata$SP, hedgedata$BTC)
print(res_btc)
##   Hedge Coefficient      p_value
## 1    c0   0.8844556 3.060991e-20
## 2  0.10   0.4617737 3.194434e-02
## 3  0.05   1.1166908 1.300167e-12
## 4  0.01   1.5372902 5.973991e-30
# Classification
classify_bm10(res_gld)
## [1] "Selected asset is a not a hedge - safe haven for 5% ."
classify_bm10(res_btc)
## [1] "Selected asset is a not a hedge - not a safe haven ."

This classifies gold/bitcoin role as a hedge or safe haven relative to sp500 using the Baur and McDermott (2010) approach.

2️⃣ Hedge Effectiveness via DCC

# Hedging asset: Gold
res_gld <- hedge_effectiveness_dcc(hedgedata$SP, hedgedata$GLD)
print(res_gld)
##    beta_mean   beta_min beta_max         HE       OPW
## 1 0.01634998 -0.8941619 1.532328 0.03604662 0.4852705
# Hedged asset: Bitcoin, 
res_btc <- hedge_effectiveness_dcc(hedgedata$SP, hedgedata$BTC)
print(res_btc)
##    beta_mean    beta_min  beta_max        HE        OPW
## 1 0.06999591 -0.01849912 0.4599944 0.1095714 0.03016472

This provides the summary of hedge ratios and the hedge effectiveness as in Basher and Sadorsky (2016).

3️⃣ Cross-Quantile Dependence Heatmaps

## Install the 'quantilogram' library
# install.packages("quantilogram") 
library(quantilogram)
# Use gold (GLD) as predicted variable, S&P (SP) as predicting variable
df1 <- hedgedata[, c("GLD", "SP")]
## setup and estimation 
k = 1                             ## lag order 
vec.q  = seq(0.05, 0.95, 0.05)    ## a list of quantiles 
B.size = 100                      ## Repetition of bootstrap  
res1 = crossq.heatmap(df1, k, vec.q, B.size, var1_name = "Gold", var2_name = "SP500") 

## result 
print(res1$plot)

# Use bitcoin (BTC) as predicted variable, S&P (SP) as predicting variable
df2 <- hedgedata[, c("BTC", "SP")]
res2 = crossq.heatmap(df2, k, vec.q, B.size, var1_name = "Bitcoin", var2_name = "SP500") 

## result 
print(res2$plot)

These heatmaps visualize how dependence across quantiles changes from S&P 500 to gold and bitcoin — revealing whether gold/bitcoin remains uncorrelated or negatively correlated (safe haven) during market stress.

4️⃣ Conditional Diversification Benefit (CDB)

# Compute CDB for SP500–Gold portfolio at 5% tail
res_cdb1 <- cdb(hedgedata$SP, hedgedata$GLD, p = 0.05, w = 0.10)
print(res_cdb1)
## [1] 0.3747956
# Compute CDB for SP500–Bitcoin portfolio at 5% tail
res_cdb2 <- cdb(hedgedata$SP, hedgedata$BTC, p = 0.05, w = 0.10)
print(res_cdb2)
## [1] 0.1352266

This returns CDB values for given portfolio weights in the hedging asset (gold/bitcoin). Higher CDB values imply stronger diversification benefits.

References

Ali, Syed, Elie Bouri, Robert L. Czudaj, and Syed Jawad H. Shahzad. 2020. “Revisiting the Valuable Roles of Commodities for International Stock Markets.” Resources Policy 66: 101603.
Basher, Syed A., and Perry Sadorsky. 2016. “Hedging Emerging Market Stock Prices with Oil, Gold, VIX, and Bonds: A Comparison Between DCC, ADCC and GO-GARCH.” Energy Economics 54: 235–47.
Baur, Dirk G., and Thomas K. McDermott. 2010. “Is Gold a Safe Haven? International Evidence.” Journal of Banking & Finance 34 (8): 1886–98.
Christoffersen, Peter, Vihang Errunza, Kris Jacobs, and Hugues Langlois. 2012. “Is the Potential for International Diversification Disappearing? A Dynamic Copula Approach.” Review of Financial Studies 25 (12): 3711–51.
Christoffersen, Peter, Kris Jacobs, Xiaowen Jin, and Hugues Langlois. 2018. “Dynamic Dependence and Diversification in Corporate Credit.” Review of Finance 22 (2): 521–60.
Han, Heejoon, Oliver Linton, Tatsushi Oka, and Yoon-Jae Whang. 2016. “The Cross-Quantilogram: Measuring Quantile Dependence and Testing Directional Predictability Between Time Series.” Journal of Econometrics 193 (1): 251–70.
Mujtaba, Ghulam, Ahmed Siddique, Nizar Naifar, and Syed Jawad H. Shahzad. 2024. “Hedge and Safe Haven Role of Commodities for the US and Chinese Equity Markets.” International Journal of Finance & Economics 29 (2): 2381–2414.
Shahzad, Syed Jawad H., Elie Bouri, David Roubaud, and Ladislav Kristoufek. 2020. “Safe Haven, Hedge and Diversification for G7 Stock Markets: Gold Versus Bitcoin.” Economic Modelling 87: 212–24.
Shahzad, Syed Jawad H., Elie Bouri, David Roubaud, Ladislav Kristoufek, and Brian Lucey. 2019. “Is Bitcoin a Better Safe-Haven Investment Than Gold and Commodities?” International Review of Financial Analysis 63: 322–30.