Learn R Programming

survMisc (version 0.4.2)

quantile: Quantiles and median for Surv and survfit objects

Description

Quantiles and median for Surv and survfit objects

Usage

quantile(x, ...)

  ## S3 method for class 'Surv':
quantile(x, ..., q = c(25, 50, 75),
    alpha = 0.05)

  ## S3 method for class 'survfit':
quantile(x, ..., q = c(25, 50, 75),
    alpha = 0.05)

  ## S3 method for class 'coxph':
quantile(x, ..., q = c(25, 50, 75),
    alpha = 0.05)

  median(x, ...)

  ## S3 method for class 'Surv':
median(x, ..., CI = FALSE, alpha = 0.05,
    method = c("log", "lin", "asr"))

  ## S3 method for class 'survfit':
median(x, ..., CI = FALSE,
    alpha = 0.05, method = c("log", "lin", "asr"))

  ## S3 method for class 'coxph':
median(x, ..., CI = FALSE, alpha = 0.05,
    method = c("log", "lin", "asr"))

Arguments

x
A Surv or survfit object
...
Additional arguments
q
(for quantile) Vector of quantiles (expressed as percentage).
alpha
Significance level $\alpha$
CI
(for median) include confidence interval
method
(for median) method for confidence interval, as below. One of log, linear or arcsine-square root.

Value

  • For quantile: For a Surv object, a data.frame with quantile, and upper and lower confidence intervals using the 3 methods. For a survfit object, a list with one element for each stratum. Each element is a data.frame as above. For median: For a Surv object, the median time. For a survfit object a data.frame with one row for each stratum. If CI = TRUE then upper and lower confidence intervals with one method (default is log).

Details

Confidence intervals are calculated from $\sigma$ which is: $$\sigma (t) = \sqrt{ \frac{Var[\hat{S}(t)]}{\hat{S}^2(t)}}$$ The intervals are:
  • linear$$\hat{S}(t) \pm Z_{1- \alpha} \sigma (t) \hat{S}(t)$$Where$\hat{S}(t)$is the Kaplan-Meier survival estimate.
  • log transform$$[ \hat{S}(t)^{\frac{1}{\theta}}, \hat{S}(t)^{\theta} ]$$Where$\theta$is:$$\exp{ \frac{Z_{1- \alpha} \sigma (t)}{ \log{\hat{S}(t)}}}$$
  • Arcsine-square root transform. Upper:$$\sin^2(\max[0, \arcsin{\sqrt{\hat{S}(t)}} - \frac{Z_{1- \alpha}\sigma(t)}{2} \sqrt{ \frac{\hat{S}(t)}{1-\hat{S}(t)}}])$$Lower:$$\sin^2(\min[\frac{\pi}{2}, \arcsin{\sqrt{\hat{S}(t)}} + \frac{Z_{1- \alpha}\sigma(t)}{2} \sqrt{ \frac{\hat{S}(t)}{1-\hat{S}(t)}}])$$

References

Examples for quantiles are from: Klein J, Moeschberger M 2003 Survival Analysis, 2nd edition. New York: Springer. Example 4.2, pg 121.

Examples

Run this code
data(bmt, package="KMsurv")
b1 <- bmt[bmt$group==1, ] # ALL patients
s1 <- Surv(time=b1$t2, event=b1$d3)
quantile(s1)
b1 <- bmt[bmt$group==2, ] # AML low-risk patients
s1 <- Surv(time=b1$t2, event=b1$d3)
quantile(s1)
b1 <- bmt[bmt$group==3, ] # AML high-risk patients
s1 <- Surv(time=b1$t2, event=b1$d3)
quantile(s1)
###
s1 <- survfit(Surv(t2, d3)~ group, data=bmt)
quantile(s1)
###
c1 <- coxph(Surv(t2, d3)~ group, data=bmt)
quantile(c1)
b1 <- bmt[bmt$group==1, ] # ALL patients
s1 <- Surv(time=b1$t2, event=b1$d3)
median(s1)
median(s1, CI=TRUE)
data(bmt, package="KMsurv")
b1 <- bmt[bmt$group==1, ] # ALL patients
s1 <- survfit(Surv(t2, d3)~ group, data=bmt)
median(s1)
median(s1, CI=TRUE, method="asr")
c1 <- coxph(Surv(t2, d3) ~ group, data=bmt)
median(c1)

Run the code above in your browser using DataLab