[R] Survival Rate Estimates

David Winsemius dwinsemius at comcast.net
Thu May 12 22:38:31 CEST 2011


On May 12, 2011, at 2:19 PM, David Winsemius wrote:

>
> On May 12, 2011, at 12:40 PM, Brian McLoone wrote:
>
>> Dear List,
>>
>> Is there an automated way to use the survival package to generate  
>> survival
>> rate estimates and their standard errors?  To be clear, *not *the
>> survivorship estimates (which are cumulative), but the survival  
>> *rate *
>> estimates...
>
> Not entirely clear, but from context I suspect you mean  
> instantaneous hazard?
>
> (Survival is not a rate but rather a proportion. Mortality can be a  
> rate. The instantaneous hazard is the decrement in survival per unit  
> time divided by the survival to that time.)
>
> So at each death the non-parametric estimate would divide current  
> deaths (often 1 but ties are possible) by time since last death and  
> then divide by proportion surviving.
>
> Or if you have a semi-parametric estimated function for survival  
> (such as might be output from `basehaz` which calls `survfit`) take:
>
> -delta_survival/delta_time/survival
>
> tdata <- data.frame(time =c(1,1,1,2,2,2,3,3,3,4,4,4),  
> status=rep(c(1,0,2),4), n =c(12,3,2,6,2,4,2,0,2,3,3,5))
> fit <- survfit(Surv(time, time, status, type='interval') ~1,  
> data=tdata, weight=n)
> > T <- c(0, fit$time)

I was doing something else in this session and realized that using 'T'  
was _not_ a good choice here.

 > T == TRUE
[1] FALSE  TRUE FALSE FALSE FALSE

I (almost) always spell out TRUE but not everyone does. Better to use  
'sT' or <almost anything else>.
(But don't use: c, df, C, F, pi, rm, t, qt, pt, rt, dt,, df, rf,  
qf, ... )

 > rm(T)
 > T == TRUE
[1] TRUE

-- 
David.


> > S <- c(1, fit$surv)
> > (-diff(S)/diff(T) )/fit$surv
> [1] 0.8602308 0.8247746 0.4044324 1.2115931
>
> I don't know if Therneau's opinion about estimating smoothed hazards  
> has changed:
> http://finzi.psych.upenn.edu/Rhelp10/2009-March/193104.html
> There is also a muhaz package which may generate standard errors for  
> its estimates but I have read elsewhere that is does not do Cox  
> models.
> http://finzi.psych.upenn.edu/R/library/muhaz/html/00Index.html
> --
>
> David Winsemius, MD
> West Hartford, CT
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list