In R, the survival fit object gives the non-parametric MLE for the survival curve via the Kaplan-Meier estimator. The fit also provides a confidence interval. What is the expression for the confidence interval, or where is the reference, to reproduce the method?

enter image description here

leukemia.surv <- survfit(Surv(time, status) ~ 1, data = aml, subset=x=='Nonmaintained') 

2 Answers 2


The default starts with the Nelson-Aalen cumulative hazard estimate $\hat\Lambda(t)$, taking the square root of its variance estimate to get a standard error. If $\Delta \bar N(t_i)$ is the number of events at time $t_i$ and $\bar Y(t_i)$ the number then at risk, the variance estimate is:

$$\text{var}\left[ \hat\Lambda(t) \right] = \sum_{i:t_i \le t} \frac{\Delta \bar N(t_i)}{\bar Y^2(t_i)}.$$

That's Equation 2.4 of Therneau and Grambsch, as recommended by Gavin Simpson; see the corresponding C code, at about line 200 in its current incarnation.

That standard error is then transformed to confidence intervals as specified by a conf.type argument, with "log" as the default. That default "calculates intervals based on the cumulative hazard or log(survival)," according to the manual page. Code in R implementing the conf.type options for a given standard error is visible in survival:::survfit_confint.


The survival package is support software for

Terry M. Therneau, Patricia M. Grambsch (2000). Modeling Survival Data: Extending the Cox Model. Springer, New York. ISBN 0-387-98784-3.

And I suspect that would be the best place to start with the detail of what is implemented in these functions. There are more conceptual details in ?survfit.formula including what method is used bye default ("log" which bases the CI on the log(survival)).

As it happens I saw this YouTube video the other day that covers some of the details of how these confidence intervals are computed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.