Skip to main content

Bayesian Vector Autoregression (VAR) in Python.

Project description

litterman

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

litterman 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/Litterman), 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/Litterman 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 litterman

Or with uv:

uv pip install litterman

Quick Start

import pandas as pd
from litterman 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/litterman

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 litterman in your research, please cite:

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

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

litterman-0.0.2.tar.gz (284.7 kB view details)

Uploaded Source

Built Distribution

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

litterman-0.0.2-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file litterman-0.0.2.tar.gz.

File metadata

  • Download URL: litterman-0.0.2.tar.gz
  • Upload date:
  • Size: 284.7 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 litterman-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3aaa2088701fe4c86fca30316a2b3bd468b6660f6ddacb70020578b094e7a152
MD5 b7da0da9f1c43464d8f4279fe122e7b4
BLAKE2b-256 0d19655d55a13c6e521ab38194bea3513367c6786381e827fd598f77a0382a8b

See more details on using hashes here.

File details

Details for the file litterman-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: litterman-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 21.1 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 litterman-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 33163223d4a15311f159ba68d40af407a7561184c339e15cddda9bcc22c8b7e4
MD5 8355190715d34264e7734561dff737d3
BLAKE2b-256 0fa50976f636b53e91883959e31bbaf4b7c042e5f0cb077a3e5ca1e10777a7ac

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