Add observational ITE benchmark DGP + all-CI demo notebook#23
Merged
Conversation
Port the 7-variable mediation SCM from mikekr97/MA_Mike (code/ITE_observational_simulation.R) into the simulations portfolio as `ITEObservational` (registry key `ite-observational`): a binary treatment confounded by X1,X2, two Colr mediators X5->X6, and a continuous outcome Y with a nonlinear baseline h_y(y)=tan(y/2)/0.2 and (X2,X3)*Tr interactions. Four scenarios toggle main/interaction effects; the generator exposes per-individual ground truth (ITE_true at the observed latent, ITE_median at the median latent) and the MC ATE. Frozen data/ite-observational/ CSV (scenario 1) + CLI, mirroring vaca/carefl. notebooks/ite_observational.py: an all-CI S-learner TRAM-DAG fitted once on observational data recovers per-individual ITEs via abduction + do (including the mediated X5->X6->Y path and the treatment heterogeneity), validated against the known truth (r ~ 0.99, ATE within ~0.01) and contrasted with the biased naive contrast. tests/test_ite_observational.py: reproducibility, frozen-CSV contract, the TRAM latent identities (KS-logistic), h_y round-trip, treatment rate, ITE_median definition, null-scenario sanity, ATE pin (fast); plus a slow all-CI fit/ITE recovery test. CHANGELOG 0.3.1 + README/notebooks docs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The DGP was attributed to "Krause", a surname I inferred from the GitHub handle mikekr97 rather than any source — it is not verified. Attribute instead to the verifiable master's-thesis repo mikekr97/MA_Mike. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…l-dgp # Conflicts: # CHANGELOG.md # notebooks/README.md
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a confounded-treatment individual-treatment-effect (ITE) benchmark to
the simulation portfolio (like VACA/CAREFL) plus a demo notebook training an
all-CI TRAM-DAG that recovers per-individual effects.
DGP ported from
code/ITE_observational_simulation.Rinmikekr97/MA_Mike (the master's-thesis repo).
The DGP —
simulations.ITEObservational(ite-observational)A 7-variable mediation SCM, topological order
X1 X2 X3 Tr X5 X6 Y:with
β = (-0.5, 0.5, 0.2, -0.6, 0.4)on(X1,X2,X3,X5,X6)and a nonlinearbaseline
h_y(y) = tan(y/2)/0.2on[-2,2](slope-matched linear tails, soh_y⁻¹(z) = 2·atan(0.2·z)in the core). All latents are logistic → the DGP sitsinside the flow's family; the shapes and the
(X2,X3)·Trinteraction are whatmust be learned.
Treatment flows through a direct path and a mediated path
X5 → X6 → Y, andthe interaction makes effects heterogeneous. Four scenarios toggle
main/interaction effects (
scenario=1..4); scenario 1 (main + interaction)is the frozen/featured dataset. The generator exposes per-individual ground
truth —
ITE_true(observed latent) andITE_median(median latent) — and theMonte-Carlo
ATE. Frozendata/ite-observational/{obs.csv,truth.json}+ CLI,mirroring the other portfolio DGPs.
The demo —
notebooks/ite_observational.pyAn all-CI S-learner (every child node a joint complex intercept over its
parents) fitted once on 20k observational rows, then queried per individual:
confounding by
X1,X2;do(Tr=0/1)(recomputing the mediators under eachcounterfactual treatment) — recovers the true ITEs at r ≈ 0.99, MAE 0.045,
ATE −0.575 vs true −0.573;
X2, X3) matches the DGP.Tests —
tests/test_ite_observational.pyGenerator pinning (reproducibility, frozen-CSV contract, the TRAM
latent identities as KS-logistic,
h_yround-trip, treatment rate,ITE_mediandefinition, null-scenario sanity, ATE pin) — 10 fast tests — plus a
slowall-CI fit/ITE-recovery test (ATE within 0.05, ITE corr > 0.8).
uv run pytest tests/test_ite_observational.py tests/test_paper_dgps.py -q -m "not slow"→ 35 passed. Notebook verified headless end-to-end (figure attached in the
description above is reproduced by the
.py).CHANGELOG 0.3.1 + README/notebooks docs updated.
🤖 Generated with Claude Code