Skip to content

drimransarmad/causal-inference-rwe-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Estimating the Effect of Early Right Heart Catheterization on 30-Day Mortality

A Reproducible Causal-Inference Workflow for Real-World Clinical Data Using Python

View the Fully Rendered Jupyter Notebook

View the fully rendered Jupyter Notebook

Project Overview

This project develops a transparent causal-inference workflow for estimating the effect of early right heart catheterization (RHC) on 30-day mortality among critically ill patients using observational clinical data.

The analysis emphasizes careful causal-question definition, transparent preprocessing, baseline-confounder assessment, propensity-score modeling, overlap diagnostics, stabilized inverse-probability-of-treatment weighting, covariate-balance assessment, doubly robust estimation, bootstrap confidence intervals, and sensitivity analysis.

The objective is not merely to compare observed mortality rates. The objective is to estimate a clinically meaningful treatment effect while documenting the assumptions and limitations of observational causal inference.

Dataset

The project uses the publicly available Right Heart Catheterization (RHC) dataset.

The analytical sample contains:

  • 5,735 critically ill patients
  • 2,184 patients receiving early RHC
  • 3,551 patients not receiving early RHC
  • 30-day mortality as the primary outcome

The treatment indicator represents early RHC during the initial period of intensive-care treatment.

Causal Question

Among critically ill patients, what is the estimated effect of early right heart catheterization on 30-day mortality after accounting for measured baseline differences between treated and untreated patients?

Primary Estimand

The primary estimand is the Average Treatment Effect (ATE).

The ATE represents the estimated difference in 30-day mortality if the study population were treated with early RHC compared with the estimated mortality if the same population were not treated, under the assumptions required for observational causal inference.

Analytical Workflow

The workflow includes:

  1. Causal-question and estimand definition
  2. Data loading and initial audit
  3. Transparent preprocessing of unusual baseline values
  4. Baseline-confounder specification
  5. Explicit categorical encoding
  6. Unadjusted covariate-balance assessment
  7. Propensity-score estimation
  8. Propensity-score overlap assessment
  9. Stabilized ATE weighting
  10. Weight diagnostics and effective-sample-size calculation
  11. Post-weighting covariate-balance assessment
  12. Primary stabilized-IPTW treatment-effect estimation
  13. Bootstrap confidence intervals with propensity-score re-estimation
  14. Doubly robust AIPW estimation
  15. Truncated-weight sensitivity analysis
  16. Empirical common-support restriction
  17. Publication-style figures and cautious interpretation

Initial Unadjusted Comparison

Treatment group Patients Observed 30-day mortality
No RHC 3,551 30.64%
RHC 2,184 38.00%

The unadjusted mortality difference was +7.36 percentage points.

This descriptive comparison should not be interpreted as a causal estimate because the treatment groups differed substantially in baseline clinical characteristics.

Baseline Imbalance Before Weighting

Before adjustment:

Diagnostic Result
Encoded baseline predictors assessed 71
Predictors with absolute SMD >= 0.10 35
Predictors with absolute SMD >= 0.20 16
Maximum absolute SMD 0.501

The strongest initial imbalances involved illness severity, blood pressure, oxygenation, diagnosis categories, organ-system indicators, and laboratory values.

Propensity-Score Overlap

The estimated propensity-score range was inspected before weighting.

Diagnostic Result
Empirical common-support range 0.0226 to 0.9751
Patients outside empirical common support 96
Patients below propensity score 0.05 355
Patients above propensity score 0.95 16

The treatment groups showed meaningful overall overlap, with limited concerns in the distribution tails.

Stabilized IPTW Diagnostics

Diagnostic Result
Mean stabilized weight 0.9947
Maximum stabilized weight 24.9137
Patients with stabilized weight above 5 33
Patients with stabilized weight above 10 6
Overall effective sample size 3,295.3

Post-Weighting Balance

After stabilized inverse-probability weighting:

Diagnostic Result
Predictors with absolute SMD >= 0.10 0
Predictors with absolute SMD >= 0.20 0
Maximum absolute SMD 0.067

