find_AUC_q: Find area matching polynomial curve.

Description Usage Arguments Value Examples

View source: R/ROC.R

Description

Based on https://win-vector.com/2020/09/13/why-working-with-auc-is-more-powerful-than-one-might-think/

Usage

1
2
3
4
5
6
7
8
find_AUC_q(
  modelPredictions,
  yValues,
  ...,
  na.rm = FALSE,
  yTarget = TRUE,
  n_points = 101
)

Arguments

modelPredictions

numeric predictions (not empty), ordered (either increasing or decreasing)

yValues

truth values (not empty, same length as model predictions)

...

force later arguments to bind by name.

na.rm

logical, if TRUE remove NA values.

yTarget

value considered to be positive.

n_points

number of points to use in estimates.

Value

q that such that curve 1 - (1 - (1-ideal_roc$Specificity)^q)^(1/q) matches area

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
d <- data.frame(pred = 1:4, truth = c(TRUE,FALSE,TRUE,TRUE))
q <- find_AUC_q(d$pred, d$truth)
roc <- build_ROC_curve(d$pred, d$truth)
ideal_roc <- data.frame(Specificity = seq(0, 1, length.out = 101))
ideal_roc$Sensitivity <- sensitivity_from_specificity_q(ideal_roc$Specificity, q)
# library(ggplot2)
# ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) +
#   geom_line(data = roc, color = "DarkBlue") +
#   geom_line(data  = ideal_roc, color = "Orange") +
#   theme(aspect.ratio=1) +
#   ggtitle("example actual and ideal curve")

sigr documentation built on June 12, 2021, 9:07 a.m.