Skip to contents

Assess how well a model can predict time to event less than a certain threshold with two metrics by thresholding the continuous output in every possible way and then plot one metric for a binary classifier against another one.

Public fields

x_metric, y_metric

Metrics shown on both axes.

confidence_level

Confidence level gamma, e.g., for confidence intervals.

x_lab, y_lab

Axis labels.

xlim, ylim

Axis limits.

scale_x, scale_y

The scale of the axes.

alpha

The alpha value for the points in the plot.

colors

Colors used by ggplot2.

theme

Theme applied to the plot.

width, height, units

The size of the plot in units.

dpi

Plot resolution in dots per inch.

Active bindings

x_metric, y_metric

Metrics shown on both axes.

x_lab, y_lab

Axis labels.

xlim, ylim

Axis limits.

scale_x, scale_y

The scale of the axes.

width, height, units

The size of the plot in units.

Methods


Method new()

Construct an Ass2d instance.

Usage

Ass2d$new(
  x_metric,
  y_metric,
  confidence_level = 0.95,
  x_lab = NULL,
  y_lab = NULL,
  xlim = c(-Inf, Inf),
  ylim = c(-Inf, Inf),
  scale_x = "identity",
  scale_y = "identity",
  alpha = 1,
  colors = NULL,
  theme = ggplot2::theme_minimal(),
  width = 7,
  height = 4,
  units = "in",
  dpi = 300
)

Arguments

x_metric, y_metric

string. Metric shown on the x and y axis. Regarding the choices:

  • Every combination of (measure, x.measure) one can pass to ROCR::performance().

  • If y_metric is "logrank" or "precision_ci" (the lower limit of the confidence_level confidence interval of the precision, see below), x_metric must be "prevalence" or "rpp" (rate of positive predictions).

  • For (x_metric, y_metric) = ("rank", "risk score"), plot the rank of every risk score against the risk score and color by true risk.

confidence_level

numeric in [0, 1]. Confidence level gamma for confidence intervals.

x_lab, y_lab

string. Axis labels. Default is x_metric and y_metric.

xlim, ylim

numeric vector of length 2. The limits for both axes. Default is no limits

scale_x, scale_y

string or transformation object (see scales::trans_new for the latter). The scale of the axes, we will pass them to the trans parameter of ggplot2::scale_x_continuous(), ggplot2::scale_y_continuous(), respectively.

alpha

numeric in [0, 1]. The alpha value for the points and lines in the plot.

colors

character vector. The colors to be used for the different models. Default is NULL, which means that the default colors of ggplot2 will be used.

theme

S3 object inheriting from "theme" and "gg" (typically the return value of ggplot2::theme() or a complete ggplot2 theme like ggplot2::theme_light()). The theme of the plot. Default is ggplot2::theme_minimal().

width

numeric. The width of the plot in units.

height

numeric. The height of the plot in units.

units

string. The units of width and height. Default is "in" (inches).

dpi

numeric. Plot resolution in dots per inch.

Returns

A new Ass2d object.


Method assess()

Assess a single model.

Usage

Ass2d$assess(
  data,
  model,
  return_type = "ggplot",
  file = NULL,
  fellow_csv = FALSE,
  quiet = FALSE,
  msg_prefix = ""
)

Arguments

data

Data object. Assess on this data. The cohort attribute must be set.

model

Model object. Assess this model.

return_type

string. Either "ggplot" or "tibble". See return section for details.

file

string. If not NULL and return_type == "ggplot, store the resulting plot in this file.

fellow_csv

logical. If TRUE, file is not NULL and return_type == "ggplot", store the plotted data in a csv named file with replaced file extension.

quiet

logical. Whether to suppress messages.

msg_prefix

string. Prefix for messages. Default is "".

Returns

ggplot object if return_type == "ggplot" or the tibble underlying the plot if return_type == "tibble".


Method assess_center()

Wrap assess() to assess multiple models and store the result.

Usage

Ass2d$assess_center(
  data,
  model_list,
  file = NULL,
  fellow_csv = FALSE,
  quiet = FALSE
)

Arguments

data

Data object. Assess on this data. The cohort attribute must be set.

model_list

list of Model objects. Assess these models.

file

string or NULL. If not NULL, store the resulting plot in this file.

fellow_csv

logical. Whether to also store the plotted data in a csv.

quiet

logical. Whether to suppress messages. Default is FALSE.


Method clone()

The objects of this class are cloneable with this method.

Usage

Ass2d$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.