Detour#

To create two overlaid Kaplan-Meier survival curves showing hospital length of stay (LOS) for living kidney donors and a control population over 50 years old, the process can be broken into key steps:


Steps to Achieve the Kaplan-Meier Curves#

  1. Prepare the Dataset:

    • Use the National Inpatient Sample (NIS) to extract relevant records.

    • Identify two groups:

      • Group 1: Living kidney donors, age > 50.

      • Group 2: Control population, age > 50, excluding individuals with diagnoses related to kidney donation or severe kidney disease.

    • Extract columns:

      • Patient ID

      • Hospital LOS (as the event time, capped at 30 days)

      • Event indicator (0 for censored, 1 for discharge).

  2. Subset and Filter Data:

    • Restrict the dataset to patients aged > 50.

    • Exclude patients with missing LOS data or inappropriate discharge statuses (e.g., against medical advice).

  3. Define Censoring:

    • Any patient still hospitalized after 30 days should be censored (event = 0).

  4. Group Matching (Optional but Recommended):

    • Use propensity score matching (age, gender, comorbidities) to balance the two groups, ensuring comparability between donors and controls.

  5. Fit Kaplan-Meier Models:

    • Fit separate Kaplan-Meier survival models for:

      • Living kidney donors (Group 1).

      • Control population (Group 2).

  6. Overlay Survival Curves:

    • Plot the two Kaplan-Meier curves on the same axis for direct comparison.

    • Time scale: Daily intervals from 0 to 30 days.

  7. Statistical Comparison:

    • Use the log-rank test to assess the statistical significance of differences in LOS between the two groups.

  8. Label and Customize the Plot:

    • X-axis: Time (Days).

    • Y-axis: Survival Probability (Proportion still hospitalized).

    • Add a legend to distinguish the two groups.


Expected Outcome#

The Kaplan-Meier plot will visually display:

  • Proportion of patients remaining hospitalized over time for each group.

  • Differences in LOS patterns between kidney donors and the control group.

If you provide the NIS dataset or a sample of it, I can preprocess it and generate these Kaplan-Meier curves for you. Let me know if you’d like assistance in writing the code or running the analysis!