Learn R Programming

survMisc (version 0.4.6)

quantile: Quantiles and median for Surv, survfit and coxph objects

Description

Extends stats::quantile and stats::quantile to work with Surv, survfit and coxph objects.

Usage

quantile(x, ...)

## S3 method for class 'Surv': quantile(x, ..., q = c(25, 50, 75), CI = TRUE, alpha = 0.05, ci = c("log", "lin", "asr"))

## S3 method for class 'survfit': quantile(x, ..., q = c(25, 50, 75), CI = TRUE, alpha = 0.05, ci = c("log", "lin", "asr"))

## S3 method for class 'coxph': quantile(x, ..., q = c(25, 50, 75), CI = TRUE, alpha = 0.05, ci = c("log", "lin", "asr"))

median(x, ...)

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

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

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

Arguments

x
A Surv, survfit or coxph object.
...
Additional arguments (not implemented).
q
(for quantile) Vector of quantiles (expressed as percentage). For the median, q=50.
CI
Include confidence interval. Defaults are CI=TRUE for quantile and CI=FALSE for median.
alpha
Significance level $\alpha$.
ci
Confidence interval. One of: log (the default), linear or arcsine-square root.

Value

  • For quantile: A data.table (or a list of data.tables, one per stratum), with columns:
  • qquantile
  • ttime
  • If CI = TRUE then upper and lower confidence intervals, as per argument ci).
  • llower confidence limit
  • uupper confidence limit
  • For median: A data.table with columns:
  • ttime
  • sstratum
  • If CI = TRUE then a list of data.tables, one per stratum, as above.

References

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

See Also

Confidence intervals are calculated as shown in the pointwise confidence intervals in ci.

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="asr", CI=TRUE)
c1 <- coxph(Surv(t2, d3) ~ group, data=bmt)
median(c1)

Run the code above in your browser using DataLab