Dynamic Survival Transformers for Causal Inference with Electronic Health Records

Prayag Chatha, Yixin Wang, Zhenke Wu, Jeffrey Regier

TL;DR

The Dynamic Survival Transformer (DynST) combines the expressive power of self-attention with causal inference to predict patient survival from complex Electronic Health Record (EHR) data. Unlike prior survival models that assume rigid proportional hazards or ignore temporal updates, DynST integrates both static and time-varying features to model hazard trajectories and reliably estimate the causal impact of medical interventions on Restricted Mean Survival Time (RMST).

What Problem Does This Paper Address?

In clinical settings, evaluating whether a treatment actually prolongs survival—such as assessing whether an antibiotic lowers 24-hour sepsis risk—is complicated by two challenges:

  1. Incomplete (censored) observational data: Randomized controlled trials are often unethical or impractical, forcing researchers to rely on observational EHRs riddled with confounding and right-censored outcomes (i.e., patients discharged or lost to follow-up before experiencing the event).
  2. Unrealistic statistical assumptions: Classical tools like Kaplan-Meier estimators cannot personalize predictions across multidimensional patient covariates. Meanwhile, Cox proportional hazard models assume that covariate effects remain constant over time—an assumption frequently violated in real-world intensive care where a patient's vitals deteriorate dynamically.

While deep learning architectures (like Transformers) have been adapted for EHRs, prior survival transformers largely ignored time-varying measurements or were not designed to estimate causal treatment effects.

Methods

DynST reformulates discrete-time survival analysis using an autoregressive Transformer encoder:

  • Unified Feature Embedding: DynST takes static baseline covariates $Z$ (e.g., initial diagnoses, biological sex) and time-varying vitals $V$ (e.g., hourly blood pressure, lab values). A linear projection maps $Z$ and $V$ into an embedding space along with standard sinusoidal positional encodings.
  • Causal Masked Self-Attention: A multi-head self-attention encoder processes the timeline. Strict autoregressive masking ensures that predictions at time step $t$ depend solely on past and current vitals, preventing temporal leakage from future records.
  • Hazard Estimation: A two-layer feedforward network with a sigmoid output estimates $q(t) = 1 - h(t)$, the complement of the discrete hazard rate. Survival curves $S(t)$ and expected survival times are derived via product integrals of these outputs.
  • Joint Censoring-Aware Objective: DynST trains end-to-end on a composite loss: $$\mathcal{L} = (1 - \alpha)\mathcal{L}_1 + \alpha\mathcal{L}_2$$ where $\mathcal{L}_1$ is a modified cross-entropy loss that maximizes survival probabilities during observed survival windows, and $\mathcal{L}_2$ directly penalizes absolute prediction error on uncensored patients (and underestimations on censored patients).

  • Causal Estimation via RMST: DynST functions as an outcome regression (OR) estimator or within an Augmented Inverse Propensity Weighting (AIPW) framework to compute the Average Treatment Effect (ATE) on restricted mean survival time up to cutoff $\tau$.

[Static & Dynamic Inputs] ──> [Linear Projections + Positional Encoding]
                                          │
                                          ▼
                         [Autoregressive Transformer Encoder]
                                          │
                                          ▼
                            [MLP + Sigmoid Hazard Head]
                                          │
                                          ▼
                       [Causal Estimators: OR & AIPW on RMST]

Datasets

The authors evaluate the model on a semi-synthetic dataset derived from MIMIC-III (30,323 ICU patient stays longer than 16 hours, truncated at 128 hours):

  • Covariates: Real-world static demographic/ICD-9 diagnosis data and four real-world dynamic lab/vital signs (hematocrit, hemoglobin, platelets, mean arterial blood pressure).
  • Synthetic Treatment & Outcome: A synthetic binary treatment assignment was generated with severe illness ($Z^*$) acting as a confounder. Synthetic hazard trajectories incorporated baseline exponential decay, a non-proportional time interaction ($t \cdot Z^*$), non-linear vital penalizations, and an unobserved Gaussian noise term on survival logits. Censoring was simulated at 39%, reflecting real-world clinical dropout.

Key Insights and Ideas

  • Handling Time-Varying Non-Proportionalities: Classical Cox regression fails when hazard ratios evolve over time (e.g., sicker patients deteriorating faster). DynST naturally absorbs time-dependent covariate interactions without needing explicitly engineered interaction terms.
  • Double Robustness via AIPW: Coupling DynST's flexible outcome modeling with a simple logistic propensity score in an AIPW estimator yielded near-unbiased treatment effect estimates, demonstrating how modern sequence models slot directly into semi-parametric doubly robust causal estimators.
  • Minimal Propensity Scoring: Counterintuitively, using a minimal set of confounders for the propensity score model prevented propensity truncation/extreme weights, stabilizing IPW-based ATE estimation.

Key Results

  • Survival Prediction Accuracy: DynST achieved the lowest Mean Absolute Error (MAE) on patient survival time on held-out test data:
  • DynST: 11.19 ± 0.24 hours
  • Static Survival Transformer: 11.42 ± 0.23 hours
  • Cox Oracle Baseline: 16.04 ± 0.25 hours
  • Causal Effect Estimation (Bias on ATE): Due to severe confounding, the unadjusted difference in means had significant negative bias (ranging from $-0.502$ at $\tau=8$ to $-1.88$ at $\tau=16$).

  • AIPW (DynST + Logistic): Achieved the lowest bias across all cutoffs ($-0.039 \pm 0.013$ at $\tau=8$, $0.0131 \pm 0.056$ at $\tau=12$, and $0.127 \pm 0.082$ at $\tau=16$).

  • DynST Outcome Regression: Came in second (bias of $-0.146$ to $-0.190$).
  • Both significantly outperformed classical Cox regression (bias up to $-0.750$) and pure Logistic IPW (bias up to $0.416$).

Limitations and Future Work

  • Static Treatment Assignment: The formulation currently assumes treatment occurs strictly at $t=0$; it does not yet handle time-varying treatments or dynamic treatment regimes.
  • Semi-Synthetic Validation: The causal performance was validated against synthetic potential outcomes; true counterfactuals cannot be verified in purely observational real-world clinical datasets.
  • Training and Architecture Refinements: The authors point to implementing cross-fitting (Double Machine Learning) to improve hyperparameter selection and jointly training treatment propensity and outcome prediction heads to further reduce confounding bias.

Summary updated

BibTeX
@inproceedings{chatha2022dynamic,
  author = {Prayag Chatha and Yixin Wang and Zhenke Wu and Jeffrey Regier},
  title = {{Dynamic Survival Transformers for Causal Inference with Electronic Health Records}},
  booktitle = {TS4H @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=6quJeu5gJ7},
}
Figure