predict() gives the survival, cumulative hazard, hazard, or density of each fitted
distribution at given times. quantile() gives the times by which given proportions of subjects
have had the event, median() the 0.5 quantile, mean() the mean survival time, and rmst()
the restricted mean survival time up to tau.
Usage
# S3 method for class 'parametric'
predict(
object,
times,
type = c("survival", "cumhaz", "hazard", "density"),
conf_level = object$conf_level,
...
)
# S3 method for class 'parametric'
quantile(x, probs = 0.5, conf_level = x$conf_level, ...)
# S3 method for class 'parametric'
median(x, na.rm = FALSE, ...)
# S3 method for class 'parametric'
mean(x, conf_level = x$conf_level, ...)
# S3 method for class 'parametric'
rmst(object, tau, conf_level = object$conf_level, ...)Arguments
- object, x
A
parametric()fit.- times
The times to evaluate at.
- type
What to give:
"survival"(the default),"cumhaz","hazard", or"density".- conf_level
The confidence level. The default is the level the model was fit with.
- ...
Unused.
- probs
Proportions of subjects who have had the event, between 0 and 1 (exclusive).
- na.rm
Unused. Present for compatibility with the generic.
- tau
The end of the window for the restricted mean.
Value
A data frame with one row per group (and per time or proportion): strata, the
grouping variables, then time for predict(), prob and time for quantile() (median()
omits prob), or tau for rmst(), then estimate (not for quantile()), std_error,
conf_low, and conf_high. The layout is the same for one group (strata is "all") as
for several.
Details
Standard errors use the delta method. Limits for survival and the cumulative hazard are built on the scale of the standardized log time, so survival stays within 0 and 1, and limits for the hazard, the density, quantiles, and means on the log scale.
Examples
lung <- data.frame(
time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654, 728, 71, 567),
status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2)
)
fit <- parametric(Surv(time, status) ~ 1, data = lung, dist = "loglogistic")
predict(fit, times = c(100, 365, 730), type = "hazard")
#> strata time estimate std_error conf_low conf_high
#> 1 all 100 0.001222776 0.0006677665 0.0004192761 0.003566104
#> 2 all 365 0.002554261 0.0008324440 0.0013485136 0.004838105
#> 3 all 730 0.002133540 0.0006641151 0.0011591621 0.003926970
quantile(fit, probs = c(0.25, 0.5, 0.75))
#> strata prob time std_error conf_low conf_high
#> 1 all 0.25 226.1240 57.54695 137.3162 372.3672
#> 2 all 0.50 391.2493 88.30358 251.3856 608.9291
#> 3 all 0.75 676.9560 176.96635 405.5493 1129.9967
mean(fit)
#> strata estimate std_error conf_low conf_high
#> 1 all 613.4068 199.3685 324.4086 1159.858
rmst(fit, tau = 730)
#> strata tau estimate std_error conf_low conf_high
#> 1 all 730 422.0849 58.54681 321.6109 553.9477