The Horseshoe at Scale — Selection when p ≫ n
Python · R · Part 8 of the variable-selection arc — global-local shrinkage
Overview
Part 8 of the variable-selection arc: selection when . Every dataset so far had a handful of predictors; real variable selection often looks the opposite — thousands of candidate predictors, tens of samples. Genomics is the canonical case, and exactly where the earlier machinery breaks down: enumeration would need models, and discrete spike-and-slab mixes painfully with 4,088 indicators. The tool built for this regime is the continuous global-local shrinkage prior — above all the horseshoe (Carvalho–Polson–Scott 2010). The benchmark is the riboflavin dataset (Bühlmann–Kalisch–Meier 2014): Bacillus subtilis cultures, gene-expression measurements, and a continuous response — the log vitamin-B2 production rate. The question: which handful of genes drives production? Fit from scratch, cross-checked against PyMC (same prior, NUTS) and R (glmnet, the lasso — the frequentist workhorse for ).
Global-local shrinkage, and the sampler that makes it scale
The horseshoe gives each coefficient its own local scale on top of a global one: , with and . The global pulls everything toward zero (essential when ); the heavy-tailed local lets a few coefficients escape. It is essentially parameter-free — the half-Cauchys need no tuning — and its action is summarised by the shrinkage weight (: shrunk to zero; : kept). Two ingredients make it tractable. (1) Makalic–Schmidt (2016) auxiliary variables turn each half-Cauchy into a pair of conjugate inverse-gamma draws, so the whole sampler is Gibbs. (2) The Bhattacharya–Chakraborty–Mallick (2016) sampler for the coefficient block: the naive draw needs the precision — , hopeless — but their exact algorithm never forms it, solving an system instead at cost. With that turns an impossible step into a millisecond one — the entire run is ~9 seconds. There are no free hyperparameters (all half-Cauchy scales are 1, the standard horseshoe). Engine: a self-contained hshd.py.
Results
A needle in 4,088 haystacks. The horseshoe drives essentially every coefficient to zero — the median shrinkage weight is 0.998 — and lets just a couple escape: YOAB and YXLE stand out sharply (), with a weaker second tier (ARGB, YISU). This is what selection must look like when : aggressive global shrinkage, a few local exceptions — and the signals are biologically sensible (the YXL-region genes and YOAB recur across analyses of this benchmark), recovered without any pre-screening. Both Bayesian engines agree on what is real, not on what is noise: with priors matched, the from-scratch Gibbs and PyMC's NUTS pick the same dominant gene (YOAB; YXLE the runner-up in the from-scratch Gibbs) and R's lasso puts YOAB first too — but across all 4,088 coefficients the two samplers correlate only . That is the posterior being honest: the ~4,086 near-zero coefficients are with large uncertainty, so their exact values are not meant to be reproduced — the reliable outputs of a fit are the shrinkage weights and the top-gene ranking, not individual near-zero estimates. The sampler matters enormously at scale: the specialised Gibbs finishes in ~10 seconds; general-purpose NUTS takes ~2.7 minutes (~16× longer) and still mixes poorly against the horseshoe funnel in 4,088 dimensions. When , the algorithm, not just the prior, is the enabling idea. The horseshoe answers the same question as SSVS — but by shrinking rather than switching: no model space, no binary indicators, just a heavy-tailed prior that lets a few coefficients through, which is why global-local priors dominate the regime.
Notebooks
Downloads
hshd.py The from-scratch high-dimensional horseshoe — Makalic–Schmidt inverse-gamma augmentation and the Bhattacharya O(n²p) coefficient sampler (new self-contained module) ribo_data.csv Riboflavin production in B. subtilis — n = 71 samples, p = 4,088 gene-expression predictors (hdi::riboflavin; ~5 MB) References
- Carvalho, C. M., Polson, N. G. & Scott, J. G. (2010). The horseshoe estimator for sparse signals. Biometrika 97(2), 465–480. — the horseshoe prior
- Bhattacharya, A., Chakraborty, A. & Mallick, B. K. (2016). Fast sampling with Gaussian scale-mixture priors in high-dimensional regression. Biometrika 103(4), 985–991. — the O(n²p) coefficient sampler that makes p ≫ n tractable
- Makalic, E. & Schmidt, D. F. (2016). A simple sampler for the horseshoe estimator. IEEE Signal Processing Letters 23(1), 179–182. — the inverse-gamma augmentation giving a fully-conjugate Gibbs sampler
- Polson, N. G. & Scott, J. G. (2011). Shrink globally, act locally: sparse Bayesian regularization and prediction. In Bayesian Statistics 9, 501–538. Oxford University Press. — the global-local shrinkage framework
- Bühlmann, P., Kalisch, M. & Meier, L. (2014). High-dimensional statistics with a view toward applications in biology. Annual Review of Statistics and Its Application 1, 255–278. — the riboflavin benchmark dataset (
hdi::riboflavin) - Tibshirani, R. (1996). Regression shrinkage and selection via the lasso. Journal of the Royal Statistical Society B 58(1), 267–288. — the lasso, the R
glmnetcross-check - Piironen, J. & Vehtari, A. (2017). Sparsity information and regularization in the horseshoe and other shrinkage priors. Electronic Journal of Statistics 11(2), 5018–5051. — shrinkage weights and effective number of nonzero coefficients