
An R6 class to assess a model with continuous output with one metric versus another.
Ass2d.RdAssess 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_metricMetrics shown on both axes.
confidence_levelConfidence level gamma, e.g., for confidence intervals.
x_lab, y_labAxis labels.
xlim, ylimAxis limits.
scale_x, scale_yThe scale of the axes.
alphaThe alpha value for the points in the plot.
colorsColors used by ggplot2.
themeTheme applied to the plot.
width, height, unitsThe size of the plot in units.
dpiPlot resolution in dots per inch.
Active bindings
x_metric, y_metricMetrics shown on both axes.
x_lab, y_labAxis labels.
xlim, ylimAxis limits.
scale_x, scale_yThe scale of the axes.
width, height, unitsThe 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_metricstring. Metric shown on the x and y axis. Regarding the choices:
Every combination of (
measure,x.measure) one can pass toROCR::performance().If
y_metricis"logrank"or"precision_ci"(the lower limit of theconfidence_levelconfidence interval of the precision, see below),x_metricmust 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_levelnumeric in [0, 1]. Confidence level gamma for confidence intervals.
x_lab, y_labstring. Axis labels. Default is
x_metricandy_metric.xlim, ylimnumeric vector of length 2. The limits for both axes. Default is no limits
scale_x, scale_ystring or transformation object (see
scales::trans_newfor the latter). The scale of the axes, we will pass them to thetransparameter ofggplot2::scale_x_continuous(),ggplot2::scale_y_continuous(), respectively.alphanumeric in [0, 1]. The alpha value for the points and lines in the plot.
colorscharacter vector. The colors to be used for the different models. Default is
NULL, which means that the default colors ofggplot2will be used.themeS3 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().widthnumeric. The width of the plot in
units.heightnumeric. The height of the plot in
units.unitsstring. The units of
widthandheight. Default is"in"(inches).dpinumeric. 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
dataData object. Assess on this data. The
cohortattribute must be set.modelModel object. Assess this model.
return_typestring. Either "ggplot" or "tibble". See return section for details.
filestring. If not
NULLandreturn_type == "ggplot, store the resulting plot in this file.fellow_csvlogical. If
TRUE,fileis notNULLandreturn_type == "ggplot", store the plotted data in a csv namedfilewith replaced file extension.quietlogical. Whether to suppress messages.
msg_prefixstring. Prefix for messages. Default is
"".
Method assess_center()
Wrap assess() to assess multiple models and store the result.
Arguments
dataData object. Assess on this data. The
cohortattribute must be set.model_listlist of Model objects. Assess these models.
filestring or NULL. If not
NULL, store the resulting plot in this file.fellow_csvlogical. Whether to also store the plotted data in a csv.
quietlogical. Whether to suppress messages. Default is
FALSE.