facebookresearch/balance
The balance python package offers a simple workflow and methods for dealing with biased data samples when looking to infer from them to some target population of interest.
What it solves
balance is designed to mitigate bias in data samples—such as those from surveys or observational studies—where the sample does not accurately represent the target population. This occurs when there is sampling bias or non-response bias, making it difficult to infer population-level characteristics from the sample data.
How it works
The package implements a workflow to fit and evaluate weights for each unit in a sample. These weights represent how many people from the target population a specific respondent represents, effectively "balancing" the sample to match the target population's distribution of auxiliary information (covariates).
Key methods for adjustment include:
- Inverse-Propensity Weighting (IPW) using L1 (LASSO) penalization.
- Covariate Balancing Propensity Score (CBPS).
- Post-stratification.
- Raking.
It also provides tools for estimating population outcomes using either inverse-propensity weighted means ($\mu\hat{}_IPW$) or outcome-model estimates ($\mu\hat{}_OM$), as well as a doubly-robust (AIPW) estimator.
Who it’s for
It is intended for researchers, survey methodologists, demographers, UX researchers, market researchers, and data scientists or machine learners who need to balance biased samples to produce accurate population-level estimations.
Highlights
- Multiple Adjustment Methods: Supports IPW, CBPS, raking, and raking post-stratification.
- Comprehensive Diagnostics: Includes barplots, density plots, QQ-plots, and "love plots" to visualize covariate balance before and after adjustment.
- Statistical Summaries: Provides Absolute Standardized Mean Difference (ASMD) and Kish's design effect to evaluate weight quality.
- Integration with
diff-diff: Offers a thin adapter for Difference-in-Differences analysis using the weights produced bybalance. - Outcome Estimation: Supports both IPW and outcome-model estimators for robustness checks.
Related
- Project
- Project
- Project
- Project
- Project