Fits survival models to the provided data using the specified engine and returns various outputs including model parameters, goodness of fit, and estimates of median survival.
fit_models(
data,
time,
event,
predict_by = NULL,
covariates = NULL,
dists = c("exp", "gamma", "gengamma", "gompertz", "llogis", "lnorm", "weibull"),
engine = "flexsurv",
k = c(1, 2, 3),
scale = "hazard",
add_time_0 = TRUE,
...
)
A list containing information about the fit_models() call, the distributions attempted, goodness of fit, fit averages, and cure fractions (if applicable).
A data frame containing the survival data.
The name of the column in data
containing the
time-to-event information.
The name of the column in data
indicating whether the
event of interest occurred.
(Optional) The name of the column in data
defining
the prediction variable.
(Optional) A character vector specifying the names of covariates to be included in the model.
(Optional) A character vector specifying the distribution(s) to be fitted.
When the engine parameter is set to "flexsurv", options are "exp", "exponential", "gamma", "genf", "genf.orig", "gengamma", "gengamma.orig", "gompertz", "llogis", "lnorm", "lognormal", "weibull", "weibullPH".
When the engine parameter is set to "flexsurvcure", options are "exp", "gamma", "gengamma", "gompertz", "llogis", "lnorm", "weibull".
When the engine parameter is set to "flexsurvspline", dists are ignored in favor of k and scale parameters.
When the engine parameter is set to "survival", options are "exponential", "extreme", "gaussian", "loggaussian" (same as lognormal), "logistic", "lognormal", "rayleigh", "weibull".
Default is c("exp", "gamma", "gengamma", "gompertz",
"llogis", "lnorm", "weibull")
which applies to flexsurv-related engines.
(Optional) The survival analysis engine to be used. Options are "flexsurv", "flexsurvcure", "flexsurvspline", and "survival". Default is "flexsurv".
"flexsurv" uses flexsurv::flexsurvreg()
.
"flexsurvspline" uses flexsurv::flexsurvspline()
.
"flexsurvcure" uses flexsurvcure::flexsurvcure()
.
"survival" uses survival::survreg()
.
(Optional) A numeric vector specifying the number of knots for
spline-based models. Default is c(1, 2, 3)
to test different
numbers.
(Optional) A character vector specifying the scale parameter(s)
for spline-based models. Options are "hazard", "odds", and "normal".
Default is "hazard"
.
Optional. Uses survival::survfit0()
to add a starting
time of 0 to the KM survfit object. This may be useful for plotting the KM
at a subsequent stage (in surv_plots). Default is TRUE.
Additional arguments just to catch them and avoid errors.
models <- fit_models(
data = easysurv::easy_bc,
time = "recyrs",
event = "censrec",
predict_by = "group",
covariates = "group"
)
models
Run the code above in your browser using DataLab