Skip to main content

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}
}

Metadata

Release files for litterman 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for litterman 0.0.2
File Size Uploaded
litterman-0.0.2.tar.gz 284.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litterman 0.0.2
File Interpreter ABI Platform
litterman-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 305.8 kB

Release files / litterman-0.0.2.tar.gz

Download URL litterman-0.0.2.tar.gz
Size 284.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3aaa2088701fe4c86fca30316a2b3bd468b6660f6ddacb70020578b094e7a152
BLAKE2b-256 checksum
How to use checksums
0d19655d55a13c6e521ab38194bea3513367c6786381e827fd598f77a0382a8b
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / litterman-0.0.2-py3-none-any.whl

Download URL litterman-0.0.2-py3-none-any.whl
Size 21.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33163223d4a15311f159ba68d40af407a7561184c339e15cddda9bcc22c8b7e4
BLAKE2b-256 checksum
How to use checksums
0fa50976f636b53e91883959e31bbaf4b7c042e5f0cb077a3e5ca1e10777a7ac
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page