A leightweight package to perform optimal case-control matching.
Project description
The package provides the following matching methods:
- optimal match
- one-to-one match
- one-to-many match
- variable ratio match
- full match (not implemented yet)
- greedy match
- not implemented yet
All matching methods support covariate and propensity score matching.
To obtain matches you can simply run:
from opmatch.matcher import Matcher
case_control_dict = Matcher(
df, matching_ratio,
min_mr, max_mr, n_controls,
metric, matching_type,
case_col, var_cols, ps_col,
).match()
Parameters
-
matching_ratio number of controls per case if matching ratio is constant
-
min_mr: minimum number of controls per case
-
max_mr: maximum number of controls per case
-
n_controls: number of controls to match
-
metric: PS or one of the metrics accepted by scipy.spatial.distances.cdist
-
matching_type: constant or variable matching ratio
-
case_col: boolean column where cases are 1s and controls 0s
-
var_cols: columns containing relevatn patient variables if metric!=PS: var_cols used for matching if metric==PS but ps_col is not specified: var_cols used to compute PS using logistic regression
-
ps_col: column containing the propensity score
-
case_col: column name of case column, should contain 1s and 0s
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file opmatch-1.0.1.tar.gz.
File metadata
- Download URL: opmatch-1.0.1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72005b27353a6135c143b221f97747b94d295bd3b654753cace51aba2a39d6ab
|
|
| MD5 |
6e04db99b8ea27c5bfad4099003c2d8a
|
|
| BLAKE2b-256 |
42ce2eb8f9975ff1ce4c18440eccb272edf70b75353a642ef5086771f112f061
|