Skip to main content

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 matrix X of covariates, numeric vector Y of response and treat 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

Metadata

Release files for ATE-python 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ATE-python 0.0.2
File Size Uploaded
ATE-python-0.0.2.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ATE-python 0.0.2
File Interpreter ABI Platform
ATE_python-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 30.8 kB

Release files / ATE-python-0.0.2.tar.gz

Download URL ATE-python-0.0.2.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6730f5147f63f827d92e5bb5a1383bf211b98f2475899f446e0d6f306c39770f
BLAKE2b-256 checksum
How to use checksums
1ee7a322b206d41c99102069c3c2a19472094a157a4b80b34c72ce9357261893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / ATE_python-0.0.2-py3-none-any.whl

Download URL ATE_python-0.0.2-py3-none-any.whl
Size 16.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a227308d797fa96236cf8367cc1c8e904b220280c677737b77e5019880320a72
BLAKE2b-256 checksum
How to use checksums
50642eb75efc800186a0939352b2f9f0eb951fb396f7e24c3daa97eef0bfe9cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page