# [R] confidence interval for survfit

Terry Therneau therneau at mayo.edu
Fri Mar 15 15:01:27 CET 2013

```The first thing you are missing is the documentation -- try ?survfit.object.
fit <- survfit(Surv(time,status)~1,data)
fit\$std.err will contain the standard error of the cumulative hazard or -log(survival)

The standard error of the survival curve is approximately S(t) * std(hazard), by the delta
method.  This is what is printed by the summary function, because it is what user's
expect, but it has very poor performance for computing confidence intervals.  A much
better one is exp(-1* confidence interval for the cumulative hazard), which is the
default.  In fact there are lots of better ones whose relative ranking depends on the
details of your simulation study.  About the only really consistent result is that
anything thoughtful beats S(t) +- 1.96 se(S), easily.  The default in R is the one that
was best in the most recent paper I had read at the time I set the default.  If I were to
rank them today using an average over all the comparison papers it would be second or
third, but the good methods are so close that in practical terms it hardly matters.

Terry Therneau

On 03/15/2013 06:00 AM, r-help-request at r-project.org wrote:
> Hi, I am wondering how the confidence interval for Kaplan-Meier estimator is calculated by survfit(). For example,?
>
>> >  summary(survfit(Surv(time,status)~1,data),times=10)
> Call: survfit(formula = Surv(rtime10, rstat10) ~ 1, data = mgi)
>
> ?time n.risk n.event survival std.err lower 95% CI upper 95% CI
> ?? 10 ?? 168????? 55??? 0.761? 0.0282??????? 0.707??????? 0.818
>
>
> I am trying to reproduce the upper and lower CI by using standard error. As far I understand, the default method for survfit() to calculate confidence interval is on the log survival scale, so:
>
>
> upper CI = exp(log(0.761)+qnorm(0.975)*0.0282) = 0.804
> lower CI = exp(log(0.761)-qnorm(0.975)*0.0282) = 0.720
>
>
> they are not the same as the output from survfit().
>
> Am I missing something?
>
> Thanks
>
> John

```