Predict survival probabilities from a parametric survival model
Source:R/surv_predict.R
surv_predict.RdEstimate model-based survival probabilities at user-specified follow-up
times from a fitted survival::survreg() model.
Arguments
- model
A fitted
survregmodel, or asurv_reg()object containing exactly one fitted model.- newdata
Optional
data.frameof profiles for prediction. IfNULL, one typical profile is built from the model data using medians for numeric variables and the most common level for categorical variables.- times
Numeric vector of follow-up times at which survival probability should be predicted.
- digits
Number of digits for displayed follow-up times and probabilities.
- format
Output format. One of
"flextable"(default),"gt", or"tibble".- theme
Table styling preset.
Value
A list of class c("gtregression","surv_predict", ...)
with elements:
tableA
flextable,gt_tbl, orNULLwhenformat = "tibble".table_bodyTibble with predicted survival probabilities.
table_displayDisplay data frame used to render the table.
modelThe fitted
survregmodel used for prediction.newdata,times,distribution,format,sourceMetadata fields.
Details
surv_predict() is for parametric survival regression models fitted by
surv_reg() or survival::survreg(). It is not a Kaplan-Meier
estimate and it is not a Cox prediction helper.
Supported distributions are "weibull", "exponential",
"lognormal", and "loglogistic", matching
surv_reg(). Predictions are conditional on the supplied profile and
the chosen parametric distribution.
Examples
lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
labels = c("Standard", "Test"))
fit <- surv_reg(
data = lung_data,
time = time,
event = status,
exposures = "trt",
adjust_for = c("age", "karno"),
distribution = weibull
)
surv_predict(
model = fit$models$trt,
newdata = data.frame(
trt = factor("Test", levels = levels(lung_data$trt)),
age = 60,
karno = 70
),
times = c(90, 180, 365)
)
surv_predict(
model = fit,
times = c(90, 180),
format = tibble
)
#> # A tibble: 2 × 8
#> Profile .profile trt age karno Time Survival.probability Distribution
#> <int> <chr> <fct> <dbl> <dbl> <dbl> <dbl> <chr>
#> 1 1 Typical pro… Stan… 62 60 90 0.478 weibull
#> 2 1 Typical pro… Stan… 62 60 180 0.234 weibull