Description Usage Arguments Value Note Author(s) See Also Examples
Do the ROC (receiver operating characteristic) analysis and calculate vector of cut-off values and associated number of true positives (TP), false negatives (FN), false positives (FP), and true negatives (TN) as well as performance measures such as sensitivity, specificity, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ## S3 method for class 'as_str'
print(x, ...)
## S3 method for class 'roc_df'
print(x, ..., show_all = FALSE, perf_digits = 2, fmt = "%.3g")
## S3 method for class 'roc_opt_result'
print(x, digits = 3, ...)
## S3 method for class 'roc_info'
print(x, ...)
roc_analysis(
x,
gr,
pos_label = levels(gr)[2],
pos_is_larger = NULL,
optimize_by = "bac",
results = "all",
...
)
## Default S3 method:
roc_analysis(
x,
gr,
pos_label = levels(gr)[2],
pos_is_larger = NULL,
optimize_by = "bac",
results = "all",
...
)
## S3 method for class 'data.frame'
roc_analysis(
x,
gr,
pos_label = levels(gr)[2],
pos_is_larger = NULL,
optimize_by = "bac",
results = "all",
...
)
## S3 method for class 'matrix'
roc_analysis(
x,
gr,
pos_label = levels(gr)[2],
pos_is_larger = NULL,
optimize_by = "bac",
results = "all",
...
)
|
x |
( |
... |
[!!!] Passed to further methods. |
show_all |
( |
perf_digits |
( |
fmt |
( |
digits |
( |
gr |
( |
pos_label |
( |
pos_is_larger |
( |
optimize_by |
( |
results |
( |
A list (which also inherits from class "roc_result_list")
with three fields: $info, $optimal, $all_results.
$info is a data frame with columns
var_name - empty string reserved for variable name,
neg_label, pos_label labels of negative and positive
groups respectively,
n_neg, n_pos, n_total - number of negative
and positive cases as well as number of cases in total.
$optimal one row from $all_results, which was
determined as having optima threshold (cut-off) value. Sometimes it can be
several rows, if the performance is equally good.
$all_results is a data frame with columns
cutoffs for cutoff values,
tp (number of true positives),
fn (number of false negatives),
fp (number of false positives),
tn (number of true negatives),
... [!!!]
This function is inspired by functions predict and
.compute.unnormalized.roc.curve from ROCR package.
Vilmantas Gegzna
Other functions for ROC:
access_elements,
calculate_performance(),
roc_performance_measures,
roc_predict()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | library(manyROC)
library(ggplot2)
# Make some data
set.seed(1)
(x <- rnorm(10))
(gr <- gl(n = 2, k = 5, length = 10, labels = c("H", "S")))
# Explore the functions
roc_analysis(x, gr)
roc_analysis(x, gr, pos_label = "H")
# --- Example 2 ---
set.seed(1)
x2 <- c(rnorm(50, mean = 14), rnorm(50, mean = 20))
gr2 <- gl(2, 50, labels = c("Neg", "Pos"))
(roc_rez <- roc_analysis(x2, gr2))
optimal_cutoff2 <- roc_rez$optimal[1]
qplot(x2, fill = gr2, color = gr2,
geom = c("density", "rug"), alpha = I(0.3)) +
geom_vline(xintercept = optimal_cutoff2)
# --- Example 3 ---
set.seed(1)
x3 <- c(rnorm(100, mean = 11), rnorm(100, mean = 14))
gr3 <- gl(2, 100, labels = c("Neg", "Pos"))
(roc_rez3 <- roc_analysis(x3, gr3))
optimal_cutoff3 <- roc_rez3$optimal[1]
qplot(x3, fill = gr3, color = gr3,
geom = c("density", "rug"), alpha = I(0.3)) +
geom_vline(xintercept = roc_rez3$optimal[1])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.