An R6 class to assess a model with continuous output with one metric versus another.
Ass2d.Rd
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 toROCR::performance()
.If
y_metric
is"logrank"
or"precision_ci"
(the lower limit of theconfidence_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
andy_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 thetrans
parameter ofggplot2::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 ofggplot2
will be used.theme
S3 object inheriting from
"theme"
and"gg"
(typically the return value ofggplot2::theme()
or a complete ggplot2 theme likeggplot2::theme_light()
). The theme of the plot. Default isggplot2::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
andheight
. Default is"in"
(inches).dpi
numeric. Plot resolution in dots per inch.
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
andreturn_type == "ggplot
, store the resulting plot in this file.fellow_csv
logical. If
TRUE
,file
is notNULL
andreturn_type == "ggplot"
, store the plotted data in a csv namedfile
with replaced file extension.quiet
logical. Whether to suppress messages.
msg_prefix
string. Prefix for messages. Default is
""
.
Method assess_center()
Wrap assess()
to assess multiple models and store the result.
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
.