Announcement

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

  • Superimposing Kaplan-Meier failure curves for 2 outcomes

    Hi,

    I'm trying to superimpose Kaplan-Meier curves for two separate outcomes, and I'd like the flip the curves so that they show "failure" instead of survival, as such:

    Click image for larger version

Name:	Ex1.png
Views:	1
Size:	34.9 KB
ID:	1498651

    I've tried using addplot and I've tried using the code below, but I'm only able to get superimposed standard survival curves- I'm not able to flip both of them. I've seen another similar example on Statalist that used Nelson-Aalen curves, but I'd like to use Kaplan Meier. Since I have two separate outcomes rather than two separate exposures, I don't think graphing using "by()" would be helpful.
    Anyone know how to do this?

    Thanks!
    -Jenine


    Code:
    stset followuptime, failure(outcome1==1) id(id)
    sts graph, failure risktable(0(2)12) 
    sts gen s1 = s
    
    stset followuptime, failure(outcome2==1) id(id)
    sts gen s2 = s
    twoway line s1 s2 _t, sort connect(step step)
    Click image for larger version

Name:	Ex2.png
Views:	1
Size:	35.6 KB
ID:	1498650

  • #2
    Maybe I'm missing something, but won't the following work?

    Code:
    generate f1=1-s1 
     generate f2=1-s2 twoway line f1 f2 _t, sort connect(step step)
    This won't give you the risk table. To do that you could use sts graph with the addplot() option (making it clear the the numbers at risk are for just one of the outcomes).

    Comment


    • #3

      If you want the risktable by sts graph
      Code:
      sts , failure risktable by(outcome)
      should work if you have one record with ( _t0, _t, _d ) for each outcome for every subject (do not use the stset id() argument):
      Code:
        +--------------------------------------------------+
        | pid   _t0   _t   _d   studytime   event   second |
        |--------------------------------------------------|
        |  10     0    8    0           8       0        0 |
        |  10     0    4    1           4       1        1 |
        +--------------------------------------------------+
      Example data:
      Code:
      sysuse cancer , clear
      keep if drug == 1
      gen pid = _n
      expand 2 , gen(second) /* dublicate data */
      replace died = 1 if second /* all subjects experience the second failure event */
      replace studytime = studytime * .5 if second == 1 /* second event before first event */ 
      rename died event 
      streset , fail(event) /* update stset */
      
      sts , failure risktable by(second)

      Comment


      • #4
        I'm going back to this problem now and just noticed these responses- thank you! Paul, your solution is exactly what I need!

        Comment

        Working...
        X