Skip to content

Commit

Permalink
conditional survmetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Jan 19, 2024
1 parent bfd39f1 commit ab0fa93
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions vignettes/oobag.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ knitr::opts_chunk$set(
library(aorsf)
library(survival)
library(SurvMetrics)
```

Expand Down Expand Up @@ -97,15 +96,27 @@ In some cases, you may want more control over how out-of-bag error is estimated.
oobag_brier_surv <- function(y_mat, w_vec, s_vec){
# output is numeric vector of length 1
as.numeric(
SurvMetrics::Brier(
object = Surv(time = y_mat[, 1], event = y_mat[, 2]),
pre_sp = s_vec,
# t_star in Brier() should match oob_pred_horizon in orsf()
t_star = 2000
# use if SurvMetrics is available
if(requireNamespace("SurvMetrics")){
return(
# output is numeric vector of length 1
as.numeric(
SurvMetrics::Brier(
object = Surv(time = y_mat[, 1], event = y_mat[, 2]),
pre_sp = s_vec,
# t_star in Brier() should match oob_pred_horizon in orsf()
t_star = 2000
)
)
)
)
}
# if not available, use a dummy version
mean( (y_mat[,2] - s_vec)^2 )
}
```
Expand Down

0 comments on commit ab0fa93

Please sign in to comment.