Survival plots for a RoBSA object

plot_prediction(
  x,
  type = "survival",
  time_range = NULL,
  new_data = NULL,
  predictor = NULL,
  covariates_data = NULL,
  conditional = FALSE,
  plot_type = "base",
  samples = 10000,
  ...
)

plot_survival(
  x,
  time_range = NULL,
  new_data = NULL,
  predictor = NULL,
  covariates_data = NULL,
  conditional = FALSE,
  plot_type = "base",
  samples = 10000,
  ...
)

plot_hazard(
  x,
  time_range = NULL,
  new_data = NULL,
  predictor = NULL,
  covariates_data = NULL,
  conditional = FALSE,
  plot_type = "base",
  samples = 10000,
  ...
)

plot_density(
  x,
  time_range = NULL,
  new_data = NULL,
  predictor = NULL,
  covariates_data = NULL,
  conditional = FALSE,
  plot_type = "base",
  samples = 10000,
  ...
)

Arguments

x

a fitted RoBSA object.

type

what type of prediction should be created

time_range

a numeric of length two specifying the range for the survival prediction. Defaults to NULL which uses the range of observed times.

new_data

a data.frame containing fully specified predictors for which predictions should be made

predictor

an alternative input to new_data that automatically generates predictions for each level of the predictor across all either across levels of covariates specified by covariates_data or at the default values of other predictors

covariates_data

a supplementary input to predictor that specifies levels of covariates for which predictions should be made

conditional

whether only models assuming presence of the specified predictor should be used

plot_type

whether to use a base plot "base" or ggplot2 "ggplot" for plotting. Defaults to "base".

samples

number of posterior samples to be evaluated

...

additional arguments.

Value

returns either NULL if plot_type = "base"

or an object object of class 'ggplot2' if plot_type = "ggplot2".

Examples

if (FALSE) {
# (execution of the example takes several minutes)
# example from the README (more details and explanation therein)
data(cancer, package = "survival")
priors <- calibrate_quartiles(median_t = 5, iq_range_t = 10, prior_sd = 0.5)
df <- data.frame(
  time         = veteran$time / 12,
  status       = veteran$status,
  treatment    = factor(ifelse(veteran$trt == 1, "standard", "new"), levels = c("standard", "new")),
  karno_scaled = veteran$karno / 100
)
RoBSA.options(check_scaling = FALSE)
fit <- RoBSA(
  Surv(time, status) ~ treatment + karno_scaled,
  data   = df,
  priors = list(
    treatment    = prior_factor("normal", parameters = list(mean = 0.30, sd = 0.15),
                                truncation = list(0, Inf), contrast = "treatment"),
    karno_scaled = prior("normal", parameters = list(mean = 0, sd = 1))
  ),
  test_predictors = "treatment",
  prior_intercept = priors[["intercept"]],
  prior_aux       = priors[["aux"]],
  parallel = TRUE, seed = 1
)

# plot survival for each level the treatment
plot_survival(fit, parameter = "treatment")

# plot hazard for each level the treatment
plot_hazard(fit, parameter = "treatment")

# plot density for each level the treatment
plot_density(fit, parameter = "treatment")
}