Efficient-Influence-Function (EIF) utilities for surrogate-index causal inference.
Project description
surrogate-index
Introduction
This package provides the first Python implementation of the Surrogate Index Estimator introduced by Athey et al. (2016), a causal inference method for estimating long-term treatment effects using short-term randomized controlled trials (e.g., A/B tests).
The core idea is to combine a randomized experimental dataset with an external observational dataset to estimate the Average Treatment Effect (ATE) on a long-term outcome that is not directly observed in the experiment (e.g., annual revenue, long-term retention). This is particularly useful in settings where long-term metrics are delayed, costly, or infeasible to measure during the experiment window.
This package implements an estimator based on the Efficient Influence Function (EIF) derived by Chen & Ritzwoller (2023), leveraging the Double/Debiased Machine Learning (DML) framework of Chernozhukov et al. (2016). EIF-based estimators enable valid inference while incorporating flexible machine learning models for nuisance components, such as short-term outcome regressions and propensity scores, without compromising asymptotic efficiency or introducing first-order bias.
Brief Mathematical Background
Given the terms:
- $w\in\{0,1\}$: binary treatment indicator
- $s$: a vector of an arbitrary number of short-term outcomes (typically used as the "metrics of interest" in an A/B Test)
- $x$: a vector of pre-treatment covariates.
- $y$: long-term outcome
- $g$: binary indicator for if the user is in the observational sample ($g=1$) or the experimental sample ($g=0$)
the corresponding influence function for the ATE $\tau_0$ is as follows:
$$\xi_0(b,\tau_0,\varphi)=\frac{g}{1-\pi}\left[\frac{1-\gamma(s,x)}{\gamma(s,x)}\cdot\frac{(\varrho(s,x)-\varrho(x))(y-\nu(s,x))}{\varrho(x)(1-\varrho(x))}\right]+\frac{1-g}{1-\pi}\left[\frac{w(\nu(s,x)-\bar\nu_1(x))}{\varrho(x)}-\frac{(1-w)(\nu(s,x)-\bar\nu_0(x))}{1-\varrho(x)}+(\bar\nu_1(x)-\bar\nu_0(x))-\tau_0\right]$$
where:
- $\nu(s,x)=E[Y|S,X,G=1]$
- $\varrho(s,x)=P(W=1|S,X,G=0)$
- $\varrho(x)=P(W=1|X,G=0)$
- $\gamma(s,x)=P(G=1|S,X)$
- $\pi=P(G=1)$
- $\bar\nu_w(x)=E[\nu(S,X)|W=w, X,G=0]$
Some industry examples of using this methodology (may differ in the estimation strategy) are:
Table of Contents
Installation
This package is not on PyPI yet. COMING SOON For now, clone the repo and install locally:
git clone https://github.com/kideokkwon/surrogate-index.git
cd surrogate-index
pip install -e ".[dev,ml]"
## For Conda Users
conda install -c conda-forge xgboost scikit-learn pandas numpy
pip install -e ".[dev]"
## Usage
from surrogate_index import efficient_influence_function
df_exp = ... # your experimental data
df_obs = ... # your observational data
results_df = efficient_influence_function(
df_exp=df_exp,
df_obs=df_obs,
y="six_month_revenue",
w="treatment",
s_cols=[...], # surrogate metric names
x_cols=[...], # covariate names
classifier=...,
regressor=...,
)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file surrogate_index-0.1.0.tar.gz.
File metadata
- Download URL: surrogate_index-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1d43948eb0a2f9fa0b0facfbbb21ab9cf80cb30eebaa48c9ef960ed9bf442c8
|
|
| MD5 |
da063c0d3f3b4a93d52d83b5146a2e10
|
|
| BLAKE2b-256 |
a6a12ca8ad2df1983646302da19d503e9b9d2aa99c9d93b48a326d83345dd330
|
File details
Details for the file surrogate_index-0.1.0-py3-none-any.whl.
File metadata
- Download URL: surrogate_index-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e5f92d45affa99651f22a06f52a33431a413dedafdacd0a98a4a31a90303c1a
|
|
| MD5 |
19b3ae59bbd85c2fc358ca7b7fb7b39f
|
|
| BLAKE2b-256 |
856a9a9759e34d74d8f276faace86e09ae9014e6269963e32401735c639f72d2
|