- The paper introduces a transformer-based causal modeling pipeline that integrates dialysis risk prediction with ingredient-level treatment effect estimation for AKI patients.
- It leverages longitudinal EHR sequences and laboratory markers while addressing rare-event imbalance and temporal leakage, achieving moderate discrimination (AUC 0.694).
- Clinical validation using kidney markers corroborates protective signals for ACE inhibitors/ARBs and risk signals for loop diuretics, advancing causal inference in nephrology.
Study Rationale and Objectives
Progression from acute kidney injury (AKI) to dialysis or end-stage renal disease (ESRD) is a critical but low prevalence outcome in nephrology. Clinical guidance regarding pharmacological interventions is hampered by the limitations of causal inference in observational EHR datasets, compounded by polypharmacy and confounding by indication. This paper presents an integrated pipeline that simultaneously models both dialysis risk prediction and average treatment effects (ATEs) at the medication ingredient level, leveraging sequential EHR data and laboratory markers. The technical innovations address reproducible cohort construction, rare-event imbalance, longitudinal representation, ingredient-level counterfactual inference, and laboratory-based clinical validation.
Cohort Construction and Data Representation
A cohort of 81,401 AKI patients was constructed using a fixed-window approach: 90 days of clinical observation followed by a 730-day risk prediction window. Outcome labeling strictly excluded events occurring during observation to avoid leakage. Each patient’s history was represented as a temporally ordered sequence of diagnoses, procedures, and medications, further supplemented with lab-derived summaries of eGFR, creatinine, and BUN trajectories. Medication exposures were mapped to both drug-product and ingredient-level vocabularies, facilitating counterfactual scenario construction.
Laboratory data availability was variable (eGFR in 93.5%, BUN in 39.4%, creatinine in 4.1%), reflecting the real-world heterogeneity of EHR sampling and imposing limitations on lab-based validation capacity.
The core model is a transformer encoder with distinct token embeddings for diagnoses, procedures, and medications, augmented by segment and positional encodings. The architecture includes four prediction heads:
- Outcome head for binary dialysis/ESRD risk prediction.
- Propensity head for modeling treatment assignment.
- Two treatment-specific outcome heads for potential outcome estimation.
Imbalance-aware loss functions (weighted cross-entropy, focal loss, class-balanced objectives) were critical, given the 1.1% outcome prevalence. Training and validation employed time-aware splits to prevent temporal leakage.
The transformer-based model demonstrated moderate discrimination on the test set: AUC = 0.694, PR-AUC = 0.094, F1 = 0.201, and a Brier score of 0.019. These values substantially exceed linear SVM and logistic regression baselines across all metrics except for the 365-day observation window, where additional clinical noise diminished performance. Imbalance-handling strategies proved essential, per ablation results, for boosting PR-AUC and F1.
Ingredient-Level Average Treatment Effect Estimation
Medication effects were estimated through a token-level counterfactual approach: dialysis risk predictions for each patient under hypothetical scenarios of exposure addition and removal. Ingredient-level aggregation reduced product-coding fragmentation and provided clinically interpretable ATEs.
Results highlighted partial protective signals for ACE inhibitors/ARBs (notably lisinopril), with ATE ≈ -0.002, and consistent risk-increasing signals for loop diuretics (ATE ≈ +0.007). These estimates, generated for both 90-day and 365-day observation windows, align with clinical practice wherein ACEi/ARB continuation is generally favored post-AKI recovery, and loop diuretic exposure often reflects underlying illness severity. However, sparse exposure to nephrotoxic drugs precluded definitive effect estimation for those classes.
Clinical Validation via Kidney Markers
Post-hoc time-anchored analyses of eGFR, creatinine, and BUN changes corroborated the model-derived directionality for ACEi/ARB and loop diuretic exposures, though laboratory coverage limits the strength of this corroboration. Propensity-weighted and regression-adjusted methods provided additional sensitivity analyses and flagged overlap violations when common support assumptions were weak.
Methodological Considerations and Limitations
The study rigorously mitigates class imbalance, temporal leakage, and confounding, but definitive causal attribution remains elusive due to:
- Confounding by indication, particularly with loop diuretic exposure.
- Limited laboratory sample sizes restricting physiological triangulation.
- Sparse representation of some drug classes.
Ingredient-level effect estimation and catalog-constrained token mapping enhance model interpretability and clinical relevance, marking a methodological step forward for pharmacoepidemiology studies using EHR data.
Implications and Future Directions
This framework demonstrates that transformer architectures applied to longitudinal EHR sequences can feasibly support both risk prediction and ingredient-level treatment effect estimation for rare events. The practical implication is scalable hypothesis generation for medication safety and renal outcome research. Theoretically, the study calls for further enhancements in modeling time-varying confounders, external validation, and richer representations (e.g., dosage, route, laboratory trajectories) to advance causal inference in observational health data.
Anticipated developments include:
- External validation across multi-system EHR sources.
- Refined causal modeling for time-dependent covariates.
- Architectures robust to lab and medication attribute sparsity.
- Improved reproducibility and computational efficiency for large-scale EHR inference.
Conclusion
This work establishes a reproducible and interpretable pipeline for dialysis risk prediction and medication effect estimation in AKI trajectories by unifying transformer-based sequence modeling and counterfactual inference. Moderate discrimination and ingredient-level clinical validation underscore the utility of the framework while highlighting the enduring challenges of causal attribution in observational EHR research. Future extensions should focus on external reproducibility, enriched feature modeling, and advanced causal methodologies to move beyond hypothesis-generation toward actionable clinical decision support.
(2604.24547)