Skip to main content

Propensity Score Matching (PSM), Coarsened Exact Matching (CEM), and Causal Inference in Python. A port of R's MatchIt.

Project description

pymatchit-causal: Propensity Score Matching in Python

Scalable Causal Inference, Propensity Score Matching (PSM), and Coarsened Exact Matching (CEM).

pymatchit-causal is a Python port of the standard R package MatchIt. It allows data scientists to preprocess data for causal inference by balancing covariates between treated and control groups using state-of-the-art matching methods.

Why use pymatchit?

If you are looking for Propensity Score Matching in Python, this library provides a robust, "R-style" workflow including:

  • Propensity Score Estimation: Logistic Regression (GLM), Random Forest, GBM, Neural Networks.
  • Matching Algorithms: Nearest Neighbor (Greedy), Exact, Subclassification, and Coarsened Exact Matching (CEM).
  • Diagnostics: Publication-ready Love Plots (Covariate Balance), Propensity Density Plots, and ECDF plots.

Features

  • Matching Methods: Nearest Neighbor, Exact, Coarsened Exact Matching (CEM), Subclassification.
  • Distance Metrics: Logistic Regression (GLM), Mahalanobis, Random Forest, GBM, Neural Networks, etc.
  • Diagnostics: Love Plots, ECDF Plots, Propensity Score Density Plots, and Summary Tables (SMD, Variance Ratios).
  • Parity: Designed to mirror the R MatchIt API (matchit(formula, data, method=...)).

Installation

pip install pymatchit-causal

Quick Start

from pymatchit import MatchIt, load_lalonde

# 1. Load Data
df = load_lalonde()

# 2. Match (Nearest Neighbor with Caliper)
m = MatchIt(df, method='nearest', caliper=0.2)
m.fit("treat ~ age + educ + race + married + nodegree + re74 + re75")

# 3. Assess Balance
m.summary()
m.plot(type='balance')

# 4. Get Matched Data for Analysis
matched_data = m.matches()

Citation

If you use pymatchit-causal in your research, please cite it.

Until the accompanying paper is published, please cite the software directly:

Tünnermann, J. (2025). pymatchit: Propensity Score Matching and Causal Inference in Python (Version 0.1.0) [Computer software]. https://github.com/jtuenner/pymatchit

BibTeX:

@software{pymatchit-causal,
  author = {Tünnermann, Jonas},
  title = {pymatchit: Propensity Score Matching and Causal Inference in Python},
  url = {[https://github.com/jtuenner/pymatchit](https://github.com/jtuenner/pymatchit)},
  version = {0.1.0},
  year = {2025}
}

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

pymatchit_causal-0.1.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

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

pymatchit_causal-0.1.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file pymatchit_causal-0.1.0.tar.gz.

File metadata

  • Download URL: pymatchit_causal-0.1.0.tar.gz
  • Upload date:
  • Size: 29.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pymatchit_causal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4f4b1f67cbca08a38d0bd52a11fabf8f7f884585d9ff2b42cc4a72bf350f057f
MD5 ff4aabf0f39ab83bafe2af92e86e7fc0
BLAKE2b-256 efec88cfc5ca0fff986e211ec09ef4b32a8a34fecccafb40ce6349c52db6f6f0

See more details on using hashes here.

File details

Details for the file pymatchit_causal-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pymatchit_causal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 162ff76216b114bb2c2078c436b76d097a64ce971ecc72df7df690c9ebb4902e
MD5 f6cd14389aa7da90223d73584c9ae958
BLAKE2b-256 0e9281addec38284a4de69e6f4b4ea84d4c190645b081f6430bd9531e0cb00eb

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