All projects
research

Causal Inference Kit

Treatment-effect estimators checked against known truth

Causal InferenceStatistical ModelingPublic HealthPython
View project

Problem#

Causal estimators are hard to trust on real data because the true effect is never observed. The useful test is to run them where the answer is known first.

What it does#

  • Simulators with known effects: confounded observational data with a hidden-confounding knob, panels for difference-in-differences, donor pools for synthetic control, running-variable samples for regression discontinuity, and encouragement designs for instrumental variables.
  • Estimators: IPW (with stabilised and Hájek variants), overlap weights, entropy balancing, AIPW (doubly robust), propensity matching, DiD and event-study DiD, synthetic control, sharp RD, two-stage least squares and linear mediation.
  • Heterogeneous effects: T-, S-, X-, R- and DR-learners.
  • Robustness: bootstrap evaluation against the true effect, E-values and Rosenbaum bounds for unmeasured confounding.

Usage#

python -m causal_inference.cli simulate --n 5000 --confounding 1.5 --seed 7 --out data.csv
python -m causal_inference.cli estimate --data data.csv --true-ate 2.25
python -m causal_inference.cli report --data data.csv --true-ate 2.25 --bootstrap 200 --out report.md

Engineering#

MIT licensed, with tests. Only NumPy and pandas are required, and propensity models are fitted by hand-written gradient descent, so every step can be read and checked.