# Causalinference: treatment effect estimation in Python

> Causalinference is a pure Python package for the observational study methods that go under the names causal inference, program evaluation and treatment effect analysis, from overlap diagnostics through propensity scores to matching, weighting and subclassification. It is a small package with a long history, and its documentation lives outside the repository.

**laurencium/Causalinference** — Causal Inference in Python

- Repository: https://github.com/laurencium/Causalinference
- Stars: 579 · Forks: 92
- Language: Python
- License: BSD-3-Clause
- Published: 2026-10-22 · Updated: 2026-10-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/laurencium-causalinference

## A small package for a field with three names

The README describes Causalinference, short for Causal Inference in Python, as a software package that implements various statistical and econometric methods used in the field variously known as Causal Inference, Program Evaluation, or Treatment Effect Analysis.

That triple naming is the point. The same body of methods shows up under different names in different literatures, and a package that implements them once for Python serves all three audiences. The methods are observational, not experimental: when you cannot randomise treatment, you estimate the effect by adjusting for the covariates that predict it, and the package exists to make that machinery available in one place.

The provenance is stated in one sentence. Work on Causalinference started in 2014 by Laurence Wong as a personal side project, and it is distributed under the 3-Clause BSD license.

Twelve years of a side project is a useful signal about the shape of the code. This is not a research group's actively developed toolkit with a large feature pipeline; it is a careful, self-contained implementation that has been refined slowly. The README links an official website at causalinferenceinpython.org, the most current development version on GitHub, and the source and binary distributions on PyPI.

## The feature list is the estimation pipeline

The Main Features section is five bullets, and they read in order as a workflow rather than as a catalogue.

Assessment of overlap in covariate distributions comes first, which is the diagnostic step. If the treated and the untreated groups do not overlap in their covariates, no adjustment method will save you, and the package makes you look before it makes you adjust.

Estimation of propensity score is the second step, the probability of treatment given the covariates, which is the object everything else is built on. Improvement of covariate balance through trimming is the third, where you drop the observations that make the two groups non-comparable.

Subclassification on propensity score is the fourth, splitting the sample into bins of the score and comparing within a bin. And estimation of treatment effects via matching, blocking, weighting, and least squares is the last, the four ways of turning a balanced sample into an effect estimate.

That ordering is the pedagogical value of the package. Each step exists because the previous one failed to produce balance, and a user who understands why the trimming comes before the matching can diagnose a result that does not move.

## Installation is a pip install, with an old dependency floor

The Installation section is short. Causalinference can be installed using pip:

```
  $ pip install causalinference
```

and the Dependencies section lists NumPy 1.8.2 or higher and SciPy 0.13.3 or higher. Those floors are old, which tells you something about the age of the code the package was written against, and the README even points to a guide for setting up Pip, NumPy and SciPy on Macs.

There is no separate binary distribution to chase and no compilation step described, so the practical installation story is unremarkable in the best way. What is worth checking is the compatibility direction rather than the installation direction: the package pins nothing in the manifest, so a modern NumPy or SciPy release is more likely to be a problem than an old one.

The README also notes that the most current development version is hosted on GitHub, separate from the PyPI distribution, so there are two things called the package and they are not always the same code. For a library whose estimators are the whole point, that distinction matters when you are reproducing a specific result.

## The minimal example is four lines and a help call

The Minimal Example section shows how a CausalModel is created:

```
  >>> from causalinference import CausalModel
  >>> from causalinference.utils import random_data
  >>> Y, D, X = random_data()
  >>> causal = CausalModel(Y, D, X)
```

The signature is the important part, because it names the three arrays the whole package operates on. Y is the outcome, D is the treatment indicator, and X is the covariate matrix. Every estimator in the package takes the same three and differs only in how it combines them, so the model object is a container for the data and a set of methods over it.

The `random_data` helper from `causalinference.utils` generates a synthetic sample for exactly this purpose, which makes the example runnable without a real dataset and is also a reasonable smoke test when you install the package.

Then there is the discovery instruction, which is the part a new user should follow: invoking `help` on `causal` at this point should return a comprehensive listing of all the causal analysis tools available in Causalinference. The object is its own documentation, and the README is telling you to read it rather than reading the README.

## The package structure mirrors the method

The setup.py in the repository root is short, and the package list in it maps directly onto the workflow the README describes.

