Bin predicted risk for plotting
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
)
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).
(numeric vector) observed event times
(numeric vector) observed event status. The values of this vector should be 0 (event censored) and 1 (event observed).
(numeric value) the time of risk prediction.
If TRUE
, bins will be created for each event type,
separately. If FALSE
, bins are made in the standard fashion for
histograms.
(integer value) total count of bins for downstream plots
(numeric value) where, relative to the y-axis, the bins should originate from on downstream plots.
(numeric value) the length of the bins on downstream plots.
a data.frame
object with values that can be plugged into
standard plotting tools, e.g., ggplot2::ggplot()
(see 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)
#> ._id_. x y xend yend
#> 1: prop_hazard 0.006691434 0 0.006691434 0.017391304
#> 2: prop_hazard 0.016624520 0 0.016624520 0.008695652
#> 3: prop_hazard 0.026557605 0 0.026557605 0.030434783
#> 4: prop_hazard 0.036490691 0 0.036490691 0.026086957
#> 5: prop_hazard 0.046423777 0 0.046423777 0.017391304
#> ---
#> 396: rsf_oblique 0.905950677 0 0.905950677 0.012500000
#> 397: rsf_oblique 0.914816484 0 0.914816484 0.025000000
#> 398: rsf_oblique 0.923682290 0 0.923682290 0.012500000
#> 399: rsf_oblique 0.932548097 0 0.932548097 0.000000000
#> 400: rsf_oblique 0.941413904 0 0.941413904 0.050000000
pbins <- predrisk_bin_segments(x = pbc_scalib$predrisk$prop_hazard,
event_time = pbc_scalib$test$time,
event_status = pbc_scalib$test$status)