Skip to contents

Methods to plot prediction error curves (pecs) for either a PredictionSurv object or a list of trained LearnerSurvs.

Usage

pecs(x, measure = c("graf", "logloss"), times, n, eps = NULL, ...)

# S3 method for class 'list'
pecs(
  x,
  measure = c("graf", "logloss"),
  times,
  n,
  eps = NULL,
  task = NULL,
  row_ids = NULL,
  newdata = NULL,
  train_task = NULL,
  train_set = NULL,
  proper = TRUE,
  ...
)

# S3 method for class 'PredictionSurv'
pecs(
  x,
  measure = c("graf", "logloss"),
  times,
  n,
  eps = 1e-15,
  train_task = NULL,
  train_set = NULL,
  proper = TRUE,
  ...
)

Arguments

x

(PredictionSurv or list of LearnerSurvs)

measure

(character(1))
Either "graf" for MeasureSurvGraf, or "logloss" for MeasureSurvIntLogloss

times

(numeric())
If provided then either a vector of time-points to evaluate measure or a range of time-points.

n

(integer())
If times is missing or given as a range, then n provide number of time-points to evaluate measure over.

eps

(numeric())
Small error value to prevent errors resulting from a log(0) or 1/0 calculation. Default is 1e-15 for log loss and 1e-3 for Graf.

...

Additional arguments.

task

(TaskSurv)

row_ids

(integer())
Passed to Learner$predict.

newdata

(data.frame())
If not missing Learner$predict_newdata is called instead of Learner$predict.

train_task

(TaskSurv)
If not NULL then passed to measures for computing estimate of censoring distribution on training data.

train_set

(numeric())
If not NULL then passed to measures for computing estimate of censoring distribution on training data.

proper

(logical(1))
Passed to MeasureSurvGraf or MeasureSurvIntLogloss.

Details

If times and n are missing then measure is evaluated over all observed time-points from the PredictionSurv or TaskSurv object. If a range is provided for times without n, then all time-points between the range are returned.

Examples

if (FALSE) { # \dontrun{
if (requireNamespace("ggplot2", quietly = TRUE)) {
  #' library(mlr3)
  task = tsk("rats")

  # Prediction Error Curves for prediction object
  learn = lrn("surv.coxph")
  p = learn$train(task)$predict(task)
  pecs(p)
  pecs(p, measure = "logloss", times = c(20, 40, 60, 80)) +
    ggplot2::geom_point() +
    ggplot2::ggtitle("Logloss Prediction Error Curve for Cox PH")

  # Access underlying data
  x = pecs(p)
  x$data

  # Prediction Error Curves for fitted learners
  learns = lrns(c("surv.kaplan", "surv.coxph"))
  lapply(learns, function(x) x$train(task))
  pecs(learns, task = task, measure = "logloss", times = c(20, 90), n = 10)
}
} # }