Hierarchical Bayesian VAR

Python · R · Part 7 of the VAR arc — prior selection & density forecasts

Overview

Part 7 of the VAR arc: letting the data choose the shrinkage. Every Bayesian VAR so far fixed the Minnesota tightness by hand — λ1=0.2\lambda_1=0.2, or the BGR in-sample-fit rule of Part 3. But how much a VAR should shrink is not a matter of taste: it is a parameter the data can speak to. Giannone, Lenza & Primiceri (2015) put a prior on the hyperparameters and estimate them by the marginal likelihood — the fully Bayesian, hierarchical answer to "how much should a VAR shrink?". This example builds that from scratch, then delivers the payoff the stochastic-volatility and time-variation notebooks implicitly promised but never measured: a proper density-forecast evaluation, where getting the shrinkage right — with its uncertainty — visibly improves the whole predictive distribution, not just the point forecast.

p^(Y)=p(Yθ)p(θγ)dθ    p(γY)p(Yγ)p(γ),γ=(λ,μ,δ)\hat p(Y) = \int p(Y\mid\theta)\,p(\theta\mid\gamma)\,d\theta \;\longrightarrow\; p(\gamma\mid Y)\propto p(Y\mid\gamma)\,p(\gamma), \qquad \gamma=(\lambda,\mu,\delta)

A conjugate BVAR whose evidence is closed-form

The trick that makes hierarchical estimation tractable is a change of prior. Earlier notebooks used an independent-Normal Minnesota prior, which needs Gibbs and has no closed-form evidence. Here the natural-conjugate (Normal-inverse-Wishart) version is implemented by dummy observations (Theil mixed estimation): the prior is written as artificial data rows appended to the sample, so the posterior is just the regression on the stacked system — and the marginal likelihood p(Yhyper)p(Y\mid\text{hyper}) is closed-form (a matric-variate-tt normalising constant). Three hyperparameters index the dummies: λ\lambda (overall Minnesota tightness, the master knob), μ\mu (Doan sum-of-coefficients — shrinks toward unit roots, a no-cointegration prior), and δ\delta (Sims dummy-initial-observation — allows a common stochastic trend, i.e. cointegration). The last two are exactly what let a levels BVAR behave sensibly at the unit-root/cointegration boundary that Part 6 was all about. Following GLP, Gamma hyperpriors on (λ,μ,δ)(\lambda,\mu,\delta) are sampled by random-walk Metropolis using the closed-form evidence as the likelihood; the coefficients then follow analytically. A new from-scratch module (bvarglp.py), fit on a 7-variable FRED-QD system in log-levels, p=4p=4.

Results

The data want less shrinkage than the convention. The marginal likelihood places λ\lambda at ~0.29 (68% band ≈ [0.26, 0.32]) — clearly to the right of the conventional 0.2 — and pulls the sum-of-coefficients hyperparameter well off its prior mode (median ≈ 2.4 vs a mode of 1), while the dummy-initial-observation term moves only slightly (≈ 1.14). Every earlier notebook collapsed all this to one fixed number; the hierarchical treatment keeps the uncertainty, and the density forecasts reward it. Best density forecasts: integrating over the hyperparameter posterior, the GLP-hierarchical BVAR has the highest average log predictive score (−3.85), beating a fixed Minnesota tightness (−4.28) and a near-flat prior (−4.54) over 79 quarters — estimating the shrinkage and carrying its uncertainty improves the whole predictive density. The same closed-form evidence gives Bayes factors: the unit-root/cointegration-aware prior components are supported "beyond decisively" (log₁₀ BF ≈ 60 over plain Minnesota), and all p3p\ge 3 dominate shorter lags. Calibration, honestly: the PIT histograms are near-uniform but all three models are mildly over-dispersed (68% intervals cover ~0.75–0.84) — the hierarchical model earns its top score by fit, not by being tightest. This is the measured payoff of Parts 3–5: those added shrinkage, SV and time-variation for better uncertainty; here the predictive densities are finally scored. Cross-checked in R against the BVAR package (itself a GLP implementation), which reproduces the hierarchical λ\lambda posterior.

Notebooks

Downloads

References