# quantile.survfit: Quantiles from a survfit object In survival: Survival Analysis

## Description

Retrieve quantiles and confidence intervals for them from a survfit object.

## Usage

 ```1 2 3 4 5 6``` ```## S3 method for class 'survfit' quantile(x, probs = c(0.25, 0.5, 0.75), conf.int = TRUE, scale, tolerance= sqrt(.Machine\$double.eps), ...) ## S3 method for class 'survfitms' quantile(x, probs = c(0.25, 0.5, 0.75), conf.int = TRUE, scale, tolerance= sqrt(.Machine\$double.eps), ...) ```

## Arguments

 `x` a result of the survfit function `probs` numeric vector of probabilities with values in [0,1] `conf.int` should lower and upper confidence limits be returned? `scale` optional scale factor, e.g., `scale=365.25` would return results in years if the fit object were in days. `tolerance` tolerance for checking that the survival curve exactly equals one of the quantiles `...` optional arguments for other methods

## Details

The kth quantile for a survival curve S(t) is the location at which a horizontal line at height p= 1-k intersects the plot of S(t). Since S(t) is a step function, it is possible for the curve to have a horizontal segment at exactly 1-k, in which case the midpoint of the horizontal segment is returned. This mirrors the standard behavior of the median when data is uncensored. If the survival curve does not fall to 1-k, then that quantile is undefined.

In order to be consistent with other quantile functions, the argument `prob` of this function applies to the cumulative distribution function F(t) = 1-S(t).

Confidence limits for the values are based on the intersection of the horizontal line at 1-k with the upper and lower limits for the survival curve. Hence confidence limits use the same p-value as was in effect when the curve was created, and will differ depending on the `conf.type` option of `survfit`. If the survival curves have no confidence bands, confidence limits for the quantiles are not available.

When a horizontal segment of the survival curve exactly matches one of the requested quantiles the returned value will be the midpoint of the horizontal segment; this agrees with the usual definition of a median for uncensored data. Since the survival curve is computed as a series of products, however, there may be round off error. Assume for instance a sample of size 20 with no tied times and no censoring. The survival curve after the 10th death is (19/20)(18/19)(17/18) ... (10/11) = 10/20, but the computed result will not be exactly 0.5. Any horizontal segment whose absolute difference with a requested percentile is less than `tolerance` is considered to be an exact match.

## Value

The quantiles will be a vector if the `survfit` object contains only a single curve, otherwise it will be a matrix or array. In this case the last dimension will index the quantiles.

If confidence limits are requested, then result will be a list with components `quantile`, `lower`, and `upper`, otherwise it is the vector or matrix of quantiles.

## Author(s)

Terry Therneau

`survfit`, `print.survfit`, `qsurvreg`

## Examples

 ```1 2 3 4 5 6 7 8 9``` ```fit <- survfit(Surv(time, status) ~ ph.ecog, data=lung) quantile(fit) cfit <- coxph(Surv(time, status) ~ age + strata(ph.ecog), data=lung) csurv<- survfit(cfit, newdata=data.frame(age=c(40, 60, 80)), conf.type ="none") temp <- quantile(csurv, 1:5/10) temp[2,3,] # quantiles for second level of ph.ecog, age=80 quantile(csurv[2,3], 1:5/10) # quantiles of a single curve, same result ```

### Example output

```\$quantile
25  50  75
ph.ecog=0 285 394 655
ph.ecog=1 181 306 550
ph.ecog=2 105 199 351
ph.ecog=3 118 118 118

\$lower
25  50  75
ph.ecog=0 189 348 558
ph.ecog=1 156 268 460
ph.ecog=2  61 156 285
ph.ecog=3  NA  NA  NA

\$upper
25  50  75
ph.ecog=0 350 574  NA
ph.ecog=1 223 429 689
ph.ecog=2 163 288 654
ph.ecog=3  NA  NA  NA

10  20  30  40  50
92 144 181 218 270
10  20  30  40  50
92 144 181 218 270
```

survival documentation built on Aug. 24, 2021, 5:06 p.m.