orsf_control_custom {aorsf} | R Documentation |
Custom ORSF control
orsf_control_custom(beta_fun, ...)
beta_fun |
(function) a function to define coefficients used
in linear combinations of predictor variables.
In addition, |
... |
Further arguments passed to or from other methods (not currently used). |
an object of class 'orsf_control'
, which should be used as
an input for the control
argument of orsf.
Two customized functions to identify linear combinations of predictors are shown here.
The first uses random coefficients
The second derives coefficients from principal component analysis.
f_rando()
is our function to get the random coefficients:
f_rando <- function(x_node, y_node, w_node){ matrix(runif(ncol(x_node)), ncol=1) }
We can plug f_rando
into orsf_control_custom()
, and then pass the
result into orsf()
:
library(aorsf) fit_rando <- orsf(pbc_orsf, Surv(time, status) ~ . - id, control = orsf_control_custom(beta_fun = f_rando), n_tree = 500) fit_rando
## ---------- Oblique random survival forest ## ## Linear combinations: Custom user function ## N observations: 276 ## N events: 111 ## N trees: 500 ## N predictors total: 17 ## N predictors per node: 5 ## Average leaves per tree: 23 ## Min observations in leaf: 5 ## Min events in leaf: 1 ## OOB stat value: 0.82 ## OOB stat type: Harrell's C-statistic ## Variable importance: anova ## ## -----------------------------------------
Follow the same steps as above, starting with the custom function:
f_pca <- function(x_node, y_node, w_node) { # estimate two principal components. pca <- stats::prcomp(x_node, rank. = 2) # use the second principal component to split the node pca$rotation[, 2L, drop = FALSE] }
Then plug the function into orsf_control_custom()
and pass the result
into orsf()
:
fit_pca <- orsf(pbc_orsf, Surv(time, status) ~ . - id, control = orsf_control_custom(beta_fun = f_pca), n_tree = 500)
How well do our two customized ORSFs do? Let’s compute their indices of prediction accuracy based on out-of-bag predictions:
library(riskRegression)
## riskRegression version 2022.09.23
library(survival) risk_preds <- list(rando = 1 - fit_rando$pred_oobag, pca = 1 - fit_pca$pred_oobag) sc <- Score(object = risk_preds, formula = Surv(time, status) ~ 1, data = pbc_orsf, summary = 'IPA', times = fit_pca$pred_horizon)
The PCA ORSF does quite well! (higher IPA is better)
sc$Brier
## ## Results by model: ## ## model times Brier lower upper IPA ## 1: Null model 1788 20.479 18.090 22.868 0.000 ## 2: rando 1788 12.381 10.175 14.588 39.541 ## 3: pca 1788 12.496 10.476 14.515 38.983 ## ## Results of model comparisons: ## ## times model reference delta.Brier lower upper p ## 1: 1788 rando Null model -8.098 -10.392 -5.804 4.558033e-12 ## 2: 1788 pca Null model -7.983 -9.888 -6.078 2.142713e-16 ## 3: 1788 pca rando 0.114 -0.703 0.932 7.838255e-01 ## ## NOTE: Values are multiplied by 100 and given in %. ## NOTE: The lower Brier the better, the higher IPA the better.
linear combination control functions
orsf_control_cph()
,
orsf_control_fast()
,
orsf_control_net()