orsf_pd_oob {aorsf}  R Documentation 
Compute partial dependence for an ORSF model. Partial dependence (PD) shows the expected prediction from a model as a function of a single predictor or multiple predictors. The expectation is marginalized over the values of all other predictors, giving something like a multivariable adjusted estimate of the model's prediction. You can compute partial dependence three ways using a random forest:
using inbag predictions for the training data
using outofbag predictions for the training data
using predictions for a new set of data
See examples for more details
orsf_pd_oob(
object,
pred_spec,
pred_horizon = NULL,
pred_type = "risk",
expand_grid = TRUE,
prob_values = c(0.025, 0.5, 0.975),
prob_labels = c("lwr", "medn", "upr"),
boundary_checks = TRUE,
...
)
orsf_pd_inb(
object,
pred_spec,
pred_horizon = NULL,
pred_type = "risk",
expand_grid = TRUE,
prob_values = c(0.025, 0.5, 0.975),
prob_labels = c("lwr", "medn", "upr"),
boundary_checks = TRUE,
...
)
orsf_pd_new(
object,
pred_spec,
new_data,
pred_horizon = NULL,
pred_type = "risk",
na_action = "fail",
expand_grid = TRUE,
prob_values = c(0.025, 0.5, 0.975),
prob_labels = c("lwr", "medn", "upr"),
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 
prob_values 
(numeric) a vector of values between 0 and 1,
indicating what quantiles will be used to summarize the partial
dependence values at each set of inputs. 
prob_labels 
(character) a vector of labels with the same length
as 
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

Partial dependence has a number of known limitations and assumptions that users should be aware of (see Hooker, 2021). In particular, partial dependence is less intuitive when >2 predictors are examined jointly, and it is assumed that the feature(s) for which the partial dependence is computed are not correlated with other features (this is likely not true in many cases). Accumulated local effect plots can be used (see here) in the case where feature independence is not a valid assumption.
a data.table containing partial dependence values for the specified variable(s) at the specified prediction horizon(s).
Begin by fitting an ORSF ensemble:
library(aorsf) set.seed(329730) index_train < sample(nrow(pbc_orsf), 150) pbc_orsf_train < pbc_orsf[index_train, ] pbc_orsf_test < pbc_orsf[index_train, ] fit < orsf(data = pbc_orsf_train, formula = Surv(time, status) ~ .  id, oobag_pred_horizon = 365.25 * 5)
You can compute partial dependence and ICE three ways with aorsf
:
using inbag predictions for the training data
pd_train < orsf_pd_inb(fit, pred_spec = list(bili = 1:5)) pd_train
## pred_horizon bili mean lwr medn upr ## 1: 1826.25 0.452406674 0.2061119 0.01444274 0.09357446 0.8053158 ## 2: 1826.25 0.224302469 0.2348236 0.02656555 0.12452704 0.8206148 ## 3: 1826.25 0.003801737 0.2749933 0.04342625 0.17565052 0.8406553 ## 4: 1826.25 0.231905942 0.3299184 0.09191382 0.24263728 0.8544871 ## 5: 1826.25 0.460010148 0.3837488 0.15153571 0.30165878 0.8663482
using outofbag predictions for the training data
pd_train < orsf_pd_oob(fit, pred_spec = list(bili = 1:5)) pd_train
## pred_horizon bili mean lwr medn upr ## 1: 1826.25 0.452406674 0.2072237 0.01383381 0.08975103 0.7998756 ## 2: 1826.25 0.224302469 0.2348821 0.02603647 0.12916899 0.8152149 ## 3: 1826.25 0.003801737 0.2746627 0.04234095 0.18723298 0.8371582 ## 4: 1826.25 0.231905942 0.3298811 0.08621202 0.24652942 0.8441472 ## 5: 1826.25 0.460010148 0.3843112 0.14684189 0.29917249 0.8562432
using predictions for a new set of data
pd_test < orsf_pd_new(fit, new_data = pbc_orsf_test, pred_spec = list(bili = 1:5)) pd_test
## pred_horizon bili mean lwr medn upr ## 1: 1826.25 0.452406674 0.2540722 0.01564154 0.1912170 0.8103449 ## 2: 1826.25 0.224302469 0.2823693 0.03037250 0.2304118 0.8413602 ## 3: 1826.25 0.003801737 0.3204294 0.04941981 0.2735839 0.8495418 ## 4: 1826.25 0.231905942 0.3742045 0.10428307 0.3494399 0.8619464 ## 5: 1826.25 0.460010148 0.4258066 0.16681425 0.4032790 0.8626002
inbag partial dependence indicates relationships that the model has learned during training. This is helpful if your goal is to interpret the model.
outofbag partial dependence indicates relationships that the model has learned during training but using the outofbag data simulates application of the model to new data. if you want to test your model’s reliability or fairness in new data but you don’t have access to a large testing set.
new data partial dependence shows how the model predicts outcomes for observations it has not seen. This is helpful if you want to test your model’s reliability or fairness.
Giles Hooker, Lucas Mentch, Siyu Zhou. Unrestricted Permutation forces Extrapolation: Variable Importance Requires at least One More Model, or There Is No Free Variable Importance. arXiv eprints 2021 Oct; arXiv1905. URL: https://doi.org/10.48550/arXiv.1905.03151