Causal calibration for treatment-effect predictions
R + Python · Heterogeneous treatment effects
Calibrate treatment-effect predictions.
causalCalibration adjusts predictions from a treatment-effect model so that people with the same calibrated score have an average treatment effect close to that score. Use it with predictions from your existing model, then estimate how much calibration error remains.
Fit a calibration map
Supply predictions, treatment and outcome data, and estimates of the outcome regressions and propensity score.
from causal_calibration import fit_calibrator
cal = fit_calibrator(
predictions=tau_hat,
treatment=a, outcome=y,
mu0=mu0_hat, mu1=mu1_hat,
propensity=e_hat,
loss="dr", method="isotonic",
)
tau_calibrated = cal.predict(tau_new)library(causalCalibration)
cal <- fit_calibrator(
predictions = tau_hat,
treatment = a, outcome = y,
mu0 = mu0_hat, mu1 = mu1_hat,
propensity = e_hat,
loss = "dr", method = "isotonic"
)
tau_calibrated <- predict(cal, tau_new)This example uses a separate calibration sample. For cross-fitted models, use cross-calibration.
Choose how to calibrate
The package supports binary treatments and observed outcomes. You supply treatment-effect predictions and nuisance estimates; the package fits the calibration map and computes diagnostics.
Standard calibration
Use fit_calibrator() with predictions on a separate calibration sample. Apply the fitted map to new predictions.
Cross-calibration
Use fit_cross_calibrator() with out-of-fold predictions and a matrix of predictions from each fitted model. No separate calibration sample is needed.
Diagnostics
Use diagnose_calibration() to estimate calibration error with a confidence interval and compare raw and calibrated predictions. Use assess_overlap() to check propensity scores.
Choose the population and method
loss="dr" targets the original study population. loss="r" targets an overlap-weighted population, giving more weight to people whose treatment probabilities are closer to one half.
Choose isotonic calibration for a nondecreasing step function, a monotone spline for a smooth nondecreasing function, linear calibration for an intercept and nonnegative slope, or histogram calibration for binwise averages.
References
- Causal calibration and cross-calibration: van der Laan et al. (2023)
- Calibration error estimation: Xu and Yadlowsky (2022)
- R-learner: Nie and Wager (2021)
- DR-learner: Kennedy (2020)
Related software: calibratedDML · Calibrated prediction-powered inference