Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plot bootstrapped survival curves

    Dear Statalist,

    Is there a way to plot multiple survival curves after using a Cox model with bootstrap? I mean, to plot 100 (or any other) replicates from bootstrap in a single Kaplan-Meier graph.
    I was thinking of the next pseudocode:

    * stset date2, failure(event==1) origin(date1) id(id)
    * stcox my_variable, vce(bootstrap, reps(100) seed(1234))
    * sts gen s_myvar = f, by(my_variable)
    * sort _t
    * twoway connected s_myvar _t

    I do not know how to integrate the last three lines to get the estimates from each of the 100 bootstrap replicate so I can plot them into a single Kaplan-Meier.
    Thank you!

  • #2
    Hi, DF.

    Your problem was explained vaguely. I am not sure if this is the best solution (you must check if it makes sense from a statistical point of view. I am not familiar with bootstrapping time-to-event outcomes), but (initially) I would approach your problem as follows:

    1. Generate the main survival curve and save it.
    2. Loop N times (for i = 1,...,100), every time getting a bootstrapped sample.
    3. For each iteration (boostrap), fit the Cox model
    4. Save the survival function in a temporary dataset:
    Code:
     stcurve, survival at1(covariate=1) outfile(iteration`i', replace)
    5. Append the N saved survival curves, identifiying them with an ID
    6. Plot the results via -spagplot-
    7. Highlight the main survival curve (which I believe should be plot 1)

    Hope this gives you some direction.

    Of course you will have to adapt the algorithm above, since you have two or more groups/exposures.
    Last edited by Tiago Pereira; 26 Jul 2023, 10:41.

    Comment

    Working...
    X