Announcement

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

  • risk table - why is everyone dying (not actually happening)

    Hello, I wonder if I'm coding this correctly

    I am plotting a risktable + KM curve for those who were revised==1

    Code:
    //value in days
    gen survivalt= revisiondates-OpDate
    
    gen survivalt2=survivalt/365
    stset survivalt2, failure(revised==1) 
    
    //Kaplan meir curve in terms of survival 
    sts graph, risktable
    However as you can see in this KM that at 15 years everyone is dying when it's not actually true. I suspect it because either the srurvialt2 is left as missing if patient did not have a revision revised=0 and therefore has no revisiondate=.

    Am i correct in saying this and if not what is your advice

    Click image for larger version

Name:	Screenshot 2024-05-16 at 11.11.49.png
Views:	1
Size:	638.5 KB
ID:	1753538



    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(OpDate revisiondates revised survivalt survivalt2) byte(_st _d) double _t byte _t0
    17783 17839 1   56 .15342465 1 1 .15342465043067932 0
    17947 21967 1 4020   11.0137 1 1  11.01369857788086 0
    17904     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
    17482 22466 1 4984 13.654795 1 1 13.654794692993164 0
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
    17932 21566 1 3634  9.956164 1 1  9.956164360046387 0
    17497 22945 1 5448 14.926027 1 1 14.926027297973633 0
    17518 19121 1 1603  4.391781 1 1  4.391780853271484 0
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
        .     . 0    .         . 0 .                  . .
    17504     . 0    .         . 0 .                  . .
    17474 17508 1   34 .09315068 1 1 .09315068274736404 0
        .     . 0    .         . 0 .                  . .
    17381 19359 1 1978  5.419178 1 1  5.419178009033203 0
        .     . 0    .         . 0 .                  . .
    19015     . 0    .         . 0 .                  . .
    19016 22210 1 3194  8.750685 1 1   8.75068473815918 0
    end
    format %td OpDate
    format %td revisiondates

  • #2
    Yes, you guessed correctly.

    If I understand correctly, the 3rd observation (Opdate 17904) did not have a revision and was alive at the end of the study. You need to add the exit date (censoring date) for these individuals.

    If it's a common date (e.g., last day of 2022) then you could just use code like the following:

    Code:
    keep OpDate revisiondates revised
    generate exitdate=min(revisiondates,mdy(12,31,2022))
    format %td OpDate revisiondates exitdate
    generate survivalt=exitdate-OpDate
    stset survivalt, failure(revised==1) scale(365.24) 
    
    //Kaplan-Meir curve in terms of survival 
    sts graph, risktable
    If there are individual censoring dates then you need to create a variable for that.

    Noe that I used the scale() option to stset rather than creating a new time variable.

    Comment

    Working...
    X