[R] Kaplan-Meier function from survfit

Marc Schwartz marc_schwartz at comcast.net
Sat Dec 6 04:35:03 CET 2008


on 12/05/2008 09:10 PM Ritwik Sinha wrote:
> Hi All,
> 
> Please pardon me if I am missing something obvious here. How do I get
> the Kaplan-Meier estimate function that is created by survfit and
> plotted by the code.
> 
> fit <- survfit(Surv(time, status) , data=aml)
> plot(fit)
> 
> That is, I need a function that will give me the survival estimate at
> a given time: \hat{S}(t).
> 
> Thanks in advance.
> 
> Ritwik Sinha


See:

library(survival)
?summary.survfit

and note the 'times' argument.

fit <- survfit(Surv(time, status) , data = aml)

> summary(fit)
Call: survfit(formula = Surv(time, status), data = aml)

 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    5     23       2   0.9130  0.0588       0.8049        1.000
    8     21       2   0.8261  0.0790       0.6848        0.996
    9     19       1   0.7826  0.0860       0.6310        0.971
   12     18       1   0.7391  0.0916       0.5798        0.942
   13     17       1   0.6957  0.0959       0.5309        0.912
   18     14       1   0.6460  0.1011       0.4753        0.878
   23     13       2   0.5466  0.1073       0.3721        0.803
   27     11       1   0.4969  0.1084       0.3240        0.762
   30      9       1   0.4417  0.1095       0.2717        0.718
   31      8       1   0.3865  0.1089       0.2225        0.671
   33      7       1   0.3313  0.1064       0.1765        0.622
   34      6       1   0.2761  0.1020       0.1338        0.569
   43      5       1   0.2208  0.0954       0.0947        0.515
   45      4       1   0.1656  0.0860       0.0598        0.458
   48      2       1   0.0828  0.0727       0.0148        0.462


> summary(fit, times = seq(0, 48, 6))
Call: survfit(formula = Surv(time, status), data = aml)

 time n.risk n.event survival std.err lower 95% CI upper 95% CI
    0     23       0   1.0000  0.0000       1.0000        1.000
    6     21       2   0.9130  0.0588       0.8049        1.000
   12     18       4   0.7391  0.0916       0.5798        0.942
   18     14       2   0.6460  0.1011       0.4753        0.878
   24     11       2   0.5466  0.1073       0.3721        0.803
   30      9       2   0.4417  0.1095       0.2717        0.718
   36      5       3   0.2761  0.1020       0.1338        0.569
   42      5       0   0.2761  0.1020       0.1338        0.569
   48      2       3   0.0828  0.0727       0.0148        0.462


HTH,

Marc Schwartz



More information about the R-help mailing list