The packages are `causalinference`, `causalinference.core`, `causalinference.estimators` and `causalinference.utils`. The `core` package holds the model and the machinery around it, the `estimators` package holds the treatment effect estimators that correspond to matching, blocking, weighting and least squares, and `utils` holds the helper functions such as the data generator used in the example. The package data declaration includes `utils/*.txt` under the `causalinference` package, which is where those auxiliary text files live.

Two details in the manifest are worth noticing. The version is `0.1.3.post1`, and the setup script falls back to distutils if setuptools is not importable. The version number is the important one: a zero major release means no promise about the API, so anything you build against it needs a pin, and a post-release suffix usually means a packaging fix rather than a feature.

The repository layout matches, with the `causalinference` package directory, a `docs` directory, a `tests` directory, `MANIFEST.in`, and the licence files `LICENSE.txt` and `COPYRIGHTS.txt`.

## Three sources of documentation, none of them the README

The Important Links section is where the documentation lives, and the pattern is that the README points outward three times.

The official website is causalinferenceinpython.org. The most current development version is on GitHub. The source and binary distribution files are on PyPI.

On top of those, two documents are singled out. There is an overview of the main features and uses of Causalinference, a vignette PDF in the repository's docs directory, and there is a blog dedicated to providing a more detailed walkthrough of Causalinference and the econometric theory behind it.

The blog is the more interesting of the two for anyone deciding whether to adopt the package, because the econometric theory is where the assumptions live. Matching, weighting and subclassification all rest on the overlap and unconfoundedness assumptions, and a package that explains those in prose is doing something a docstring cannot.

The vignette is the map, and the README explicitly points there for an overview of the main features and uses. A reader who wants to know what the package can do before installing it should read that document first.

## A pre-1.0 package with a long history

The version in the repository is 0.1.3.post1, the package has no GitHub releases, and the repository is not archived with the last push on 2026-09-26.

So this is a package that has been in development for over a decade and has not reached 1.0. For a library whose surface is a set of well-established econometric estimators, that is a statement about API stability rather than about the methods, and it has a practical consequence. Any code you write against it needs a pinned version, and any tutorial you follow online may predate the current signatures.

The BSD-3-Clause licence is permissive, and the repository carries both a `LICENSE.txt` and a `COPYRIGHTS.txt`, which is a reminder that the code is a compilation of methods whose provenance matters if you intend to publish results based on it.

The judgement on the project is a fairly simple one. If you want to see exactly how a matching or weighting estimator is implemented, with the theory alongside, this is a good package to read. If you want the newest estimator, the best diagnostics, or a maintained API, the version number and the absence of releases are the facts that will decide it for you.

## Conclusion

Causalinference fits an economist, data scientist or social scientist who wants a transparent, readable implementation of propensity score methods rather than a black box, and who is comfortable with the assumptions the methods require. It is the wrong choice for a causal machine learning workflow with heterogeneous treatment effects, cross-fitting or double robustness, none of which the feature list mentions. Verify first which estimators the version you install actually provides, since the package version in the repository is still 0.1.3.post1, and read the vignette and the blog rather than assuming the README's feature list is the current API.

## FAQ

### What is the Causalinference Python package?

It is a package implementing various statistical and econometric methods used in the field variously known as Causal Inference, Program Evaluation, or Treatment Effect Analysis. Work started in 2014 by Laurence Wong as a personal side project, and it is distributed under the 3-Clause BSD license.

### What methods does Causalinference provide?

Assessment of overlap in covariate distributions, estimation of propensity score, improvement of covariate balance through trimming, subclassification on propensity score, and estimation of treatment effects via matching, blocking, weighting, and least squares.

### How do I install Causalinference and what does it need?

Run pip install causalinference. The only dependencies listed are NumPy 1.8.2 or higher and SciPy 0.13.3 or higher.

### What does a CausalModel take in its constructor?

Three arrays, Y, D and X, which in the minimal example come from the random_data helper in causalinference.utils. Calling help on the resulting object returns a listing of all the causal analysis tools the package offers.

### Where can I find the documentation for Causalinference?

The README points to the official website causalinferenceinpython.org, the development version on GitHub, the package on PyPI, a vignette PDF with an overview of the main features and uses, and a blog with a more detailed walkthrough and the econometric theory behind it.

## Sources

- [Issues](https://github.com/laurencium/Causalinference/issues)
- [laurencium/Causalinference on GitHub](https://github.com/laurencium/Causalinference)
- [License: BSD-3-Clause](https://github.com/laurencium/Causalinference/blob/master/LICENSE)
- [README](https://github.com/laurencium/Causalinference/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/laurencium-causalinference
