orsf_ice_oob {aorsf} | R Documentation |
Compute individual conditional expectations for an ORSF model. Unlike partial dependence, which shows the expected prediction as a function of one or multiple predictors, individual conditional expectations (ICE) show the prediction for an individual observation as a function of a predictor. You can compute individual conditional expectations three ways using a random forest:
using in-bag predictions for the training data
using out-of-bag predictions for the training data
using predictions for a new set of data
See examples for more details
orsf_ice_oob(
object,
pred_spec,
pred_horizon = NULL,
pred_type = "risk",
expand_grid = TRUE,
boundary_checks = TRUE,
...
)
orsf_ice_inb(
object,
pred_spec,
pred_horizon = NULL,
pred_type = "risk",
expand_grid = TRUE,
boundary_checks = TRUE,
...
)
orsf_ice_new(
object,
pred_spec,
new_data,
pred_horizon = NULL,
pred_type = "risk",
na_action = "fail",
expand_grid = TRUE,
boundary_checks = TRUE,
...
)
object |
(orsf_fit) a trained oblique random survival forest (see orsf). |
pred_spec |
(named list or data.frame).
|
pred_horizon |
(double) a value or vector indicating the time(s)
that predictions will be calibrated to. E.g., if you were predicting
risk of incident heart failure within the next 10 years, then
|
pred_type |
(character) the type of predictions to compute. Valid options are
|
expand_grid |
(logical) if |
boundary_checks |
(logical) if |
... |
Further arguments passed to or from other methods (not currently used). |
new_data |
a data.frame, tibble, or data.table to compute predictions in. |
na_action |
(character) what should happen when
|
a data.table containing individual conditional expectations for the specified variable(s) at the specified prediction horizon(s).
Begin by fitting an ORSF ensemble
library(aorsf) set.seed(329) fit <- orsf(data = pbc_orsf, formula = Surv(time, status) ~ . - id) fit
## ---------- Oblique random survival forest ## ## Linear combinations: Accelerated ## N observations: 276 ## N events: 111 ## N trees: 500 ## N predictors total: 17 ## N predictors per node: 5 ## Average leaves per tree: 25 ## Min observations in leaf: 5 ## Min events in leaf: 1 ## OOB stat value: 0.84 ## OOB stat type: Harrell's C-statistic ## Variable importance: anova ## ## -----------------------------------------
Use the ensemble to compute ICE values using out-of-bag predictions:
pred_spec <- list(bili = seq(1, 10, length.out = 25)) ice_oob <- orsf_ice_oob(fit, pred_spec, boundary_checks = FALSE) ice_oob
## pred_horizon id_variable id_row bili pred ## 1: 1788 1 1 1 0.8935318 ## 2: 1788 1 2 1 0.1025087 ## 3: 1788 1 3 1 0.6959198 ## 4: 1788 1 4 1 0.3465760 ## 5: 1788 1 5 1 0.1105536 ## --- ## 6896: 1788 25 272 10 0.4409361 ## 6897: 1788 25 273 10 0.4493052 ## 6898: 1788 25 274 10 0.4696659 ## 6899: 1788 25 275 10 0.3892409 ## 6900: 1788 25 276 10 0.4565133
Much more detailed examples are given in the vignette