predrisk_bin_segments: Bin predicted risk for plotting

View source: R/predrisk_bin_segments.R

predrisk_bin_segmentsR Documentation

Bin predicted risk for plotting

Description

Bin predicted risk for plotting

Usage

predrisk_bin_segments(
  x,
  event_time = NULL,
  event_status = NULL,
  pred_horizon = NULL,
  by_event = FALSE,
  bin_count = 100,
  bin_yintercept = 0,
  bin_length = 1
)

Arguments

x

a numeric vector of predicted risk values or an object of class scalib. If x is a scalib object, then the input arguments event_time, event_status, and pred_horizon should be left blank. (They are filled in using info stored in the scalib object).

event_time

(numeric vector) observed event times

event_status

(numeric vector) observed event status. The values of this vector should be 0 (event censored) and 1 (event observed).

pred_horizon

(numeric value) the time of risk prediction.

by_event

If TRUE, bins will be created for each event type, separately. If FALSE, bins are made in the standard fashion for histograms.

bin_count

(integer value) total count of bins for downstream plots

bin_yintercept

(numeric value) where, relative to the y-axis, the bins should originate from on downstream plots.

bin_length

(numeric value) the length of the bins on downstream plots.

Value

a data.frame object with values that can be plugged into standard plotting tools, e.g., ggplot2::ggplot() (see examples).

Examples


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

pbins <- predrisk_bin_segments(sc)

print(pbins)

pbins <- predrisk_bin_segments(x = pbc_scalib$predrisk$prop_hazard,
                               event_time = pbc_scalib$test$time,
                               event_status = pbc_scalib$test$status)


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