Skip to main content

Bayesian Vector Autoregression (VAR) in Python.

Project description

Impulso

Release Build status codecov Commit activity License

Bayesian Vector Autoregression (VAR) in Python.

🚧 Experimental — under heavy development. This project is an experiment in AI-driven software development. The vast majority of the code, tests, and documentation were written by AI (Claude Code). Humans direct architecture, priorities, and design decisions, but have not reviewed most of the code line-by-line. Treat this accordingly — there will be bugs, rough edges, and things that don't work.

Overview

impulso provides a modern, Pythonic interface for Bayesian Vector Autoregression modeling. Built on PyMC, it enables full posterior inference for VAR models with informative priors (Minnesota/Impulso), structural identification, impulse response analysis, and forecast error variance decomposition.

Core Pipeline

The library follows an immutable, type-safe pipeline:

VARData → VAR.fit() → FittedVAR → .set_identification_strategy() → IdentifiedVAR
  • VARData: Validated time series data (endogenous/exogenous variables + DatetimeIndex)
  • VAR: Model specification (lags, priors, exogenous variables)
  • FittedVAR: Reduced-form posterior estimates with forecasting capabilities
  • IdentifiedVAR: Structural VAR with impulse responses, FEVD, and historical decomposition

Key Features

  • Full Bayesian inference via PyMC (NUTS sampling, automatic diagnostics)
  • Minnesota/Impulso priors for regularization in high-dimensional VARs
  • Flexible identification schemes: Recursive (Cholesky), sign restrictions
  • Forecasting: Point forecasts, credible intervals, and scenario analysis
  • Impulse response functions (IRFs) with uncertainty quantification
  • Forecast error variance decomposition (FEVD)
  • Historical decomposition of variables into structural shocks
  • Extensible protocols: Plug in custom priors, samplers, and identification schemes
  • Type-safe: Frozen Pydantic models with full type hints

Installation

pip install impulso

Or with uv:

uv pip install impulso

Quick Start

import pandas as pd
from impulso import VARData, VAR

# Load your time series data
df = pd.read_csv("data.csv", index_col="date", parse_dates=True)

# Create validated VAR data
data = VARData.from_df(df, endog_vars=["gdp", "inflation", "interest_rate"])

# Specify and fit a VAR(4) model with Minnesota prior
var = VAR(lags=4, prior="minnesota")
fitted = var.fit(data)

# Generate forecasts
forecast = fitted.forecast(steps=12)
forecast.plot()

# Structural identification and impulse responses
identified = fitted.set_identification_strategy("cholesky")
irf = identified.impulse_response(steps=20)
irf.plot()

# Forecast error variance decomposition
fevd = identified.fevd(steps=20)
fevd.plot()

Documentation

Full documentation, tutorials, and API reference: https://thomaspinder.github.io/impulso

Requirements

  • Python 3.10+
  • PyMC 5.0+
  • ArviZ 0.19+
  • NumPy, Pandas, Pydantic

Development

See CLAUDE.md for development setup, testing, and contribution guidelines.

License

MIT License. See LICENSE for details.

Citation

If you use impulso in your research, please cite:

@software{impulso,
  author = {Pinder, Thomas},
  title = {impulso: Bayesian Vector Autoregression in Python},
  year = {2026},
  url = {https://github.com/thomaspinder/impulso}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

impulso-0.0.1.tar.gz (723.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

impulso-0.0.1-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

Details for the file impulso-0.0.1.tar.gz.

File metadata

  • Download URL: impulso-0.0.1.tar.gz
  • Upload date:
  • Size: 723.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for impulso-0.0.1.tar.gz
Algorithm Hash digest
SHA256 53ce4995835ee9daf3edb4022d83b679d2d2b0230908bb71a19fb34b2c070f10
MD5 746c1116b6c6b54e14bc0ad4d338762e
BLAKE2b-256 625be0e53fa859421e20e8c973dc58f0f938df39cba66e351fc211fae2e29b11

See more details on using hashes here.

File details

Details for the file impulso-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: impulso-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for impulso-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26757cecc6c599cc29d6ddc3da1f401c68503ea48bbfe8798db08fae8ba815d0
MD5 11bd679bf9b0bc2e2c83298fb898de77
BLAKE2b-256 1e57d7392be7664203d5d3460b3acff69f827875c44fb676c6853ee002d80660

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page