srvar-toolkit: A Python Implementation of Shadow-Rate Vector Autoregressions with Stochastic Volatility
Abstract
We introduce srvar-toolkit, an open-source Python package for Bayesian vector autoregression with shadow-rate constraints and stochastic volatility. The toolkit implements the methodology of Grammatikopoulos (2025, Journal of Forecasting) for forecasting macroeconomic variables when interest rates hit the effective lower bound. We provide conjugate Normal-Inverse-Wishart priors with Minnesota-style shrinkage, latent shadow-rate data augmentation via Gibbs sampling, diagonal stochastic volatility using the Kim-Shephard-Chib mixture approximation, and stochastic search variable selection. Core dependencies are NumPy, SciPy, and Pandas, with optional extras for plotting and a configuration-driven command-line interface. We release the software under the MIT licence at https://github.com/shawcharles/srvar-toolkit.
Summary
The paper introduces `srvar-toolkit`, an open-source Python package designed for Bayesian Vector Autoregression (VAR) modeling, specifically addressing the challenges posed by the effective lower bound (ELB) on interest rates using shadow-rate models and incorporating stochastic volatility. The package implements the methodology detailed in Grammatikopoulos (2025), allowing researchers to forecast macroeconomic variables more accurately when interest rates are near zero. It provides a user-friendly interface for specifying models, configuring priors (including Minnesota-style shrinkage), and running MCMC sampling. The core of the toolkit involves data augmentation via Gibbs sampling to handle latent shadow rates, Kim-Shephard-Chib (KSC) mixture approximation for diagonal stochastic volatility, and stochastic search variable selection to improve model parsimony. The key contribution of `srvar-toolkit` is making advanced shadow-rate VAR estimation accessible to researchers who primarily use Python, filling a gap left by existing MATLAB implementations. The toolkit's architecture emphasizes modularity, immutability of configuration objects, explicit random number generator injection for reproducibility, and limited core dependencies (NumPy, SciPy, Pandas). This design promotes ease of use, extensibility, and reliability, suitable for both exploratory analysis and production forecasting. The paper provides a demonstration of the toolkit's capabilities using a simplified two-variable system with an ELB constraint, showcasing the ability to infer shadow rates and generate forecast fan charts that account for parameter uncertainty and time-varying volatility.
Key Insights
- •Implements shadow-rate data augmentation using Gibbs sampling to estimate latent interest rates when the observed rate is at the effective lower bound (ELB), improving macroeconomic forecasting accuracy in such scenarios.
- •Utilizes the Kim-Shephard-Chib (KSC) mixture approximation for efficient estimation of diagonal stochastic volatility, capturing time-varying uncertainty in macroeconomic variables.
- •Offers Minnesota-style shrinkage priors with a hyperparameter λ1 to control overall tightness, and λ3 to govern lag decay. Larger values of λ1 pull coefficients towards the prior mean, promoting model parsimony.
- •Incorporates stochastic search variable selection (SSVS) with spike-and-slab priors to automatically identify and include only the most relevant predictors in the VAR model.
- •The `srvar-toolkit` is designed with immutable configuration objects, preventing accidental modifications during estimation and ensuring reproducibility.
- •The toolkit is modular, allowing users to easily replace or extend components like the volatility specification without affecting other parts of the pipeline.
- •The software design limits core dependencies to NumPy, SciPy, and Pandas, avoiding the complexity of probabilistic programming frameworks, while providing optional extras for plotting and a configuration-driven CLI.
Practical Implications
- •Enables more accurate macroeconomic forecasting in environments where interest rates are at or near the effective lower bound, crucial for policymakers and financial institutions.
- •Provides a flexible and extensible platform for researchers to experiment with different VAR model specifications, prior distributions, and sampling techniques.
- •Facilitates the adoption of shadow-rate VAR models by applied researchers and practitioners who prefer working in Python.
- •Opens avenues for future research, including extending the toolkit to handle time-varying correlations between variables, incorporating steady-state VAR parameterization, and implementing alternative shrinkage priors like Bayesian LASSO or Dirichlet-Laplace.
- •Allows for building production forecasting pipelines due to the focus on reproducibility, testing, and clear separation of model specification and sampling machinery.