Announcement

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

  • Drawing generic survivorship curves

    Hi all,

    I am working to draw some illustrative example survivorship curves as in the diagram attached. Note, these are slightly different form 'normal' survival curves in that everything goes to zero.


    Code:
    * simplest option?
    
    // clear all
    
    set obs 1000
    
    gen t = _n
    gen fail =  rbinomial(1, 0.1)
    tab fail
    
    stset t, fail(fail)
    
    sts graph, title("")
    sts gen surv1 = s
    twoway (lowess surv1 t, sort lpattern(solid) lwidth(thick) lcolor(orange))
    
    * more complex options
    // ssc install survsim
    
    clear all
    set obs 1000
    set seed 123
    gen treat = rbinomial(1,0.5)
    
    * lambda = scale; gamma = shape
     
    survsim time1 fail, lambdas (20) gammas(10) cov(treat 10) maxt(2)
    stset time1, fail(fail = 1)
    sts graph, by(treat) title("")
    
    clear all
    set obs 1000
    set seed 123
    gen treat = rbinomial(1,0.5)
    survsim time1 fail, lambdas (20) gammas(0.5) cov(treat 10) maxt(2)
    
    stset time1, fail(fail = 1)
    sts graph, by(treat) title("")
    exit
    However, I am struggling to get smooth nice-looking curves. Any ideas on better ways to attack this problem?

    thanks!
    Last edited by Andrew Lover; 12 Dec 2014, 14:05.
    __________________________________________________ __
    Assistant Professor, Department of Biostatistics and Epidemiology
    School of Public Health and Health Sciences
    University of Massachusetts- Amherst

  • #2
    It is not very clear what you want. But with a constant incidence rate (IR; here 0.02 per time unit T), the corresponding survival function is exp(-IR*T):

    Code:
    twoway function y=exp(-.02*x) , range(0 100)
    Is that what you are thinking of?

    Comment


    • #3
      Hello Svend,

      Thanks, that's certainly much closer to what I was hunting for:

      Code:
      tw (function y=exp(-.065*x) , range(0 100))
      tw (function y=-exp(0.065*x) , range(0 100))
      It always surprises me how limited the manuals are regarding -function-; I wasn't aware you could even call it directly inside -twoway-!

      cheers
      Last edited by Andrew Lover; 14 Dec 2014, 09:18.
      __________________________________________________ __
      Assistant Professor, Department of Biostatistics and Epidemiology
      School of Public Health and Health Sciences
      University of Massachusetts- Amherst

      Comment


      • #4
        The last of three examples in the manual entry shows a combination of twoway function and scatter with data.

        A tiny trick I often use for adding lines of equality over some range is

        Code:
        ... || function equality = x, ra(xwhatever)
        The text equality is then echoed to the legend.

        Comment


        • #5
          Thanks Nick, that's very helpful.
          Just to save others from the same confusion I had: Nick is referencing the manual entry for -twoway function- which has no links from the entry for -function- (as far as I can tell).
          __________________________________________________ __
          Assistant Professor, Department of Biostatistics and Epidemiology
          School of Public Health and Health Sciences
          University of Massachusetts- Amherst

          Comment

          Working...
          X