diff --git a/R/MeasureSurvChamblessAUC.R b/R/MeasureSurvChamblessAUC.R index 15071a89..3d469ac6 100644 --- a/R/MeasureSurvChamblessAUC.R +++ b/R/MeasureSurvChamblessAUC.R @@ -15,6 +15,7 @@ #' #' @family AUC survival measures #' @family lp survival measures +#' @template example_auc_measures #' @export MeasureSurvChamblessAUC = R6Class("MeasureSurvChamblessAUC", inherit = MeasureSurvAUC, diff --git a/R/MeasureSurvHungAUC.R b/R/MeasureSurvHungAUC.R index 91141cd9..c8cf41ce 100644 --- a/R/MeasureSurvHungAUC.R +++ b/R/MeasureSurvHungAUC.R @@ -15,6 +15,7 @@ #' #' @family AUC survival measures #' @family lp survival measures +#' @template example_auc_measures #' @export MeasureSurvHungAUC = R6Class("MeasureSurvHungAUC", inherit = MeasureSurvAUC, diff --git a/R/MeasureSurvSongAUC.R b/R/MeasureSurvSongAUC.R index 401a1888..ee79ec93 100644 --- a/R/MeasureSurvSongAUC.R +++ b/R/MeasureSurvSongAUC.R @@ -16,6 +16,7 @@ #' #' @family AUC survival measures #' @family lp survival measures +#' @template example_auc_measures #' @export MeasureSurvSongAUC = R6Class("MeasureSurvSongAUC", inherit = MeasureSurvAUC, diff --git a/R/MeasureSurvUnoAUC.R b/R/MeasureSurvUnoAUC.R index b1565944..9c5c3ffe 100644 --- a/R/MeasureSurvUnoAUC.R +++ b/R/MeasureSurvUnoAUC.R @@ -16,6 +16,7 @@ #' #' @family AUC survival measures #' @family lp survival measures +#' @template example_auc_measures #' @export MeasureSurvUnoAUC = R6Class("MeasureSurvUnoAUC", inherit = MeasureSurvAUC, diff --git a/man-roxygen/example_auc_measures.R b/man-roxygen/example_auc_measures.R new file mode 100644 index 00000000..c229fa96 --- /dev/null +++ b/man-roxygen/example_auc_measures.R @@ -0,0 +1,27 @@ +#' <% measure = suppressWarnings(get(fullname)$new()) %> +#' +#' @examples +#' library(mlr3) +#' +#' # Define a survival Task +#' task = tsk("lung") +#' +#' # Create train and test set +#' part = partition(task) +#' +#' # Train Cox learner on the train set +#' cox = lrn("surv.coxph") +#' cox$train(task, row_ids = part$train) +#' +#' # Make predictions for the test set +#' p = cox$predict(task, row_ids = part$test) +#' +#' # Integrated AUC score +#' p$score(msr("<%=measure$id%>"), task = task, train_set = part$train, learner = cox) +#' +#' # AUC at specific time point +#' p$score(msr("<%=measure$id%>", times = 600), task = task, train_set = part$train, learner = cox) +#' +#' # Integrated AUC at specific time points +#' p$score(msr("<%=measure$id%>", times = c(100, 200, 300, 400, 500)), task = task, train_set = part$train, learner = cox) +#' diff --git a/man/mlr_measures_surv.chambless_auc.Rd b/man/mlr_measures_surv.chambless_auc.Rd index 6b8476ac..88e68bca 100644 --- a/man/mlr_measures_surv.chambless_auc.Rd +++ b/man/mlr_measures_surv.chambless_auc.Rd @@ -61,6 +61,32 @@ If \code{integrated == FALSE} then a single time point at which to return the sc } } +\examples{ +library(mlr3) + +# Define a survival Task +task = tsk("lung") + +# Create train and test set +part = partition(task) + +# Train Cox learner on the train set +cox = lrn("surv.coxph") +cox$train(task, row_ids = part$train) + +# Make predictions for the test set +p = cox$predict(task, row_ids = part$test) + +# Integrated AUC score +p$score(msr("surv.chambless_auc"), task = task, train_set = part$train, learner = cox) + +# AUC at specific time point +p$score(msr("surv.chambless_auc", times = 600), task = task, train_set = part$train, learner = cox) + +# Integrated AUC at specific time points +p$score(msr("surv.chambless_auc", times = c(100, 200, 300, 400, 500)), task = task, train_set = part$train, learner = cox) + +} \references{ Chambless LE, Diao G (2006). \dQuote{Estimation of time-dependent area under the ROC curve for long-term risk prediction.} diff --git a/man/mlr_measures_surv.hung_auc.Rd b/man/mlr_measures_surv.hung_auc.Rd index e5207db4..3f05b93c 100644 --- a/man/mlr_measures_surv.hung_auc.Rd +++ b/man/mlr_measures_surv.hung_auc.Rd @@ -61,6 +61,32 @@ If \code{integrated == FALSE} then a single time point at which to return the sc } } +\examples{ +library(mlr3) + +# Define a survival Task +task = tsk("lung") + +# Create train and test set +part = partition(task) + +# Train Cox learner on the train set +cox = lrn("surv.coxph") +cox$train(task, row_ids = part$train) + +# Make predictions for the test set +p = cox$predict(task, row_ids = part$test) + +# Integrated AUC score +p$score(msr("surv.hung_auc"), task = task, train_set = part$train, learner = cox) + +# AUC at specific time point +p$score(msr("surv.hung_auc", times = 600), task = task, train_set = part$train, learner = cox) + +# Integrated AUC at specific time points +p$score(msr("surv.hung_auc", times = c(100, 200, 300, 400, 500)), task = task, train_set = part$train, learner = cox) + +} \references{ Hung H, Chiang C (2010). \dQuote{Estimation methods for time-dependent AUC models with survival data.} diff --git a/man/mlr_measures_surv.song_auc.Rd b/man/mlr_measures_surv.song_auc.Rd index f57df554..deceab50 100644 --- a/man/mlr_measures_surv.song_auc.Rd +++ b/man/mlr_measures_surv.song_auc.Rd @@ -69,6 +69,32 @@ incident TPR, \code{cumulative} refers to cumulative TPR. } } +\examples{ +library(mlr3) + +# Define a survival Task +task = tsk("lung") + +# Create train and test set +part = partition(task) + +# Train Cox learner on the train set +cox = lrn("surv.coxph") +cox$train(task, row_ids = part$train) + +# Make predictions for the test set +p = cox$predict(task, row_ids = part$test) + +# Integrated AUC score +p$score(msr("surv.song_auc"), task = task, train_set = part$train, learner = cox) + +# AUC at specific time point +p$score(msr("surv.song_auc", times = 600), task = task, train_set = part$train, learner = cox) + +# Integrated AUC at specific time points +p$score(msr("surv.song_auc", times = c(100, 200, 300, 400, 500)), task = task, train_set = part$train, learner = cox) + +} \references{ Song, Xiao, Zhou, Xiao-Hua (2008). \dQuote{A semiparametric approach for the covariate specific ROC curve with survival outcome.} diff --git a/man/mlr_measures_surv.uno_auc.Rd b/man/mlr_measures_surv.uno_auc.Rd index 5536ad7a..b4206ac2 100644 --- a/man/mlr_measures_surv.uno_auc.Rd +++ b/man/mlr_measures_surv.uno_auc.Rd @@ -61,6 +61,32 @@ If \code{integrated == FALSE} then a single time point at which to return the sc } } +\examples{ +library(mlr3) + +# Define a survival Task +task = tsk("lung") + +# Create train and test set +part = partition(task) + +# Train Cox learner on the train set +cox = lrn("surv.coxph") +cox$train(task, row_ids = part$train) + +# Make predictions for the test set +p = cox$predict(task, row_ids = part$test) + +# Integrated AUC score +p$score(msr("surv.uno_auc"), task = task, train_set = part$train, learner = cox) + +# AUC at specific time point +p$score(msr("surv.uno_auc", times = 600), task = task, train_set = part$train, learner = cox) + +# Integrated AUC at specific time points +p$score(msr("surv.uno_auc", times = c(100, 200, 300, 400, 500)), task = task, train_set = part$train, learner = cox) + +} \references{ Uno H, Cai T, Tian L, Wei LJ (2007). \dQuote{Evaluating Prediction Rules fort-Year Survivors With Censored Regression Models.}