Quantiles for Kaplan-Meier and Aalen-Johansen estimates.

# S3 method for class 'prodlim'
quantile(x, q, cause = 1, ...)

Arguments

x

Object of class "prodlim".

q

Quantiles. Vector of values between 0 and 1.

cause

For competing risks the cause of interest.

...

not used

Author

Thomas Alexander Gerds <tag@biostat.ku.dk>

Examples

library(lava)
set.seed(1)
d=SimSurv(30)

# Quantiles of the potential followup time
g=prodlim(Hist(time,status)~1,data=d,reverse=TRUE)
quantile(g)
#> Quantiles of the potential follow up time distribution based on the Kaplan-Meier method 
#> applied to the censored times reversing the roles of event status and censored.
#> 
#> Table of quantiles and corresponding confidence limits:
#>        q quantile lower upper
#>    <num>    <num> <num> <num>
#> 1:  0.00       NA    NA    NA
#> 2:  0.25       NA  9.17    NA
#> 3:  0.50     9.17  5.79    NA
#> 4:  0.75     5.79  4.58   9.2
#> 5:  1.00     0.86  0.86   4.6
#> 
#> 
#> Median with interquartile range (IQR):
#>      Median (IQR)
#>            <char>
#> 1: 9.17 (5.79;NA)

# survival time
f=prodlim(Hist(time,status)~1,data=d)
f1=prodlim(Hist(time,status)~X1,data=d)
# default: median and IQR
quantile(f)
#> Quantiles of the event time distribution based on the Kaplan-Meier method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>        q quantile lower upper
#>    <num>    <num> <num> <num>
#> 1:  0.00       NA    NA    NA
#> 2:  0.25    11.28  6.42    NA
#> 3:  0.50     5.26  4.45   9.2
#> 4:  0.75     3.49  2.50   5.0
#> 5:  1.00     0.49  0.49   2.5
#> 
#> 
#> Median with interquartile range (IQR):
#>         Median (IQR)
#>               <char>
#> 1: 5.26 (3.49;11.28)
quantile(f1)
#> Quantiles of the event time distribution based on the Kaplan-Meier method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>        X1     q quantile lower upper
#>     <num> <num>    <num> <num> <num>
#>  1:     0  0.00       NA    NA    NA
#>  2:     0  0.25    11.28  9.16    NA
#>  3:     0  0.50     9.16  6.42    NA
#>  4:     0  0.75     5.00  3.10   9.2
#>  5:     0  1.00     1.55  1.55   5.0
#>  6:     1  0.00       NA    NA    NA
#>  7:     1  0.25     5.26  3.71    NA
#>  8:     1  0.50     4.45  2.73   5.1
#>  9:     1  0.75     2.73  0.75   4.4
#> 10:     1  1.00     0.49  0.49   2.5
#> 
#> 
#> Median with interquartile range (IQR):
#>       X1      Median (IQR)
#>    <num>            <char>
#> 1:     0 9.16 (5.00;11.28)
#> 2:     1  4.45 (2.73;5.26)
# median alone
quantile(f,.5)
#> Quantiles of the event time distribution based on the Kaplan-Meier method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>        q quantile lower upper
#>    <num>    <num> <num> <num>
#> 1:   0.5      5.3   4.4   9.2
quantile(f1,.5)
#> Quantiles of the event time distribution based on the Kaplan-Meier method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>       X1     q quantile lower upper
#>    <num> <num>    <num> <num> <num>
#> 1:     0   0.5      9.2   6.4    NA
#> 2:     1   0.5      4.4   2.7   5.1

