scalib_hare: Calibration Slope using Hazard Regression (HARE)

View source: R/scalib_hare.R

scalib_hareR Documentation

Calibration Slope using Hazard Regression (HARE)

Description

TODO: add description

Usage

scalib_hare(
  scalib_object,
  verbose = 0,
  hare_penalty = NULL,
  hare_max_dimension = NULL,
  hare_prophaz = FALSE,
  hare_additive = FALSE,
  hare_linear_risk = FALSE,
  hare_linear_time = FALSE,
  hare_fit = NULL
)

Arguments

scalib_object

An object of class scalib (see scalib).

verbose

(integer value) If 0, no output will be printed. If 1, some output will be printed. If 2, all output will be printed.

hare_penalty

the parameter to be used in the AIC criterion. The method chooses the number of knots that minimizes -2 * loglikelihood + penalty * (dimension). The default is to use penalty = log(samplesize) as in BIC. The effect of this parameter is summarized in summary.hare.

hare_max_dimension

maximum dimension (default is 6 * length(data)^0.2.

hare_prophaz

should the model selection be restricted to proportional hazards models?

hare_additive

should the model selection be restricted to additive models?

hare_linear_risk

(logical value) should the effect of risk be linear?

hare_linear_time

(logical value) should the effect of time be linear?

hare_fit

hare object. If fit is specified, hare adds basis functions starting with those in fit.

Value

an object of class scalib

Examples


# packages
library(ggplot2)
library(tidyr)
library(dplyr)

sc <- scalib(pred_risk = pbc_scalib$predrisk,
             pred_horizon = 2500,
             event_time = pbc_scalib$test$time,
             event_status = pbc_scalib$test$status)

sc_hare <- scalib_hare(sc)

print(sc_hare)

data_gg <- sc_hare$data_outputs |>
  select(._id_., hare_data_plot) |>
  unnest(hare_data_plot)

data_bins <- predrisk_bin_segments(sc_hare, bin_count = 30) |>
 mutate(._id_.)

id_labels <- c(prop_hazard = "Cox proportional hazards",
               rsf_axis = "Random survival forest (axis based splitting)",
               gradient_booster = "Gradient boosted decision trees",
               rsf_oblique = "Random survival forest (oblique splitting)")

ggplot(data_gg) +
  aes(x = predicted, y = observed) +
  geom_line() +
  geom_abline(col = 'grey', linetype = 2) +
  geom_hline(yintercept = 0, col = 'grey') +
  theme_bw() +
  theme(panel.grid = element_blank()) +
  coord_cartesian(xlim = c(0, 1),
                  ylim = c(-0.1, 1)) +
  geom_segment(data = data_bins,
               size = 4,
               alpha = 0.50,
               col = 'grey',
               mapping = aes(x = x,
                             y = y,
                             xend = xend,
                             yend = yend)) +
 facet_wrap(~._id_., labeller = labeller(._id_. = id_labels)) +
 labs(x = 'Predicted risk', y = 'Observed risk')

bcjaeger/survival.calib documentation built on June 15, 2022, 7:47 a.m.