Announcement

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

  • Superimposing observed and predicted Weibull survivor function graphs

    Hi
    I was wondering if there is a simple way to superimpose observed and fitted Weibull survivor functions onto the one graph. I am trying to reproduce Figure 10.1 in David Collett's book "Modelling survival data in medical research" 3rd Edition. This is a study of survival in breast cancer patients with 2 types of stain on their histological specimens.
    This is the dataset:
    Code:
    clear
    input float(stain time status)
    1  23 1
    1  47 1
    1  69 1
    1  70 0
    1  71 0
    1 100 0
    1 101 0
    1 148 1
    1 181 1
    1 198 0
    1 208 0
    1 212 0
    1 224 0
    2   5 1
    2   8 1
    2  10 1
    2  13 1
    2  18 1
    2  24 1
    2  26 1
    2  26 1
    2  31 1
    2  35 1
    2  40 1
    2  41 1
    2  48 1
    2  50 1
    2  59 1
    2  61 1
    2  68 1
    2  71 1
    2  76 0
    2 105 0
    2 107 0
    2 109 0
    2 113 1
    2 116 0
    2 118 1
    2 143 1
    2 154 0
    2 162 0
    2 188 0
    2 212 0
    2 217 0
    2 225 0
    end
    And this the code for the two graphs I want superimposed.
    Code:
    stset time, failure(status==1)
    streg i.stain, distribution(weibull)
    sts graph, by(stain)
    stcurve, survival at1( stain=1 ) at2( stain=2 )
    Thanks and regards

    Chris

  • #2
    Both -sts graph- and -stcurve- have an -addplot()- option, but unfortunately the plot to be added must be a -twoway- plot, which is not the case here.

    One solution is to compute the Weibul fits using -predict- and then superimpose them on the Kaplan-Merier curves from -sts graph- using -addplot- with -line-

    Code:
    predict ws, surv
    sts graph, by(stain) addplot(line ws _t if stain==1 || line ws _t if stain==2)
    The other way around is to save the Kaplan-Meier curves using -sts gen- and then superimpose them on the Weibull fits from -stcurve- using -addplot- with -line-

    Code:
    sts gen km = s, by(stain)
    stcurve, survival at1( stain=1 ) at2( stain=2 )  ///
      addplot(line km _t if stain==1, c(stair) || line km _t if stain==2, c(stair))
    In both cases the predicted survival curves do not start at time 0, but at the lowest observed _t in each group. This can be fixed by adding two dummy observations with stain=1 and 2, and _t0 = _t = 0, km = ws = 1, and sorting. Personally, I think the first option works well without this fix. The legend, however, can be improved.

    Comment


    • #3
      Thanks German,
      That's really elegant!
      Rergards
      Chris

      Comment

      Working...
      X