Joint Treatment Effect Estimation from Incomplete Healthcare Data: Temporal Causal Normalizing Flows with LLM-driven Evolutionary MNAR Imputation

Olivia Jullian Parra, Sara Zoccheddu, David Catalán Cerezo, Tom Forzy, Franziska S Ulrich, William Sutcliffe, Jakob M. Burgstaller, Oliver Senn, Patrick Owen, Nicola SerraNeurIPS 2026

TL;DR

Electronic health records (EHRs) hold a goldmine of real-world medical insights, yet figuring out whether a drug actually caused an outcome is thwarted by two compounding problems: doctors change treatments dynamically over time, and up to 80% of critical lab values are missing because of how sick the patient looks. This paper introduces a two-stage pipeline—an LLM that evolves custom code to fill in missing data without distorting causal signals, paired with an exactly invertible causal normalizing flow—that successfully recovers clinical-trial-grade drug comparisons directly from messy primary care records.

What Problem Does This Paper Address?

Randomized Controlled Trials (RCTs) are the gold standard of medicine, but they are expensive, slow, and exclude complex, real-world patients. Target Trial Emulation (TTE) tries to mimic RCTs using routine observational EHR data. However, standard machine learning causal estimators typically tackle challenges in isolation and break down under two interacting real-world realities:

  1. Time-varying confounding: A patient's evolving health dictates their next treatment, which in turn alters their future health. Without explicit causal guardrails, flexible deep learning models silently learn spurious, anti-causal shortcuts.
  2. Severe MNAR (Missing-Not-At-Random) missingness: Doctors don't order blood tests by rolling dice; they order them on clinical suspicion. Often 50%–80% of biomarker entries are blank, and standard imputation tools (which assume data is missing at random) warp the underlying biomarker–outcome relationships, poisoning downstream causal estimates.

Methods

The authors tackle this sequentially so each stage can be validated independently:

Overview of the two-stage pipeline: Stage 1 uses an LLM evolutionary loop to write an imputer, feeding completed patient trajectories into Stage 2's LSTM-conditioned, DAG-constrained normalizing flow.
  • Stage 1: LLM-Driven Evolutionary Imputation. Instead of asking an LLM to guess missing numbers directly, the LLM acts as a mutation operator in an evolutionary search, writing executable Python imputation programs. What’s novel is the self-supervised proxy score: candidate programs are judged on held-out masked cells not just by pointwise reconstruction error (RMSE), but also by penalties if they distort correlations between biomarkers and treatments or outcomes. The winning program is frozen and run offline.
  • Stage 2: CausalFlow-T. Standard Causal Masked Autoregressive Flows (CausalMAF) work on static data. The authors extend this to longitudinal trajectories by conditioning the flow on an LSTM summary of patient history. Crucially, the flow's autoregressive structure is locked to an expert-specified Directed Acyclic Graph (DAG). Because normalizing flows are exact bijections (invertible without loss), counterfactuals are computed via Pearl’s Abduction-Action-Prediction: invert the flow to extract a patient's exact exogenous "noise," surgically swap the treatment, and push forward exclusively through true causal descendants.

Datasets

  • Four Synthetic Benchmarks: Designed with ground-truth counterfactuals of escalating difficulty: Simple 3-Node (linear control), LDL Toy (autoregressive dynamics and subgroup confounding), Cox Survival (binary survival, bimodal heterogeneity), and CVD Risk Toy (50k patients, 17-node DAG where treatment effects are 100% mediated through lagged blood pressure).
  • Semi-Synthetic Benchmark: Built on a real Swiss EHR backbone with 10 synthetic longitudinal biomarkers, a known benchmark Average Treatment Effect ($\text{ATE} = -3.484$), and artificial MNAR missingness injected at 30%, 50%, and 80%.
  • Real-World EHR (FIRE Database): 6,114 adults with Type 2 Diabetes in Swiss primary care initiating either GLP-1 receptor agonists (like Ozempic; $n=3,722$) or SGLT-2 inhibitors ($n=2,392$), tracking 1-year body weight change under >50% MNAR missingness.

Key Insights and Ideas

  • Factual accuracy hides counterfactual disasters: Models can achieve great overall prediction error while failing catastrophically in practice—collapsing tail variance, failing specific subgroups, or even reversing a drug's effect from helpful to harmful.
  • Two non-overlapping failure modes: Ablations reveal that DAG constraints and exact inference solve strictly separate problems. Without a DAG, unconstrained flows route interventions through anti-causal pathways. Without exact likelihoods, variational models (like CVAEs using ELBO approximations) suffer posterior collapse on mediated pathways, estimating a null effect where a real benefit exists. Neither component can compensate for missing the other.
  • The Reconstruction–Causal Tradeoff: Imputing missing numbers accurately and preserving causal correlation structure are misaligned goals. Optimizing purely for RMSE degrades downstream treatment effect estimates, explaining why joint biomarker–causal scoring during program search is vital.

