SSVS for VARs — Bayesian Restriction Search
Python · R · Part 3 of the variable-selection arc — restriction search on a system
Overview
Part 3 of the variable-selection arc: restriction search on a whole system. An unrestricted VAR is famously over-parameterised — with variables and lags the system has coefficients plus a full covariance matrix. George, Sun & Ni (2008) turn Part 1's spike-and-slab idea loose on exactly this, and distinctively select on two fronts at once: the VAR coefficients (which lag relationships are real) and the off-diagonals of the error precision's Cholesky factor where (which contemporaneous links are real). Every free element gets a latent 0/1 indicator and a spike-and-slab prior; a Gibbs sampler sweeps them, and the posterior inclusion probabilities read out the restrictions the data support. Fit from scratch to a canonical three-variable US monetary VAR (GDP growth, CPI inflation, the 3-month T-bill rate; 1959–2009) — the SSVS counterpart to the shrinkage priors (Minnesota, horseshoe) used elsewhere for large VARs, and the only method in the series that prunes the error covariance as well as the mean.
Two spike-and-slab layers, four Gibbs blocks
Two spike-and-slab layers over the reduced-form VAR . Coefficients: each element of carries an indicator with a narrow spike / wide slab and . Error structure: factor the precision with upper-triangular; the free off-diagonals — the contemporaneous conditional dependence between equations — get their own spike-and-slab with indicators , so selecting says variables and are contemporaneously conditionally independent. The scales are semiautomatic: tied to each coefficient's OLS standard error (, , with ), so "small" and "large" are measured in units of sampling variability for every coefficient automatically. One Gibbs sweep cycles four closed-form blocks: (1) the coefficients as a vectorised GLS draw; (2) their indicators from the spike/slab density ratio; (3) the error factor drawn column by column from the exact Cholesky-of-precision update; (4) the link indicators . Steps 1–2 are Part 1's SSVS vectorised; steps 3–4 are the new covariance-selection layer. The engine is a self-contained gsnvar.py.
Results
The search recovers textbook macro dynamics. In the GDP-growth equation its own first lag dominates (0.95); the inflation equation is strongly autoregressive; and the T-bill equation keeps its own lag and loads on lagged output and inflation — a Taylor-rule-like reaction function, discovered, not imposed. About half the lag coefficients are switched off — cross-variable terms with no support pushed into the spike — substantially sparsifying the VAR, exactly the over-parameterisation cure. Contemporaneous structure is selected too: the off-diagonals keep ffr↔infl (1.00) and ffr↔dlgdp (0.75) but drop infl↔dlgdp (0.20) — conditional on the interest rate, output and inflation innovations are close to contemporaneously independent. Selection, not just shrinkage: unlike a continuous global-local prior (the horseshoe), SSVS returns genuine 0/1 restrictions and their probabilities — a posterior over VAR specifications — and unlike every earlier selection method here, it prunes the error covariance as well. The bespoke Gibbs and a PyMC spike-and-slab agree on which coefficients survive; the PyMC run mixes far less efficiently (discrete indicators under a full multivariate-normal likelihood), which is precisely why George–Sun–Ni derive a dedicated closed-form Gibbs sampler. Cross-checked further against a from-scratch base-R re-implementation.
Notebooks
Downloads
gsnvar.py The from-scratch George–Sun–Ni SSVS-VAR engine — vectorised GLS coefficient draw, Cholesky-factor covariance selection, and both indicator updates (new self-contained module) gsnvar_data.csv US quarterly real GDP growth, CPI inflation, and the 3-month T-bill rate (statsmodels macrodata, 1959–2009) References
- George, E. I., Sun, D. & Ni, S. (2008). Bayesian stochastic search for VAR model restrictions. Journal of Econometrics 142(1), 553–580. — the two-layer SSVS-VAR restriction search reproduced here
- George, E. I. & McCulloch, R. E. (1993). Variable selection via Gibbs sampling. Journal of the American Statistical Association 88(423), 881–889. — the spike-and-slab SSVS foundation
- Korobilis, D. (2013). VAR forecasting using Bayesian variable selection. Journal of Applied Econometrics 28(2), 204–230. — stochastic-search restriction selection for VAR forecasting
- Koop, G. (2013). Forecasting with medium and large Bayesian VARs. Journal of Applied Econometrics 28(2), 177–203. — selection vs. shrinkage for high-dimensional VARs
- Sims, C. A. (1980). Macroeconomics and reality. Econometrica 48(1), 1–48. — the over-parameterised unrestricted VAR the search prunes
- Taylor, J. B. (1993). Discretion versus policy rules in practice. Carnegie-Rochester Conference Series on Public Policy 39, 195–214. — the monetary-policy reaction function the T-bill equation recovers