Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opmatch-1.0.1.tar.gz (7.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page