pymc-labs/CausalPy

A Python package for causal inference in quasi-experimental settings

What it solves

CausalPy addresses the challenge of estimating causal effects in "quasi-experimental" settings—situations where you cannot conduct a randomized controlled trial but still need to understand the impact of an intervention, such as a policy change, a marketing campaign, or a threshold-based rule.

How it works

The library provides a collection of statistical methods designed to analyze data from non-randomized experiments. It supports a "Bayesian-first" approach using PyMC for full uncertainty quantification, while also offering traditional OLS regression via scikit-learn. Users define their model, input their data, and the library produces decision-ready outputs, including effect summaries, credible intervals, and publication-quality visualizations.

Who it’s for

It is designed for researchers and analysts who have a clear quasi-experimental design (like a cutoff rule or staggered rollout) and require rigorous, reproducible, and uncertainty-aware analysis rather than automated "black box" answers.

Highlights

  • Supports diverse methods including Difference-in-Differences, Synthetic Control, Regression Discontinuity, and Instrumental Variables.
  • Provides transparent, uncertainty-aware outputs like Highest Density Intervals (HDI) and Region of Practical Equivalence (ROPE) analysis.
  • Includes built-in visualization tools to plot causal effects and thresholds.
  • Offers AI agent skills to assist coding assistants in performing causal inference tasks.

Related

  • Project
  • Project
  • Project
  • Project
  • Project