| confIntKM | R Documentation | 
Computes Wald confidence intervals for a Kaplan-Meier survival curve at
a fixed time point. The variance is computed according to Peto's formula and the
confidence interval is computed using a logit-transformation, to ensure that
it lies in (0, 1). Alternatives are given in the examples
below.
confIntKM(time, event, t0, conf.level = 0.95)
| time | Event times, censored or observed. | 
| event | Censoring indicator, 1 for event, 0 for censored. | 
| t0 | Numeric vector of time points to compute confidence interval for. | 
| conf.level | Confidence level for confidence interval. | 
A matrix with the following columns:
| t0 | Time points. | 
| S_t0 | Value of survival curve at  | 
| lower.ci | Lower limits of confidence interval(s). | 
| upper.ci | Upper limits of confidence interval(s). | 
The variance according to Peto's formula tends to be more conservative than that based on Greenwood's formula.
Kaspar Rufibach 
 kaspar.rufibach@gmail.com
## use Acute Myelogenous Leukemia survival data contained in package 'survival'
time <- leukemia[, 1]
event <- leukemia[, 2]
formula <- Surv(time = time, event = event) ~ 1
plot(survfit(formula = formula, conf.type = "none"), mark = "/", col = 1:2)
confIntKM(time = time, event = event, t0 = c(10, 25, 50), conf.level = 0.95)
## an alternative is the log-log confidence interval using Greenwood's
## variance estimate
t0 <- 10
fit <- survfit(formula = formula, conf.int = 0.95, conf.type = "log-log", 
               type = "kaplan", error = "greenwood")
dat <- cbind(fit$time, fit$surv, fit$lower, fit$upper)
dat <- dat[dat[, 1] >= t0, ]
dat[1, 3:4]
## this same confidence interval can also be computed using the 
## package km.ci
if(require(km.ci)) {
    ci.km <- km.ci(survfit(formula = formula), conf.level = 0.95,
                   method = "loglog")
    dat.km <- cbind(ci.km$time, ci.km$surv, ci.km$lower, ci.km$upper)
    dat.km <- dat.km[dat.km[, 1] >= t0, 3:4]
    dat.km[1, ]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.