Key Results

  • Causal Reliability: Across the four synthetic benchmarks, CausalFlow-T is the only architecture passing all five reliability criteria (subgroup bias, tail variance, hazard direction, arm error, and stability), achieving the best mean rank (2.08). On the fully mediated CVD Risk test (true Hazard Ratio $0.831$), CVAE baselines collapsed to null ($\text{HR} \approx 1.005$) and TARNet inverted the effect ($\text{HR} = 1.133$), whereas CausalFlow-T recovered $\text{HR} = 0.786 \pm 0.051$.
Table 1: Per-metric ranks (1 = best, 5 = worst) across four synthetic datasets and binary reliability criteria (✓/✗). Arm: mean per-arm error; VR: |VRQ4 −1|. Reliability: Bias ratio < 0.5; Tail: mean |VRQ4 −1| < 0.5 across all benchmarks; HR: correct direction; Arm: best on ≥2 benchmarks; Stable: no explosion or inversion. Metric definitions are in Appendix D.1.
  • MNAR Imputation: Evaluated across 30%–80% MNAR missingness with three LLM backends, LLM-evolved imputers took the top pooled ranks (GPT-5.4 at 2.46, open-weight GPT-OSS-120b at 2.69, Qwen3.5-Plus at 3.38), beating MissForest (3.75), CausalCFM (3.92), and LOCF (4.81). GPT-5.4 barely flinched from 30% to 80% missingness (MAE $1.914 \rightarrow 2.059$).
  • Clinical Trial Replication: On real Swiss diabetes EHR data, the pipeline estimated a 1-year per-protocol weight-loss advantage of $-0.93\text{ kg}$ [95% CI $-1.26, -0.70$] for GLP-1RAs over SGLT-2is—aligning closely with the landmark SUSTAIN 8 RCT ($-1.06\text{ kg}$), despite real-world class mixing and heavy missingness.

Limitations and Future Work

  • Continuous Flows on Discrete Events: Normalizing flows require continuous variables; dequantizing binary survival outcomes introduces a slight calibration penalty, pointing toward discrete or hybrid flows as a natural next step.
  • Expert DAG Reliance & Unmeasured Confounding: The method assumes a correctly specified expert DAG and no hidden confounders (like unrecorded doctor prescribing preferences). While single missing edges mostly show up as cross-seed instability—a potential clue for future data-driven DAG refinement—wrong edge directions remain an open vulnerability.
  • Search Overhead: Evolutionary search requires LLM API calls and currently uses a simple single-parent loop; multi-objective evolutionary search and testing across broader hospital EHR systems are slated for future work.

Summary updated

Abstract

Target trial emulation (TTE) provides a framework for answering causal questions using observational data when randomized controlled trials (RCTs) are infeasible. However, standard methods for treatment effect estimation have been developed in isolation, failing to jointly address the compounding challenges inherent to analyses of observational data such as electronic health records (EHRs). In particular, these challenges include time-varying confounding and missing-not-at-random (MNAR) missingness reaching 50\%--80\% for critical biomarkers. To address this gap, we propose a two-stage pipeline that jointly handles MNAR missingness and causal structure across time. CausalFlow-T adapts a Directed Acyclic Graph (DAG)-constrained normalizing flow conditioned on a Long Short-Term Memory (LSTM)-encoding of patient history and performs exact invertible counterfactual inference, eliminating the approximation errors and confounding biases where existing variational and adversarial methods can fail silently. Ablations on four synthetic and one semi-synthetic datasets with known counterfactuals confirm that its two core design choices address strictly non-overlapping failure modes (DAG constraints for confounding separation, exact inference for structural propagation) with neither compensating for the absence of the other. To handle the incomplete data CausalFlow-T receives as input, we propose an LLM-driven evolutionary imputer and evaluate it with three LLM backends, including an open-weight model. Across 30\%--80\% MNAR missingness, the imputer achieves the best pooled rank across biomarker and causal metrics, leading on pointwise accuracy and temporal extrapolation while maintaining a competitive average treatment effect (ATE) recovery where statistical methods progressively degrade. Applied to a cohort of adults with type 2 diabetes in Swiss primary care initiating a GLP-1 receptor agonist or SGLT-2 inhibitor, the pipeline recovers a per-protocol weight-loss difference of $-0.93$ kg [$95\%$ CI $-1.26$, $-0.70$] favoring GLP-1 receptor agonists, consistent with RCT evidence and estimated directly from realistically incomplete real-world EHR data.
BibTeX
@inproceedings{parra2026joint,
  author = {Olivia Jullian Parra and Sara Zoccheddu and David Catalán Cerezo and Tom Forzy and Franziska S Ulrich and William Sutcliffe and Jakob M. Burgstaller and Oliver Senn and Patrick Owen and Nicola Serra},
  title = {{Joint Treatment Effect Estimation from Incomplete Healthcare Data: Temporal Causal Normalizing Flows with LLM-driven Evolutionary MNAR Imputation}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=eYP8uXiZtE},
}
Figure