hēRo3 includes a wide array of functions for working with survival distributions. These functions can be used to define parametric survival distributions or Kaplan-Meiers, work with life tables, apply treatment effects, joint curves together, or many other typical survival modeling-related tasks. A complete listing of these functions and their usage is provided in the table below.
Function |
Description |
Example |
apply_af(...) |
Applies acceleration factor to a survival distribution. Can also be used to rescale a survival distribution from one time unit to another. For example, applying an acceleration factor of 12 would convert from annual to monthly. |
apply_af(my_dist, 1.5)
|
apply_hr(...) |
Applies hazard ratio to a survival distribution. |
apply_hr(my_dist, 0.5)
|
apply_or(...) |
Applies odds ratio to a survival distribution. |
apply_or(my_dist, 1.3)
|
apply_shift(...) |
Shift survival distribution forwards or backwards in time. |
apply_shift(my_dist, 20)
|
event_prob(...) |
Calculates probability of experiencing an event in a set of intervals given a survival distribution, start times of the intervals, and end times of the intervals. Useful for calculating transition probabilities based either on state time or model time using a survival distribution. |
event_prob(my_dist, start, end)
|
surv_prob(...) |
Calculates survival probabilities for survival distribution at given times. |
surv_prob(my_dist, times)
|
add_hazards(...) |
Combine two survival distributions as two independent risks. |
add_hazards(dist1, dist2)
|
define_survival(...) |
Define parametric survival model for given family and with given parameter values. Supported distributions include:
Information on parameterization of each survival distribution can be found here. |
define_survival(
|
define_survival_cure(...) |
Define mixture or non-mixture parametric survival cure model for a given family, with given cure fraction, and with given parameter values. Supports same set of distributions and parameterizations as with "define_survival". |
define_survival_cure(
|
define_spline_survival(...) |
Define a Royston & Parmar spline-based survival model. These models represent a transformation of the survival function as a natural cubic spline function of log time. Argument include the parameters of the spline model (gamma1, gamma2, etc...), the knot times on the log scale (knots1, knots2, etc...), and what transformation of the survival function is modeled by the spline (scale). The number of parameters and knot times passed into define_spline_survival must be equal. Options for the scale argument are:
|
define_spline_survival( |
define_surv_table(...) |
Define survival distribution based on a table of times and survival probabilities. Columns must be named "time" and "survival" respectively. |
define_surv_table(my_table)
|
define_surv_lifetable(...) |
Define survival distribution based on a life table. First argument is a table with annual death rates by age containing the columns "age", "male", and "female". Second and third arguments are the starting age and percent of patients who are men. |
define_surv_lifetable(
|
join(...) |
Join two or more survival distributions together at given cut time(s). First argument is survival distribution for first segment, followed by cut point, and then distribution used in second segment. |
join(km_dist, 60, param_dist) |
mix(...) |
Mix two or more distributions using given weights. Each survival distribution argument must be followed by additional numeric argument specifying weight assigned to that distribution. |
mix(dist1, 0.7, dist2, 0.3) |
set_covariates(...) |
Takes a survival model estimated with covariates (from survfit, flexsurvreg, or other supported functions) and sets the covariate values for which survival projections will be used. |
set_covariates( |
Functions from Other R Packages
In addition to the built-in functions above, hēRo3 can also support fitted parametric models from the flexsurv and flexsurvcure packages, as well as Kaplan-Meiers from the survival package. More information on how to use these functions is provided in their respective documentation pages.