{"library":"psmpy","title":"psmpy - Propensity Score Matching for Python","description":"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.","language":"python","status":"active","last_verified":"Sat May 09","install":{"commands":["pip install psmpy"],"cli":null},"imports":["from psmpy import Psmpy","from psmpy import Psmpy"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pandas as pd\nfrom psmpy import Psmpy\nfrom sklearn.linear_model import LogisticRegression\n\n# Sample data\ndf = pd.DataFrame({\n    'treatment': [0, 1, 0, 1, 0, 1],\n    'age': [30, 40, 35, 45, 25, 50],\n    'income': [50000, 60000, 55000, 65000, 45000, 70000]\n})\n\n# Initialize Psmpy\npsm = Psmpy(data=df, treatment='treatment', indx='age',\n            exclude_cols=['income'],\n            logistic_model=LogisticRegression(solver='liblinear'))\n\n# Compute propensity scores\npsm.pscore()\n\n# Perform matching\npsm.match(method='nearest', caliper=None, replace=False)\n\n# View matched pairs\nprint(psm.matched_ids)","lang":"python","description":"Basic workflow: initialize with data, compute scores, match, and inspect matches.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}