Conformal causal inference (counterfactuals & ITE)¶
Distribution-free prediction intervals for counterfactual potential outcomes \(Y(0), Y(1)\) and Individual Treatment Effects \(\text{ITE} = Y(1) - Y(0)\) under binary treatment assignment.
| Use it when | You estimate individual treatment effects from an A/B test or observational study with propensity scores \(e(x) = \mathbb{P}(T = 1 \mid X = x)\). |
| Guarantee | Exact finite-sample coverage \(\ge 1 - \alpha\) for \(Y(0)\), \(Y(1)\), and \(Y(1) - Y(0)\) when propensities are known (randomized or known-propensity designs) under strong ignorability. |
| In the library | ConformalITE |
| Source | Lei and Candès (JRSS-B 2021) |
| Example needs | pyconformal |
Finite-sample counterfactual & ITE guarantee
Using inverse propensity weights \(1/e(X_i)\) for treated units and \(1/(1 - e(X_i))\) for control units, ConformalITE delivers exact finite-sample intervals for both counterfactual arms and the unobserved Individual Treatment Effect \(Y(1) - Y(0)\).
Minimal example¶
Copy, paste, run.
import numpy as np
from pyconformal import ConformalITE
rng = np.random.default_rng(0)
n = 1600
x = rng.normal(size=n)
e = 1.0 / (1.0 + np.exp(-0.8 * x))
T = (rng.random(n) < e).astype(int)
mu0, mu1 = 1.0 + 0.5 * x, 3.0 + 1.2 * x
Y0 = mu0 + rng.normal(0.0, 0.7, size=n)
Y1 = mu1 + rng.normal(0.0, 0.9, size=n)
Y_obs = np.where(T == 1, Y1, Y0)
ite = ConformalITE(alpha=0.1).calibrate(
y=Y_obs[:800], treatment=T[:800], mu0_pred=mu0[:800], mu1_pred=mu1[:800], propensity=e[:800]
)
bounds = ite.predict_ite(mu0_pred=mu0[800:], mu1_pred=mu1[800:], propensity=e[800:])
true_ite = Y1[800:] - Y0[800:]
print(f"ITE coverage: {np.mean((true_ite >= bounds[:, 0]) & (true_ite <= bounds[:, 1])):.3f}")
More¶
- Full argument list: API reference
- All methods: what's inside