Announcement

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

  • Kaplan Meier estimator show risktable including number of participants censored

    Dear community,

    I have created a Kaplan Meier estimator with sts graph that includes a risktable. I would like the risktable to include not only numbers of participants at risk, but also numbers of participants censored at each timepoint, somewhat like this: https://towardsdatascience.com/kapla...s-c5768e349479
    How can I do this? Or at the very least add a hash to each censoring event while keeping the risktable?

    My code is:
    Code:
    sts graph, by(rand) risktable(, order(1 "verum" 2 "placebo") rowtitle(, justification(left))) title("Kaplan-Meier curve randomized-controlled trial") subtitle("Time to event") ytitle("Probability of survival") xtitle("Time from randomisation (days)") ylabel(0(0.1)1, angle(horizontal)) xlabel(0 "0" 86400000 "1" 172800000 "2" 259200000 "3" 345600000 "4" 432000000 "5" 518400000 "6" 604800000 "7")
    Thank You in advance
    Last edited by Dorothea Ekoka Mbassi; 15 Dec 2022, 05:03.

  • #2
    Don't you get that from the suboption -failevents-? See

    Code:
    help sts_graph
    Code:
    sts graph, by(rand) risktable(, failevents order(1 "verum" 2 "placebo") ...)

    Comment


    • #3
      Dear Andrew,

      The suboption -failevents- summarizes all failures, I'd however prefer to specify the numbers lost by censoring. -failevents- summarizes dropouts due to events as well as censoring.
      The commands -enter- or -censored()- should be able to do that, however I cannot get them to work without dropping my risktable that I'd like to maintain.

      Any further ideas?

      Comment


      • #4
        PS: Maybe this is also an issue with stset. Here is what I set:

        Code:
        stset exitdatetime10TBS, enter(entrydatetime) origin(entrydatetime) failure(censored10TBS)
        However, only participants with censored10TBS==0 are censored. There's 2 of them in my dataset of 29 participants. However, if I set failure(censored10TBS==0) my graph looks very weird and loses all sense. If I set failure (censored10TBS==1), -failevents- renders the same numbers as observed above (dropouts due to event and censoring combined), while there is supposed to be only to failures/censorings to be displayed.
        How can I fix this? I want only the 2 participants that have -0- for the variable censored10TBS to be considered as failure/censored.

        Comment


        • #5
          It appears possible, except that the censored values may be randomly placed and may not align with the axis values. Also, being close to each other, it may not be feasible to add parentheses around these values. Note that you can indicate these values using the option -censored(number)- within the graph. Here is a way using the -addplot()- option, where you have to fiddle around with the y-axis position to find where to place them. You can add a note, e.g., "censored values shown in red" below.

          Code:
          webuse drug2b, clear
          bys _t: egen censored= total(!_d)
          *SPECIFY Y-AXIS POSITION
          local pos -.4
          gen pos= cond(!_d, `pos', _d)
          set scheme s1color
          sts graph, risktable( , color(navy))  ///
          addplot(scatter pos _t if pos<0, mlab(censored) ///
          mlabpos(0) msy(none) mlabc(red) mlabs(3.5))  ///
          graphregion(margin(5 5 10 5)) leg(off)
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	23.4 KB
ID:	1693700


          Last edited by Andrew Musau; 15 Dec 2022, 09:06.

          Comment


          • #6
            Thank You!

            Comment

            Working...
            X