Confidence interval before the first event in a Kaplan–Meier curve The confidence intervals for Kaplan–Meier curves in survival analysis only exist for times after the first (non-censored) event. Example R code:
set.seed(1)
library(survival)
n = 30
x = 10 + sort(10*rexp(n))
u = rep(0, n)
u[15] = 1
l = survfit(Surv(x,u)~1)
plot(l)


While the actual Kaplan–Meier curve is well defined for all time points, the (pointwise) confidence intervals seems to be undefined for all time points earlier than ∼18.
However, it seems reasonable to at least try to calculate confidence intervals even for these early time points. For example, if we’re interested in the time point 10, we observe that out of 30 possible events, non occurred before time 10, so using the rule of three, a simple approximate confidence interval for survival to (at least) time 10 is [1−3/30, 1] = [0.9, 1]. Surely this is better than no confidence interval at all.
For time points between 10 and 18, however, there are several censored observations. Is it still possible to to calculate sensible confidence intervals? Or are these censored observations the reason that software packages don’t show any confidence intervals for time points earlier than the first non-censored event.
 A: Various ways to estimate Kaplan-Meier (KM) confidence intervals (CI) in difficult situations like this--before the first event time, with heavy censoring, or at late times when few are still at risk--have been discussed by Fay et al., "Pointwise confidence intervals for a survival distribution with small samples or heavy censoring," Biostatistics (2013), vol. 14, no. 4, pp. 723–736. Such estimates are possible with some CI methods, they just aren't provided by the default method in the survival package. For example, in the absence of censoring the binomial Clopper-Pearson exact interval for observing no events out of the total number of events, essentially as described in the question and in another answer, could be used.
With censoring, as frequently occurs in survival analysis, things become more complicated. Fay et al. compare 10 KM CI methods against the "beta product confidence procedure (BPCP)" method they propose. BPCP is based on quantiles of a product of beta random variables that is defined in terms of the numbers at risk at each event time up to the survival time of interest. They show that their method provides correct CI coverage for the above types of difficult situations, under some assumptions. They argue for its superiority over other methods if censoring times are simply independent of failure times, and (in a supplement) document its asymptotic equivalence to the Nelson-Aalen and Greenwood CI estimates.
There is an implementation in the R bpcp package. This implementation includes some extensions made since the paper cited above, including two-sample comparisons and handling of discrete-time data.
A: seems to me that there should be a way to compute confidence interval on survival prior to the first failure using likelihood concept
the likelihood of seeing $k=0$ zero failures from $n$ units is given by binomial probability probability mass function $B(n,p)$ https://en.wikipedia.org/wiki/Binomial_distribution
if $\alpha$ is 1-tailed confidence level, the corresponding pre-fails survival probability $S_\alpha$  lower confidence bound should be $\alpha^{\frac{1}{n+1}}$for population of size $n$
for example 60% confidence bound for 30 units would be 0.6^(1/31) = 0.984
