Skip to main content

Population Matching

Project description

https://bayer-group.github.io/pybalance/index.html

Confounding Adjustment

In scientific experiments, researchers aim to identify cause and effect by holding all variables except one constant. Any difference in outcome can then be attributed to the manipulated variable.

However, in many practical cases, it is not possible to control the variables of interest. For instance, it is unethical to conduct a randomized trial to test the effects of smoking on long-term health outcomes; yet the answer to this question is of extreme interest to policy makers, insurance companies and regulatory agencies. Similarly, in social science research, when studying the impact of education on income, researchers cannot manipulate individuals' education levels while holding all other variables constant.

In these cases, observational data can form the basis for "natural experiments" but care must be taken in interpreting these data. One major issue with interpreting these data is known as "confounding".

A classic example of confounding is the association between coffee consumption and heart disease. Initially, a study might find a positive correlation between high coffee consumption and increased risk of heart disease. However, this apparent relationship could be confounded by the fact that heavy coffee drinkers are more likely to also smoke, which is a known risk factor for heart disease. In this case, smoking acts as a confounding variable, as it distorts the true relationship between coffee consumption and heart disease. To address this, researchers need to adjust for smoking status and potentially other relevant variables to accurately assess the independent impact of coffee consumption on heart disease risk.

In general, any comparative analysis of two non-randomized populations will differ systematically in a number of covariate dimensions and these systematic differences must be adjusted for as part of any causal inference analysis. That is where pybalance comes in.

PyBalance

pybalance is a suite of tools in python for performing confounding adjustment in non-randomized populations. In pybalance, we start with measures of "balance" (how similar two populations are) and directly optimize this metric. This approach is different, and we think almost always better, from the well-known propensity score approach, in which the probability of treatment assignment is modelled, but balance metrics are almost always anyway implicitly defining the success criterion (see our demo). Our approach here is to explicitly define and directly optimize the balance metric that is relevant for the given problem.

The pybalance library implements several routines for optimizing balance. To learn more about these methods, head on over to the demos. Then give the code a spin for yourself by following the installation instructions. Any questions or issues please feel free to open an issue or start a discussion.

An application of this library to build an external control arm in a pharmaceutical setting is presented here.

Features

  • Implements linear and non-linear optimization approaches for matching.
  • Utilizes integer program solvers and evolutionary solvers for optimization.
  • Includes implementation of propensity score matching for comparison.
  • Offers a variety of balance calculators and matchers.
  • Provides visualization tools for analysis.
  • Supports simulation of datasets for testing and demonstration purposes.

Limitations

At the moment, pybalance only implements matching routines. Suport for weighting methods is on our roadmap and will appear in a future release.

Citation

If you use pybalance for your research, please acknowledge this with a citation to our paper.

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

pybalance-0.2.3.tar.gz (8.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybalance-0.2.3-py3-none-any.whl (8.6 MB view details)

Uploaded Python 3

File details

Details for the file pybalance-0.2.3.tar.gz.

File metadata

  • Download URL: pybalance-0.2.3.tar.gz
  • Upload date:
  • Size: 8.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybalance-0.2.3.tar.gz
Algorithm Hash digest
SHA256 74fcfff554aa9c102611097c566dd081d5d745b7816621d270b0079f42c0973c
MD5 6e57a0b5b76fd2b2a67e527aced5dd76
BLAKE2b-256 e0acd30fa48400f2836341baf24a84d1689ccc5db38ba0ed3ca983e7eb744159

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybalance-0.2.3.tar.gz:

Publisher: pypi.yml on Bayer-Group/pybalance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybalance-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pybalance-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybalance-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 363ebe1c9fe12152a87813c711984671542cad4045eec3a2b3a4c38b8cf083c6
MD5 1de137ca95a418d86c6627aeb8834146
BLAKE2b-256 8809b316b1a2a5ed6042e3a7816e4a939a95429c7bd44ea0663da38c9bf5398e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybalance-0.2.3-py3-none-any.whl:

Publisher: pypi.yml on Bayer-Group/pybalance

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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