Metadata-Version: 2.4
Name: ebal
Version: 1.0.0
Summary: Entropy Balancing for Causal Inference - Binary and Continuous Treatment
Author: Eddie Yang
License: MIT
Project-URL: Homepage, https://github.com/EddieYang211/ebal-py
Project-URL: Repository, https://github.com/EddieYang211/ebal-py.git
Project-URL: Issues, https://github.com/EddieYang211/ebal-py/issues
Keywords: entropy balancing,causal inference,propensity score,treatment effect,ATT,ATE,ATC,observational studies
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20.0
Requires-Dist: scipy>=1.6.0
Requires-Dist: scikit-learn>=0.24.0
Requires-Dist: statsmodels>=0.12.0
Requires-Dist: pandas>=1.2.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Dynamic: license-file

# Entropy Balancing for Binary and Continuous Treatment

Python implementation of Entropy Balancing for binary and continuous treatment

> Author: Eddie Yang

ebal for binary treatment is based on Hainmueller ([2012](https://web.stanford.edu/~jhain/Paper/PA2012.pdf)) and ebal for continuous treatment is based on Tübbicke ([2020](https://arxiv.org/abs/2001.06281)) and Vegetabile et al. ([2021](https://arxiv.org/pdf/2003.02938.pdf)).

## Installation

```bash
# From PyPI
pip install ebal

# From GitHub
pip install git+https://github.com/EddieYang211/ebal-py.git

# For development
git clone https://github.com/EddieYang211/ebal-py.git
cd ebal
pip install -e .
```

## Examples

```python
# Binary
import pandas as pd
from ebal import ebal_bin

df = pd.read_csv('~/data.csv')

treatment="treat"
tmp_df = df[df[treatment].isin([0, 1])]
tmp_df = tmp_df.sort_values(by=[treatment])
tmp_df = tmp_df.reset_index(drop=True)

Y = tmp_df.Y.values
X = tmp_df.loc[:,0:10]                         #features
T = tmp_df[treatment].values                   #treatment
e = ebal_bin()
out = e.ebalance(T, X, Y)

# print ebal-weighted regression result
out['wls'].summary()

# check post-weighting balance between treatment and control groups
e.check_balance(X, T, out['w'])
```

```python
# Continuous
import pandas as pd
from ebal import ebal_con

df = pd.read_csv('~/data_cont.csv')

Y = df.Y.values
X = df.iloc[:,4:]                         #features
T = df.T.values                           #treatment

e = ebal_con()
out = e.ebalance(T, X)

# check post-weighting Pearson correlation
e.check_balance(X, T, out['w'])
```

## Documentation

For detailed documentation in Chinese:
- [Binary Treatment Documentation](docs/README_binary.md)
- [Continuous Treatment Documentation](docs/README_continuous.md)

## Reference
* Hainmueller, J. (2012). Entropy balancing for causal effects: A multivariate reweighting method to produce balanced samples in observational studies. Political analysis, 20(1), 25-46.
* Vegetabile, B. G., Griffin, B. A., Coffman, D. L., Cefalu, M., Robbins, M. W., & McCaffrey, D. F. (2021). Nonparametric estimation of population average dose-response curves using entropy balancing weights for continuous exposures. Health Services and Outcomes Research Methodology, 21(1), 69-110.
* Tübbicke, S. (2020). Entropy balancing for continuous treatments. arXiv preprint arXiv:2001.06281.
* R Package 'ebal': https://github.com/cran/ebal

## License

MIT License - see [LICENSE](LICENSE) for details.
