Data and R code for: Portfolio Risk Across Volatility Regimes in Commodity–Equity Markets
Description
Daily closing prices (1 August 2016 – 31 July 2026) for nine commodity, equity and currency instruments and the VIX: WTI crude oil futures, Brent crude oil futures, natural gas futures, gold futures, copper futures (Yahoo Finance), S&P 500 index, Nasdaq-100 futures, MSCI Emerging Markets ETF, VIX (Yahoo Finance) and the trade-weighted US dollar index DTWEXBGS (FRED). Files: prices_merged_with_dates.csv (raw prices merged by calendar date, 2,512 days); returns_with_dates.csv (simple daily returns, 2,453 observations); rolling_9assets.csv and rolling_10series.csv (rolling 60-day portfolio volatility, average individual volatility, average pairwise correlation, diversification ratio and regime classification); Paper3_FINAL_figures_tables.R (R script that reproduces all tables and figures). To reproduce the results, run the R script in R (version 4.2.1 or later) with the packages quantmod, ggplot2, sandwich and lmtest; it downloads the data, restricts the sample to the period above, and writes Tables 1–4 and Figures 1–2.
Files
Steps to reproduce
Install R (version 4.2.1 or later) and the packages quantmod, ggplot2, sandwich and lmtest. Open Paper3_FINAL_figures_tables.R in RStudio and click “Source”. A window asks for an output folder. The script downloads the daily prices (Yahoo Finance and FRED), merges them by calendar date and restricts the sample to 1 August 2016 – 31 July 2026. The resulting prices are identical to prices_merged_with_dates.csv. It then computes simple returns (returns_with_dates.csv) and the rolling 60-day measures for the nine-asset and ten-series portfolios (rolling_9assets.csv, rolling_10series.csv). It classifies windows into regimes (75th percentile of average individual volatility), estimates Newey-West regressions (lag 60) and writes Table1–Table4.csv, Figure1.png, Figure2.png and results_for_paper.txt.
Institutions
- University of BelgradeCentral Serbia, Belgrade