| Title: | Parametric Survival Model Selection for Decision-Analytic Models |
|---|---|
| Description: | Provides a standardized framework to support the selection and evaluation of parametric survival models for time-to-event data. Includes tools for visualizing survival data, checking proportional hazards assumptions (Grambsch and Therneau, 1994, <doi:10.1093/biomet/81.3.515>), comparing parametric (Ishak and colleagues, 2013, <doi:10.1007/s40273-013-0064-3>), spline (Royston and Parmar, 2002, <doi:10.1002/sim.1203>) and cure models, examining hazard functions, and evaluating model extrapolation. Methods are consistent with recommendations in the NICE Decision Support Unit Technical Support Documents (14 and 21 <https://sheffield.ac.uk/nice-dsu/tsds/survival-analysis>). Results are structured to facilitate integration into decision-analytic models, and reports can be generated with 'rmarkdown'. The package builds on existing tools including 'flexsurv' (Jackson, 2016, <doi:10.18637/jss.v070.i08>)) and 'flexsurvcure' for estimating cure models. |
| Authors: | Bram Ramaekers [aut, cre, ths] (ORCID: <https://orcid.org/0000-0001-5785-9228>), Xavier Pouwels [ctb] (ORCID: <https://orcid.org/0000-0003-3563-0013>), Sabine Grimm [ths] (ORCID: <https://orcid.org/0000-0002-2175-7999>), Manuela Joore [ths] (ORCID: <https://orcid.org/0000-0002-5649-6768>) |
| Maintainer: | Bram Ramaekers <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.2 |
| Built: | 2026-05-09 08:44:58 UTC |
| Source: | https://github.com/bram-r/persuade |
Computes cumulative hazard estimates for up to three groups along with variance and confidence intervals, using the estimateNAH package.
f_cum_hazard(years, status, group, ngroups, time_pred, time_unit)f_cum_hazard(years, status, group, ngroups, time_pred, time_unit)
years |
Numeric vector of time-to-event data. |
status |
Numeric vector indicating event occurrence (1 = event, 0 = censoring). |
group |
Factor indicating group membership. |
ngroups |
Integer. Number of groups (1-3). |
time_pred |
Numeric vector of prediction times. |
time_unit |
Numeric. Time unit length for scaling. |
A data frame with columns:
group: Group identifier.
time: Prediction times.
H: Cumulative hazard values.
var: Variance estimates.
H_upper, H_lower: 95% confidence interval bounds.
H_delta, H_upper_delta, H_lower_delta: Differences between time steps.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_cum_hazard( years = years, status = status, group = group, ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 30 )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_cum_hazard( years = years, status = status, group = group, ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 30 )
Save the PERSUADE object and render a PDF report using the bundled
PERSUADE_output.Rmd template, or a user-specified template.
f_generate_report( PERSUADE, output_dir = NULL, template_dir = NULL, open = FALSE )f_generate_report( PERSUADE, output_dir = NULL, template_dir = NULL, open = FALSE )
PERSUADE |
A PERSUADE object returned by |
output_dir |
Character string giving the directory to copy the function
output to. If |
template_dir |
Optional character string giving the full path to an Rmd
template. If |
open |
Logical. Whether to browse the generated file. |
The default R markdown file PERSUADE_output.Rmd is stored within
the package under inst/rmd/. Figures are written to a subdirectory
Images/ inside the output folder, and the knit environment is
initialised with the supplied PERSUADE object. Supplying a custom
template_dir allows alternative report formats to be used, and
simplifies testing. This function requires the following suggested packages:
knitr, kableExtra, and rmarkdown.
If not installed, the function will throw an error.
A length-1 character string giving the absolute path to the generated PDF, returned invisibly.
## Not run: # Requires LaTeX to be installed years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) # Copy output to temporary directory # (change `tempdir()` into `getwd()` # for copying to working directory) f_generate_report( PERSUADE, output_dir = file.path( tempdir(), paste0(PERSUADE$name, "_output") ), template_dir = NULL ) ## End(Not run)## Not run: # Requires LaTeX to be installed years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) # Copy output to temporary directory # (change `tempdir()` into `getwd()` # for copying to working directory) f_generate_report( PERSUADE, output_dir = file.path( tempdir(), paste0(PERSUADE$name, "_output") ), template_dir = NULL ) ## End(Not run)
Copy the bundled Excel template PERSUADE_Excel_template.xltx to a user-specified
directory. This template provides a convenient structure for transferring survival
model outputs from PERSUADE into health economic models.
f_get_excel_template(output_dir = NULL)f_get_excel_template(output_dir = NULL)
output_dir |
Character string giving the directory to copy the template to.
If |
The default Excel file PERSUADE_Excel_template.xltx is stored within
the package under inst/excel_template/. This function locates the installed
file via system.file() and copies it into the requested directory. If a file
with the same name already exists at the destination, it will be overwritten.
The Excel template provides a standardized format for entering parametric survival model parameters, making it easier to use PERSUADE outputs in downstream decision-analytic models. Users may adapt the template as needed for their specific workflows.
A length-1 character string giving the absolute path to the copied template file, returned invisibly.
f_generate_report(), system.file()
# Copy output to temporary directory # (change `tempdir()` into `getwd()` for # copying to working directory) f_get_excel_template( output_dir = file.path(tempdir(), paste0("BC_OS", "_output")) )# Copy output to temporary directory # (change `tempdir()` into `getwd()` for # copying to working directory) f_get_excel_template( output_dir = file.path(tempdir(), paste0("BC_OS", "_output")) )
Computes smoothed hazard estimates for up to three groups using the muhaz package.
f_hazard(years, status, group, ngroups)f_hazard(years, status, group, ngroups)
years |
Numeric vector of time-to-event data. |
status |
Numeric vector indicating event occurrence (1 = event, 0 = censoring). |
group |
Factor indicating group membership. |
ngroups |
Integer. Number of groups (1-3). |
A list with elements:
hazards: List of hazard objects (one per group).
names: Vector of group identifiers for hazard values.
max: Data frame with maximum time and hazard values.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_hazard( years = years, status = status, group = group, ngroups = nlevels(group) )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_hazard( years = years, status = status, group = group, ngroups = nlevels(group) )
Executes the PERSUADE workflow for parametric survival analysis, including Kaplan-Meier, parametric, spline, and cure models. Produces outputs for visualization, prediction, and Excel export.
f_PERSUADE( name = "no_name", years, status, group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", time_unit, time_horizon, time_pred_surv_table )f_PERSUADE( name = "no_name", years, status, group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", time_unit, time_horizon, time_pred_surv_table )
name |
Character. Name identifier for the analysis (default: "no_name"). |
years |
Numeric vector of time-to-event data. |
status |
Numeric vector indicating event occurrence (1 = event, 0 = censoring). |
group |
Factor indicating group membership. |
strata |
Logical. Whether to stratify models by group. |
spline_mod |
Logical. Whether spline models should be fitted. |
cure_mod |
Logical. Whether cure models should be fitted. |
cure_link |
Character string specifying the link function for cure models ("logistic", "loglog", "identity", "probit"; default = "logistic"). |
time_unit |
Numeric. The unit of time for annualization. |
time_horizon |
Numeric. The maximum prediction time horizon. |
time_pred_surv_table |
Numeric vector of time points for survival table predictions. |
The workflow proceeds in three main stages:
Observed data (Kaplan-Meier, hazards, Cox regression).
Parametric, spline, and cure model fitting.
Prediction and export of results.
A list of class "PERSUADE" containing:
input: Input arguments used in the analysis.
surv_obs: Observed survival results (Kaplan-Meier, hazards, Cox model).
surv_model: Fitted parametric/spline/cure models.
surv_pred: Model predictions.
surv_model_excel: Excel-ready parameter table.
misc: Auxiliary results (labels, number of groups, etc.).
f_hazard(), f_cum_hazard(), f_surv_model()
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) )
Plot Kaplan-Meier curves per group with shaded confidence bands and overlay
fitted cure survival models (Weibull, log-normal, log-logistic; mixture and
non-mixture forms) extrapolated to the analysis time horizon. Runs only when
PERSUADE$input$cure_mod is TRUE.
f_plot_cure_surv_extrap(PERSUADE)f_plot_cure_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_cure_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_cure_surv_extrap(PERSUADE)
Overlays a fitted cure survival model on KM curves, including shaded KM confidence bands per group.
f_plot_cure_surv_model(PERSUADE, model_index = 1)f_plot_cure_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the cure model in |
A base R plot of KM curves with cure model overlays.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_cure_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_cure_surv_model(PERSUADE, model_index = 1)
Produces diagnostic plots for mixture and non-mixture cure survival models, using transformations depending on the underlying distribution (Weibull, log-normal, log-logistic).
f_plot_diag_cure_surv_model(PERSUADE, model_index = 1)f_plot_diag_cure_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the cure model in
|
A base R diagnostic plot for the selected cure survival model.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_cure_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_cure_surv_model(PERSUADE, model_index = 1)
Produces diagnostic plots for standard parametric survival models, using appropriate transformations depending on the model family (exponential, Weibull, Gompertz, log-normal, log-logistic, gamma, generalized gamma).
f_plot_diag_param_surv_model(PERSUADE, model_index = 1)f_plot_diag_param_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the parametric model in
|
A base R diagnostic plot for the selected parametric survival model.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_param_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_param_surv_model(PERSUADE, model_index = 1)
Produces diagnostic plots for spline-based survival models, using log-time transformations adapted to hazard, odds, or normal scales depending on the spline model type.
f_plot_diag_spline_surv_model(PERSUADE, model_index = 1)f_plot_diag_spline_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the spline model in
|
A base R diagnostic plot for the selected spline-based survival model.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_spline_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_diag_spline_surv_model(PERSUADE, model_index = 1)
Plot observed smoothed hazard rates per group and overlay extrapolated
hazard functions from all fitted cure survival models (mixture and non-mixture).
Runs only when PERSUADE$input$cure_mod is TRUE.
f_plot_hazard_cure_extrap(PERSUADE)f_plot_hazard_cure_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_cure_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_cure_extrap(PERSUADE)
Plot observed smoothed hazard rates per group and overlay extrapolated hazard functions from all fitted parametric survival models.
f_plot_hazard_parametric_extrap(PERSUADE)f_plot_hazard_parametric_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_parametric_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_parametric_extrap(PERSUADE)
Plot observed smoothed hazard rates per group and overlay extrapolated
hazard functions from all fitted spline survival models. Runs only when
PERSUADE$input$spline_mod is TRUE.
f_plot_hazard_spline_extrap(PERSUADE)f_plot_hazard_spline_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_spline_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_spline_extrap(PERSUADE)
Plots observed smoothed hazard estimates together with hazard predictions from parametric, spline, and cure survival models (if fitted).
f_plot_hazard_with_models(PERSUADE)f_plot_hazard_with_models(PERSUADE)
PERSUADE |
A PERSUADE object created by |
A series of base R plots, one per group, with hazard overlays by model family.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_with_models(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_hazard_with_models(PERSUADE)
Generates Kaplan-Meier survival plots from a PERSUADE object using
survminer::ggsurvplot(), automatically adapting to the number of groups.
f_plot_km_survival(PERSUADE)f_plot_km_survival(PERSUADE)
PERSUADE |
A PERSUADE object created by |
A ggsurvplot object with KM curves, risk table, CI bands, and optional censor marks.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_km_survival(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_km_survival(PERSUADE)
Generates Kaplan-Meier survival plots from a PERSUADE object using base R graphics, with shaded confidence intervals and group-specific legends.
f_plot_km_survival_base(PERSUADE)f_plot_km_survival_base(PERSUADE)
PERSUADE |
A PERSUADE object created by |
A base R plot.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_km_survival_base(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_km_survival_base(PERSUADE)
Creates a log(-log(S(t))) vs log(time) plot to visually assess proportional hazards.
f_plot_log_cumhaz(PERSUADE)f_plot_log_cumhaz(PERSUADE)
PERSUADE |
A PERSUADE object created by |
A base R plot showing ln(-ln(S(t))) against ln(time).
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_log_cumhaz(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_log_cumhaz(PERSUADE)
Plot Kaplan-Meier curves per group with shaded confidence bands and overlay fitted parametric survival models (Exponential, Weibull, Gompertz, log-normal, log-logistic, Gamma, generalized Gamma) extrapolated to the analysis time horizon.
f_plot_param_surv_extrap(PERSUADE)f_plot_param_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_param_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_param_surv_extrap(PERSUADE)
Overlays a fitted parametric survival model on top of KM curves, including shaded KM confidence bands per group.
f_plot_param_surv_model(PERSUADE, model_index = 1)f_plot_param_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the parametric model in |
A base R plot of KM curves with parametric model overlays.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_param_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_param_surv_model(PERSUADE, model_index = 1)
Produces scaled Schoenfeld residual plots with fitted regression lines to evaluate Cox proportional hazards assumptions.
f_plot_schoenfeld_residuals(PERSUADE)f_plot_schoenfeld_residuals(PERSUADE)
PERSUADE |
A PERSUADE object created by |
One or more base R plots, one per group comparison.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_schoenfeld_residuals(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_schoenfeld_residuals(PERSUADE)
Plots smoothed hazard estimates for each group in the PERSUADE object.
f_plot_smoothed_hazard(PERSUADE)f_plot_smoothed_hazard(PERSUADE)
PERSUADE |
A PERSUADE object created by |
A base R plot of smoothed hazards by group.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_smoothed_hazard(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_smoothed_hazard(PERSUADE)
Plot Kaplan-Meier curves per group with shaded confidence bands and overlay
fitted spline survival models (hazard, odds, normal scales) extrapolated to
the analysis time horizon. Runs only when PERSUADE$input$spline_mod is TRUE.
f_plot_spline_surv_extrap(PERSUADE)f_plot_spline_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_spline_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_spline_surv_extrap(PERSUADE)
Overlays a spline-based survival model on KM curves, including shaded KM confidence bands and vertical lines for knot positions.
f_plot_spline_surv_model(PERSUADE, model_index = 1)f_plot_spline_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object created by |
model_index |
Integer. Index of the spline model in |
A base R plot of KM curves with spline model overlays and knots.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_spline_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_spline_surv_model(PERSUADE, model_index = 1)
Plot smoothed observed annual transition probabilities with shaded confidence
intervals and overlay predictions from all fitted cure survival models.
Runs only when PERSUADE$input$cure_mod is TRUE.
f_plot_tp_cure_surv_extrap(PERSUADE)f_plot_tp_cure_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_cure_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_cure_surv_extrap(PERSUADE)
Plot smoothed observed annual transition probabilities with shaded confidence intervals, overlaid with predictions from a selected cure survival model (mixture or non-mixture; Weibull, log-normal, or log-logistic).
f_plot_tp_cure_surv_model(PERSUADE, model_index = 1)f_plot_tp_cure_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object returned by |
model_index |
Integer index selecting the cure model within
|
Invisibly returns NULL. The function draws a base R plot as a side effect.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_cure_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = TRUE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_cure_surv_model(PERSUADE, model_index = 1)
Plot smoothed observed annual transition probabilities with shaded confidence intervals and overlay predictions from all fitted parametric survival models.
f_plot_tp_param_surv_extrap(PERSUADE)f_plot_tp_param_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_param_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_param_surv_extrap(PERSUADE)
Plot smoothed observed annual transition probabilities alongside model-predicted probabilities for a selected parametric model, with shaded confidence intervals per group.
f_plot_tp_param_surv_model(PERSUADE, model_index = 1)f_plot_tp_param_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object returned by |
model_index |
Integer index selecting the parametric model within
|
Invisibly returns NULL. The function draws a base R plot as a side effect.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_param_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_param_surv_model(PERSUADE, model_index = 1)
Plot smoothed observed annual transition probabilities with shaded confidence
intervals and overlay predictions from all fitted spline survival models.
Runs only when PERSUADE$input$spline_mod is TRUE.
f_plot_tp_spline_surv_extrap(PERSUADE)f_plot_tp_spline_surv_extrap(PERSUADE)
PERSUADE |
A PERSUADE object returned by |
Invisibly returns NULL. The function draws one or more base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_spline_surv_extrap(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_spline_surv_extrap(PERSUADE)
Plot smoothed observed annual transition probabilities together with predictions from a selected spline survival model (hazard/odds/normal scale), including shaded confidence intervals and vertical lines for spline knots.
f_plot_tp_spline_surv_model(PERSUADE, model_index = 1)f_plot_tp_spline_surv_model(PERSUADE, model_index = 1)
PERSUADE |
A PERSUADE object returned by |
model_index |
Integer index selecting the spline model within
|
Invisibly returns NULL. The function draws a base R plot as a side effect.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_spline_surv_model(PERSUADE, model_index = 1)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = TRUE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) f_plot_tp_spline_surv_model(PERSUADE, model_index = 1)
Compute descriptive statistics for each numeric variable in a data frame: mean, standard deviation, minimum, first quartile (Q1), median, third quartile (Q3), maximum, and interquartile range (IQR). Results are rounded to three decimals.
f_summary(df)f_summary(df)
df |
A data frame; numeric columns are summarized. |
A data frame (one row per variable) with columns:
Mean, Std.Dev, Min, Q1, Median, Q3, Max, IQR.
f_summary(mtcars)f_summary(mtcars)
Fits standard parametric models, spline models, and cure models using the flexsurv package.
f_surv_model( years, status, group, strata, ngroups, form, spline_mod, cure_mod, cure_link, group_names )f_surv_model( years, status, group, strata, ngroups, form, spline_mod, cure_mod, cure_link, group_names )
years |
Numeric vector of time-to-event data. |
status |
Numeric vector indicating event occurrence (1 = event, 0 = censoring). |
group |
Factor indicating group membership. |
strata |
Logical. Whether to stratify models by group. |
ngroups |
Integer. Number of groups. |
form |
A survival model formula (e.g., |
spline_mod |
Logical. Whether spline models should be fitted. |
cure_mod |
Logical. Whether cure models should be fitted. |
cure_link |
Character string specifying the link function for cure models ("logistic", "loglog", "identity", "probit"; default = "logistic"). |
group_names |
Character vector of group labels (for cure fractions). |
Models fitted include Exponential, Weibull, Gompertz, Log-normal, Log-logistic, Gamma, Generalised Gamma. Optional spline models (1-3 knots, scales: hazard, odds, normal) and cure models (Weibull, Log-normal, Log-logistic with logistic/probit/etc. link).
A list containing:
param_models, param_ic: Parametric models and information criteria.
spline_models, spline_ic: Spline models and IC (if fitted).
cure_models, cure_ic: Cure models and IC (if fitted).
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) )
Formats model parameters (including spline knots) into a table suitable for export to Excel.
f_surv_model_excel(ngroups, strata, surv_model, spline_mod, cure_mod)f_surv_model_excel(ngroups, strata, surv_model, spline_mod, cure_mod)
ngroups |
Integer. Number of groups. |
strata |
Logical. Whether stratified models were used. |
surv_model |
List of fitted models from |
spline_mod |
Logical. Whether spline models were included. |
cure_mod |
Logical. Whether cure models were included. |
A transposed data frame containing:
Distribution names
Parameter names
Estimates, SE, CI
Knot values (if splines fitted)
Covariance matrix
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) f_surv_model_excel( ngroups = nlevels(group), strata = FALSE, surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) f_surv_model_excel( ngroups = nlevels(group), strata = FALSE, surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE )
Generates predicted survival and hazard values from fitted parametric, spline, and cure models.
f_surv_model_pred( ngroups, time_pred, surv_model, spline_mod, cure_mod, group_names )f_surv_model_pred( ngroups, time_pred, surv_model, spline_mod, cure_mod, group_names )
ngroups |
Integer. Number of groups. |
time_pred |
Numeric vector of prediction times. |
surv_model |
List of fitted survival models from |
spline_mod |
Logical. Whether spline models were fitted. |
cure_mod |
Logical. Whether cure models were fitted. |
group_names |
Character vector of group labels. |
A list of predictions containing:
param_models: Survival & hazard predictions for standard models.
spline: Predictions for spline models (if fitted).
cure: Predictions for cure models (if fitted).
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) )
Consolidates predictions from f_surv_model_pred() into
group-specific data frames.
f_surv_model_pred_gr( ngroups, surv_model, surv_model_pred, spline_mod, cure_mod )f_surv_model_pred_gr( ngroups, surv_model, surv_model_pred, spline_mod, cure_mod )
ngroups |
Integer. Number of groups. |
surv_model |
List of survival models from |
surv_model_pred |
List of predictions from |
spline_mod |
Logical. Whether spline models were fitted. |
cure_mod |
Logical. Whether cure models were fitted. |
A list of length ngroups, each a data frame with columns:
time
survival predictions for all models (parametric, spline, cure).
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) surv_model_pred <- f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) ) f_surv_model_pred_gr( ngroups = nlevels(group), surv_model = surv_model, surv_model_pred = surv_model_pred, spline_mod = FALSE, cure_mod = FALSE )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) surv_model_pred <- f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) ) f_surv_model_pred_gr( ngroups = nlevels(group), surv_model = surv_model, surv_model_pred = surv_model_pred, spline_mod = FALSE, cure_mod = FALSE )
Compute Transition Probabilities for Survival Model Predictions
f_surv_model_pred_tp_gr( ngroups, time_pred, time_unit, surv_model_pred_gr, cols_tp )f_surv_model_pred_tp_gr( ngroups, time_pred, time_unit, surv_model_pred_gr, cols_tp )
ngroups |
Integer, number of groups. |
time_pred |
Numeric vector of prediction times (currently unused). |
time_unit |
Numeric, time unit for transition probability calculation. |
surv_model_pred_gr |
List of group predictions. Each group's table should have a time column in column 1 and survival-related columns from 2:cols_tp. |
cols_tp |
Integer, index of the last survival-related column (i.e., use columns 2:cols_tp). |
Named list of data.frames with transition probabilities (truncated after threshold).
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) surv_model_pred <- f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) ) surv_model_pred_gr <- f_surv_model_pred_gr( ngroups = nlevels(group), surv_model = surv_model, surv_model_pred = surv_model_pred, spline_mod = FALSE, cure_mod = FALSE ) f_surv_model_pred_tp_gr( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 365.25/12, surv_model_pred_gr = surv_model_pred_gr, cols_tp = 8 )years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) form <- stats::as.formula(survival::Surv(years, status) ~ group) surv_model <- f_surv_model( years = years, status = status, group = group, strata = FALSE, ngroups = nlevels(group), form = form, spline_mod = FALSE, cure_mod = FALSE, cure_link = "logistic", group_names = levels(group) ) surv_model_pred <- f_surv_model_pred( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), surv_model = surv_model, spline_mod = FALSE, cure_mod = FALSE, group_names = levels(group) ) surv_model_pred_gr <- f_surv_model_pred_gr( ngroups = nlevels(group), surv_model = surv_model, surv_model_pred = surv_model_pred, spline_mod = FALSE, cure_mod = FALSE ) f_surv_model_pred_tp_gr( ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 365.25/12, surv_model_pred_gr = surv_model_pred_gr, cols_tp = 8 )
Derives annualized transition probabilities (and confidence bounds) from cumulative hazard estimates, smoothed with LOESS.
f_tp(ngroups, cum_haz, time_unit)f_tp(ngroups, cum_haz, time_unit)
ngroups |
Integer. Number of groups (1-3). |
cum_haz |
Data frame from |
time_unit |
Numeric. Time unit for annualization. |
A list with:
gr_1, gr_2, gr_3: Data frames of smoothed probabilities per group.
max: Maximum upper bound across all groups.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) cum_haz <- f_cum_hazard( years = years, status = status, group = group, ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 30 ) f_tp(ngroups = nlevels(group), cum_haz = cum_haz, time_unit = 30)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) cum_haz <- f_cum_hazard( years = years, status = status, group = group, ngroups = nlevels(group), time_pred = seq(0, 5000, 365.25), time_unit = 30 ) f_tp(ngroups = nlevels(group), cum_haz = cum_haz, time_unit = 30)
Generates diagnostic and model fit plots for PERSUADE survival analysis objects.
The type argument controls which plot(s) are produced:
"km": Kaplan-Meier survival curves.
"ph": Proportional hazards diagnostics.
"hr": Hazard function with fitted models.
"param_models": Fitted parametric survival models with diagnostics and transition probability plots.
"spline_models": Fitted spline-based survival models with diagnostics and transition probability plots.
"cure_models": Fitted cure survival models with diagnostics and transition probability plots.
## S3 method for class 'PERSUADE' plot(x, type = "km", ...)## S3 method for class 'PERSUADE' plot(x, type = "km", ...)
x |
A PERSUADE object from |
type |
Character. The type of plot to produce. |
... |
Additional arguments (currently unused). |
Invisibly returns a list of results from the plotting functions. Also produces base R plots as side effects.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) plot(PERSUADE, "km")years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) plot(PERSUADE, "km")
Displays a brief summary of the PERSUADE object in the console.
## S3 method for class 'PERSUADE' print(x, ...)## S3 method for class 'PERSUADE' print(x, ...)
x |
A PERSUADE object from |
... |
Additional arguments (currently unused). |
Invisibly returns the PERSUADE object.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) print(PERSUADE)years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) print(PERSUADE)
The type argument controls which summary is produced:
"km": Kaplan-Meier estimates (default).
"surv_probs": Survival probabilities at specified prediction times for each group.
"gof": Goodness-of-fit statistics for standard parametric models.
"gof_spline": Goodness-of-fit statistics for spline models.
"gof_cure": Goodness-of-fit statistics for cure models (including cure fraction).
## S3 method for class 'PERSUADE' summary(object, ..., type = "km")## S3 method for class 'PERSUADE' summary(object, ..., type = "km")
object |
A PERSUADE object from |
... |
Additional arguments. Currently only |
type |
Character string, one of "km", "surv_probs", "gof", "gof_spline", "gof_cure". Controls the type of summary output. |
A data frame or list of data frames depending on type.
years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) summary(PERSUADE, type = "surv_probs")years <- survival::lung$time status <- survival::lung$status group <- factor(survival::lung$sex) PERSUADE <- f_PERSUADE( name = "Example", years = years, status = status, group = group, strata = FALSE, spline_mod = FALSE, cure_mod = FALSE, time_unit = 365.25/12, time_horizon = 2000, time_pred_surv_table = seq(0, 2000, 365.25) ) summary(PERSUADE, type = "surv_probs")