The weighting strategy substantially improved comparability between the RHC and No-RHC groups across the measured baseline covariates.

Primary Stabilized-IPTW Results

Estimate Result
Weighted mortality: No RHC 31.20%
Weighted mortality: RHC 37.25%
Adjusted ATE risk difference +6.05 percentage points
95% bootstrap CI +2.72 to +9.04 percentage points
Adjusted risk ratio 1.194
95% bootstrap CI 1.084 to 1.300

After stabilized-IPTW adjustment, early RHC was associated with an estimated increase of 6.05 percentage points in 30-day mortality.

Robustness Analyses

Analytical approach Estimated risk difference 95% bootstrap CI
Primary stabilized IPTW +6.05 percentage points +2.72 to +9.04
Doubly robust AIPW +5.83 percentage points +2.91 to +9.20
Truncated-weight IPTW +6.07 percentage points +3.33 to +8.49
Empirical common-support restriction +6.03 percentage points +2.66 to +9.56

The adjusted estimates were closely aligned across complementary analytical approaches.

Publication-Style Figures

Propensity-Score Overlap Before Weighting

Propensity-score overlap

Covariate Balance Before and After Stabilized IPTW

Covariate-balance Love plot

Treatment-Effect Comparison Across Analytical Approaches

Treatment-effect comparison

Estimated Mortality Across Analytical Approaches

Mortality comparison

Robustness of the Adjusted Treatment-Effect Estimate

Robustness analysis

Interpretation Boundary

This project demonstrates a transparent observational causal-inference workflow.

The findings remain dependent on important assumptions, including:

  • adequate adjustment for measured confounders,
  • meaningful positivity and overlap,
  • appropriate model specification,
  • consistency of the treatment definition,
  • and the absence of important unmeasured confounding.

Propensity-score weighting and doubly robust estimation can reduce bias from measured confounding. They cannot eliminate bias from important unmeasured confounders.

The results should not be interpreted as:

  • definitive proof of a clinical treatment effect,
  • a clinical recommendation,
  • evidence applicable automatically to all patient populations,
  • or a substitute for randomized evidence and clinical expertise.

Tools Used

  • Python
  • pandas
  • NumPy
  • matplotlib
  • scikit-learn
  • Google Colab

Repository Files

Notebook

  • Causal_Inference_RWE_Python.ipynb

Figures

  • propensity_score_overlap_before_weighting.png
  • love_plot_covariate_balance_before_after_weighting.png
  • treatment_effect_comparison_risk_difference.png
  • mortality_comparison_across_estimators.png
  • adjusted_treatment_effect_robustness_analysis.png

Summary Tables

  • repository_file_inventory.csv
  • key_project_findings_summary.csv
  • covariate_balance_before_after_weighting.csv
  • primary_iptw_treatment_effect_point_estimates.csv
  • primary_iptw_bootstrap_confidence_intervals.csv
  • causal_estimator_comparison.csv
  • aipw_bootstrap_confidence_intervals.csv
  • weight_truncation_sensitivity_summary.csv
  • truncated_weight_bootstrap_confidence_intervals.csv
  • common_support_sensitivity_summary.csv
  • common_support_bootstrap_confidence_intervals.csv
  • consolidated_causal_sensitivity_analysis_summary.csv
  • treatment_effect_comparison_risk_difference.csv
  • mortality_comparison_across_estimators.csv
  • adjusted_treatment_effect_robustness_analysis.csv

Professional Positioning

This project supports the following professional positioning:

PhD Statistical Consultant | Advanced Quantitative Modeling (R, Mplus, Python)

The project demonstrates applied capability in causal inference for observational clinical and real-world evidence data, propensity-score methods, doubly robust estimation, bootstrap uncertainty analysis, sensitivity analysis, transparent reporting, and reproducible statistical computing in Python.

Professional website: https://drimransarmad.com

About

Reproducible clinical/RWE causal-inference workflow estimating the effect of early right heart catheterization on 30-day mortality using IPTW, doubly robust AIPW, overlap diagnostics, sensitivity analysis, and Python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors