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.1.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.1-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymatchit_causal-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 48437f4ac8a66950ce62481fc6046a10f50dd9ae265a1f35a81b11b5f78b5a2f
MD5 d6493203b30f8b2aa867730725c0e1f4
BLAKE2b-256 5eae66f95e745ca2e286148e3d785b3836dddfd15394a895a8701a7a13ccaa6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pymatchit_causal-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b82beee6d177d46264e16ba6d325a1b7ed138782984b47268c64eea2959ffe0
MD5 ec6cf64889d2814251f602f300199f8d
BLAKE2b-256 f00e90261934f4d6086205ab0018a52a1006985ea4315be11c4fee36eeff973c

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