# competing risks
set.seed(3)
dd = SimCompRisk(30)
ff=prodlim(Hist(time,event)~1,data=dd)
ff1=prodlim(Hist(time,event)~X1,data=dd)
## default: median and IQR
quantile(ff)
#> Quantiles of the event time distribution based on the Aalen-Johansen method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>     cause     q quantile lower upper
#>    <char> <num>    <num> <num> <num>
#> 1:      1  0.00      1.6   1.6   1.9
#> 2:      1  0.25      3.6   1.9   5.5
#> 3:      1  0.50      8.1   4.3    NA
#> 4:      1  0.75       NA   8.7    NA
#> 5:      1  1.00       NA    NA    NA
#> 
#> 
#> Median with interquartile range (IQR):
#>     cause   Median (IQR)
#>    <char>         <char>
#> 1:      1 8.07 (3.61;NA)
quantile(ff1)
#> Quantiles of the event time distribution based on the Aalen-Johansen method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>      cause    X1     q quantile lower upper
#>     <char> <num> <num>    <num> <num> <num>
#>  1:      1     0  0.00      3.0   3.0   5.5
#>  2:      1     0  0.25      5.5   3.0    NA
#>  3:      1     0  0.50       NA   5.5    NA
#>  4:      1     0  0.75       NA    NA    NA
#>  5:      1     0  1.00       NA    NA    NA
#>  6:      1     1  0.00      1.6   1.6   1.9
#>  7:      1     1  0.25      3.0   1.8   5.0
#>  8:      1     1  0.50      5.2   3.6   8.7
#>  9:      1     1  0.75      8.7   5.2    NA
#> 10:      1     1  1.00       NA    NA    NA
#> 
#> 
#> Median with interquartile range (IQR):
#>     cause    X1     Median (IQR)
#>    <char> <num>           <char>
#> 1:      1     0     NA (5.51;NA)
#> 2:      1     1 5.20 (2.98;8.74)

print(quantile(ff1),na.val="NA")
#> Quantiles of the event time distribution based on the Aalen-Johansen method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>      cause    X1     q quantile lower upper
#>     <char> <num> <num>    <num> <num> <num>
#>  1:      1     0  0.00      3.0   3.0   5.5
#>  2:      1     0  0.25      5.5   3.0    NA
#>  3:      1     0  0.50       NA   5.5    NA
#>  4:      1     0  0.75       NA    NA    NA
#>  5:      1     0  1.00       NA    NA    NA
#>  6:      1     1  0.00      1.6   1.6   1.9
#>  7:      1     1  0.25      3.0   1.8   5.0
#>  8:      1     1  0.50      5.2   3.6   8.7
#>  9:      1     1  0.75      8.7   5.2    NA
#> 10:      1     1  1.00       NA    NA    NA
#> 
#> 
#> Median with interquartile range (IQR):
#>     cause    X1     Median (IQR)
#>    <char> <num>           <char>
#> 1:      1     0     NA (5.51;NA)
#> 2:      1     1 5.20 (2.98;8.74)
print(quantile(ff1),na.val="Not reached")
#> Quantiles of the event time distribution based on the Aalen-Johansen method.
#> 
#> Table of quantiles and corresponding confidence limits:
#>      cause    X1     q quantile lower upper
#>     <char> <num> <num>    <num> <num> <num>
#>  1:      1     0  0.00      3.0   3.0   5.5
#>  2:      1     0  0.25      5.5   3.0    NA
#>  3:      1     0  0.50       NA   5.5    NA
#>  4:      1     0  0.75       NA    NA    NA
#>  5:      1     0  1.00       NA    NA    NA
#>  6:      1     1  0.00      1.6   1.6   1.9
#>  7:      1     1  0.25      3.0   1.8   5.0
#>  8:      1     1  0.50      5.2   3.6   8.7
#>  9:      1     1  0.75      8.7   5.2    NA
#> 10:      1     1  1.00       NA    NA    NA
#> 
#> 
#> Median with interquartile range (IQR):
#>     cause    X1     Median (IQR)
#>    <char> <num>           <char>
#> 1:      1     0     NA (5.51;NA)
#> 2:      1     1 5.20 (2.98;8.74)