The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
cutpointr includes several convenience functions for plotting data from a cutpointr
object. These include:
plot_cutpointr
: General purpose plotting function for cutpointr or roc_cutpointr objectsplot_cut_boot
: Plot the bootstrapped distribution of optimal cutpointsplot_metric
: If maximize_metric
or minimize_metric
was used this function plots all possible cutoffs on the x-axis vs. the respective metric values on the y-axis. If bootstrapping was run, a confidence interval based on the bootstrapped distribution of metric values at each cutpoint can be displayed. To display no confidence interval set conf_lvl = 0
.plot_metric_boot
: Plot the distribution of out-of-bag metric valuesplot_precision_recall
: Plot the precision recall curveplot_sensitivity_specificity
: Plot all cutpoints vs. sensitivity and specificityplot_roc
: Plot the ROC curveplot_x
: Plot the distribution of the predictor variablelibrary(cutpointr)
set.seed(123)
opt_cut_b_g <- cutpointr(suicide, dsi, suicide, gender, boot_runs = 500)
## Assuming the positive class is yes
## Assuming the positive class has higher x values
## Running bootstrap...
## Warning: Removed 1 rows containing non-finite values (stat_density).
## Warning: Removed 8 rows containing non-finite values (stat_density).
All plot functions, except for the standard plot method that returns a composed plot, return ggplot
objects than can be further modified. For example, changing labels, title, and the theme can be achieved this way:
library(ggplot2)
p <- plot_x(opt_cut_b_g)
p + ggtitle("Distribution of dsi") +
theme_minimal() +
xlab("Depression score")
Using plot_cutpointr
any metric can be chosen to be plotted on the x- or y-axis and results of cutpointr()
as well as roc()
can be plotted. If a cutpointr
object is to be plotted, it is thus irrelevant which metric
function was chosen for cutpoint estimation. Any metric that can be calculated based on the ROC curve can be subsequently plotted as only the true / false positives / negatives over all cutpoints are needed. That way, not only the above plots can be produced, but also any combination of two metrics (or metric functions) and / or cutpoints. The built-in metric functions as well as user-defined functions or anonymous functions can be supplied to xvar
and yvar
. If bootstrapping was run, confidence intervals can be plotted around the y-variable. This is especially useful if the cutpoints, available in the cutpoints
function, are placed on the x-axis. Note that confidence intervals can only be correctly plotted if the values of xvar
are constant across bootstrap samples. For example, confidence intervals for TPR by FPR (a ROC curve) cannot be plotted easily, as the values of the false positive rate vary per bootstrap sample.
## Assuming the positive class is yes
## Assuming the positive class has higher x values
## Running bootstrap...
Since cutpointr
returns a data.frame
with the original data, bootstrap results, and the ROC curve in nested tibbles, these data can be conveniently extracted and plotted manually. The relevant nested tibbles are in the columns data
, roc_curve
and boot
. The following is an example of accessing and plotting the grouped data.
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.