Nonparametric efficient inference of average treatment effects for observational data
Project description
Python package: ATE
The main aim of ATE
is to provide a user-friendly interface for nonparametric efficient inference of average
treatment effects for observational data. The package provides point estimates for average treatment
effects, average treatment effect on the treated and can also handle the case of multiple treatments.
The package also allows inference by consistent variance estimates.
Requirements
numpy
pandas
scipy
matplotlib
Installation
The package can be installed from pypi:
pip install ATE
Alternatively, we can directly install from Github:
pip install git+https://github.com/ross1456/ATE-python.git
Key Features
- Ease of use: The main function
ATE
requires only a numeric matrixX
of covariates, numeric vectorY
of response andtreat
vector indicating treatment assignment.
#Generate some data
import numpy as np
np.random.seed(0)
n = 500
# Generate covariates
X1 = np.random.normal(size=(n, 5))
X2 = np.random.binomial(1, 0.4, size=(n, 3))
X = np.hstack((X1, X2))
# Calculate propensity scores
prop = 1 / (1 + np.exp(X[:, 0] - 0.5 * X[:, 1] + 0.25 * X[:, 2] + X[:, 5] + 0.5 * X[:, 7]))
# Treatment assignment
treat = np.random.binomial(1, prop, size=n)
# Outcome variable
Y = 10 * treat + (2 * treat - 1) * (X[:, 0] - 0.5 * X[:, 1] + 0.25 * X[:, 2] + X[:, 5] + 0.5 * X[:, 7]) + np.random.normal(size=n)
#Fit ATE object
ate1 <- ATE()
ate1.fit(Y, treat, X)
ate1.summary()
Estimate Std. Error 95%.Lower 95%.Upper z value p value
E[Y(1)] 10.522690 0.106475 10.314003 10.731376 98.827916 0.000000e+00
E[Y(0)] -0.640634 0.080557 -0.798523 -0.482746 -7.952586 1.826574e-15
ATE 11.163324 0.157352 10.854920 11.471728 70.944896 0.000000e+00
- We can also estimate the average treatment effect on the treated.
ate2 <- ATE(ATT = TRUE)
ate2.fit(Y, treat,X)
ate2.summary()
Estimate Std. Error 95%.Lower 95%.Upper z value p value
E[Y(1)] 9.702759 0.100730 9.505331 9.900187 96.324138 0.000000
E[Y(0)] 0.265824 0.121707 0.027283 0.504365 2.184136 0.028952
ATE 9.436935 0.188530 9.067422 9.806448 50.055253 0.000000
ATE
automatically detects and estimates the case of multiple treatment arm.
ate3<-ATE()
ate3.fit(Y,treat,X)
ate3.summary()
Estimate Std. Error 95%.Lower 95%.Upper z value p value
E[Y(0)] -0.433280 0.332050 -1.084086 0.217526 -1.304863 1.919395e-01
E[Y(1)] 10.391241 1.421770 7.604622 13.177860 7.308663 2.698139e-13
E[Y(2)] 21.393437 5.246493 11.110499 31.676375 4.077664 4.549043e-05
E[Y(3)] 32.643964 12.081066 8.965510 56.322417 2.702077 6.890790e-03
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
Built Distribution
File details
Details for the file ATE-python-0.0.2.tar.gz
.
File metadata
- Download URL: ATE-python-0.0.2.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6730f5147f63f827d92e5bb5a1383bf211b98f2475899f446e0d6f306c39770f |
|
MD5 | 9dfd58bdc482368c6e2cf77468fa06c9 |
|
BLAKE2b-256 | 1ee7a322b206d41c99102069c3c2a19472094a157a4b80b34c72ce9357261893 |
File details
Details for the file ATE_python-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ATE_python-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a227308d797fa96236cf8367cc1c8e904b220280c677737b77e5019880320a72 |
|
MD5 | 6bdf3447307aac7a1969158cee198253 |
|
BLAKE2b-256 | 50642eb75efc800186a0939352b2f9f0eb951fb396f7e24c3daa97eef0bfe9cc |