BVAR with Stochastic Volatility
Python · R · Part 4 of the VAR arc
Overview
Part 4 of the VAR arc: time-varying volatility. Every VAR so far — through the large 20-variable system of Part 3 — assumed a constant shock covariance , treating the economy as equally turbulent in 1974, 1998 and 2008. That is plainly false: US macro data went through a Great Moderation — a sharp, lasting fall in the volatility of output, inflation and interest rates around 1984 — bracketed by the turbulent 1970s and the 2008 crisis. A fixed- VAR splits the difference, so its forecast intervals are simultaneously too wide in calm times and too narrow in storms — its risk assessments are wrong exactly when they matter. Stochastic volatility (SV) lets the shock variances follow their own process, and the literature (Clark 2011; D'Agostino–Gambetti–Giannone 2013) finds it delivers most of the gain from time-varying models — more than letting the regression coefficients drift. This example adds SV to the monetary BVAR from scratch in NumPyro, holding the coefficients constant so the volatility is the whole story.
Factoring the time-varying covariance
The covariance is factored through a constant unit-lower-triangular and a time-varying diagonal (Cogley–Sargent 2005; Primiceri 2005): orthogonalises the reduced-form shocks into independent structural components, each carrying its own log-variance that drifts as a driftless random walk. Because has ones on the diagonal, , so the change of variables from to has unit Jacobian and the likelihood is just a product of univariate Gaussians — no determinant term. The coefficients keep the same Minnesota prior (via bvar.py, ), but with own_mean = 0: the data are stationary growth rates, so the prior shrinks toward white noise, not a random walk. The whole model — VAR coefficients, , and the log-volatility surface — is sampled jointly by NUTS, with the random walk written in non-centred form to kill the volatility-of-volatility funnel that otherwise cripples HMC (, min ESS ~890).
Results
The volatility paths write the postwar history plainly. All three shock volatilities are high and choppy through the 1970s and early 1980s, then drop to a low, stable plateau after ~1984 and stay there — the Great Moderation, with the constant- line sitting uselessly in between. interest-rate volatility peaks in the 1979–82 Volcker disinflation (output-growth volatility a little earlier, in the turbulent late 1970s), inflation volatility peaks with the 1974 oil shock, every series flares in 2008, and the funds-rate volatility collapses toward zero after 2008 when the policy rate was pinned at the zero lower bound. SV massively improves fit — the in-sample log-likelihood rises by ~300 moving from constant variance to SV — and a standardization test confirms it: dividing each shock by its SV path whitens it to a flat rolling std near 1, while dividing by a constant std leaves the heteroskedasticity glaring. The practical payoff is calibrated forecast uncertainty: the SV-VAR's predictive intervals widen in the 1970s and 2008 and narrow through the Great Moderation, so its probability statements are honest in every regime. All of this from time-varying volatility alone — the coefficients never moved (that comes in Part 5, the time-varying-parameter VAR). Cross-checked in R from the opposite direction — a stationary AR(1) SV fit to the OLS residuals with stochvol — which recovers the same Great-Moderation collapse and the same crisis spikes, confirming the path is in the data, not the prior.
Notebooks
Downloads
bvar.py The Minnesota / steady-state BVAR helpers (shared with the Bayesian VAR example) — here supplying the Minnesota prior and lag-regressor build
bvar_sv_data.csv US quarterly annualised GDP growth, GDP-deflator inflation, and the Fed funds rate, 1959–2019 (FRED-QD) References
- Primiceri, G. E. (2005). Time varying structural vector autoregressions and monetary policy. Review of Economic Studies 72(3), 821–852. — the A-matrix / time-varying-covariance factorization used here
- Cogley, T. & Sargent, T. J. (2005). Drifts and volatilities: monetary policies and outcomes in the post WWII US. Review of Economic Dynamics 8(2), 262–302. — stochastic volatility in a macro VAR
- Clark, T. E. (2011). Real-time density forecasts from Bayesian vector autoregressions with stochastic volatility. Journal of Business & Economic Statistics 29(3), 327–341. — SV delivers most of the density-forecast gain
- D'Agostino, A., Gambetti, L. & Giannone, D. (2013). Macroeconomic forecasting and structural change. Journal of Applied Econometrics 28(1), 82–101. — time-varying volatility vs. drifting coefficients
- Kim, S., Shephard, N. & Chib, S. (1998). Stochastic volatility: likelihood inference and comparison with ARCH models. Review of Economic Studies 65(3), 361–393. — the canonical SV likelihood machinery
- Kastner, G. & Frühwirth-Schnatter, S. (2014). Ancillarity-sufficiency interweaving strategy (ASIS) for boosting MCMC estimation of stochastic volatility models. Computational Statistics & Data Analysis 76, 408–423. — the R
stochvolpackage used in the cross-check - McCracken, M. W. & Ng, S. (2020). FRED-QD: a quarterly database for macroeconomic research. Federal Reserve Bank of St. Louis Review 103(1), 1–44. — the FRED-QD data source