Registry / data / psmpy
library0.3.16pypypi✓ verified 82d ago

psmpy provides propensity score matching for observational studies, including functions to compute propensity scores, perform matching (with/without replacement, caliper), and generate graphical plots (balancing, histogram). Version 0.3.16 is the latest release. Release cadence is low; last update was 2024.

pip install psmpy
INSTALL
IMPORT
SIG · PSMPY
P
psmpy
datapythonv0.3.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PsmPy
from psmpy import PsmPy
from psmpy import Psmpy

Basic workflow: initialize with data, compute scores, match, and inspect matches.

import pandas as pd from psmpy import Psmpy from sklearn.linear_model import LogisticRegression # Sample data df = pd.DataFrame({ 'treatment': [0, 1, 0, 1, 0, 1], 'age': [30, 40, 35, 45, 25, 50], 'income': [50000, 60000, 55000, 65000, 45000, 70000] }) # Initialize Psmpy psm = Psmpy(data=df, treatment='treatment', indx='age', exclude_cols=['income'], logistic_model=LogisticRegression(solver='liblinear')) # Compute propensity scores psm.pscore() # Perform matching psm.match(method='nearest', caliper=None, replace=False) # View matched pairs print(psm.matched_ids)
Debug
Known issues
breakingIn version 0.3.15 and earlier, the 'indx' parameter was called 'idcol'. It was renamed in 0.3.16. Using 'idcol' raises TypeError.
fix
Use 'indx' instead of 'idcol' when initializing Psmpy.
affects: >=0.3.16
gotchaThe 'logistic_model' parameter expects a scikit-learn LogisticRegression instance with solver='liblinear' (or similar) that supports predict_proba. Using default solver may raise warnings or errors on small datasets.
fix
Explicitly instantiate LogisticRegression(solver='liblinear').
affects: all
gotchaThe 'exclude_cols' parameter should include any columns not used for propensity score estimation (e.g., outcome variables, IDs). Forgetting to exclude the treatment column can cause errors.
fix
List all columns that are not predictors in 'exclude_cols'.
affects: all
Upgrade
Version history
0.3.16latest on PyPI · released Nov 12, 2025
Audit
Dependencies
pandasrequiredData handling for propensity score computation and matching
numpyrequiredNumerical operations
scikit-learnrequiredLogistic regression for propensity score estimation
matplotlibrequiredPlotting balance and histogram graphs
Agent activity
7 hits · last 30 days
node
6
Resources
psmpy — pip install psmpy · libregistry