Announcement

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

  • Integral for mean survival time (streg postestimation)

    Hello,

    I have a dataset on student attendance and drop out rates for a certain set of courses, and I've used streg with a Weibull distribution to calculate the mean survival time (in days). All students complete or drop out of the course within two years, so I don't have to worry about censoring for completed cohorts when using the mean survival time. I'm trying to create a forecast for each student currently enrolled on the expected number of days that they will remain in class given that they have achieved their current number of days, but the streg mean time calculation in the Stata manual (http://www.stata.com/manuals13/ststr...estimation.pdf page 8) just integrates from 0 to ∞ with no option to integrate from the current number of days that they've been in class. I've installed stpm2, but mean time is not an allowed option. Any thoughts?

    v/r,

    Garrett Harmon
    Last edited by Garrett Harmon; 27 Apr 2015, 13:46.

  • #2
    Ended up solving the problem for future reference of anyone else that may need to do this. The stpm2 guide (http://www.stata-journal.com/sjpdf.h...iclenum=st0165) doesn't mention that you can use rmst as a postestimation option on predict for stpm2. All you need to do is run two predict commands, one with no time option for RMST, and another with the current time of your subject, then subtract the two. If anyone reading this has the ability to update the guide, it'd be helpful to have a current version listing the full set of options.

    Comment


    • #3
      I see the timevar() option for predict after stpm2, but I can't quite tell what you did. Please show all commands, starting with stset.

      Thanks
      Last edited by Steve Samuels; 28 Apr 2015, 10:17.
      Steve Samuels
      Statistical Consulting
      [email protected]

      Stata 14.2

      Comment


      • #4
        After some testing, here's a simple example of what I came up with:

        Code:
        clear
        webuse brcancer
        gen recyears = trunc(rectime/365.25)
        stset recyears, f(censrec=1)
        rename x1 age
        stpm2 hormon age, scale(hazard) df(1)
        
        gen restrictmean=.
        forvalues i=1/10 {
        predict placeholder, rmst tmax(`i') n(100)
        replace restrictmean=placeholder if censrec==0 & recyears ==`i'
        drop placeholder
        local i=`i'+1
        }
        predict meansurvt0, rmst
        predict surv_t, survival timevar(recyears)
        gen integraldiff=meansurvt0-restrictmean
        gen additionalyears=integraldiff/surv_t
        The "additionalyears" variable is the expected number of additional years given survival to time _t for observations that have not yet experienced an event.
        Last edited by Garrett Harmon; 12 Jun 2015, 08:44.

        Comment

        Working...
        X