sensitivity_and_specificity_s12p12n: Compute the shape1_pos, shape2_pos, shape1_neg, shape2_neg...

Description Usage Arguments Value Examples

View source: R/ROC.R

Description

Compute specificity and sensitivity given specificity and model fit parameters.

Usage

1
2
3
4
5
6
7
8
sensitivity_and_specificity_s12p12n(
  Score,
  ...,
  shape1_pos,
  shape2_pos,
  shape1_neg,
  shape2_neg
)

Arguments

Score

vector of sensitivities to evaluate

...

force later arguments to bind by name.

shape1_pos

beta shape1 parameter for positive examples

shape2_pos

beta shape2 parameter for positive examples

shape1_neg

beta shape1 parameter for negative examples

shape2_neg

beta shape1 parameter for negative examples

Value

Score, Specificity and Sensitivity data frame

Examples

 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
library(wrapr)

empirical_data <- rbind(
  data.frame(
    Score = rbeta(1000, shape1 = 3, shape2 = 2),
    y = TRUE),
  data.frame(
    Score = rbeta(1000, shape1 = 5, shape2 = 4),
    y = FALSE)
)

unpack[shape1_pos = shape1, shape2_pos = shape2] <-
  fit_beta_shapes(empirical_data$Score[empirical_data$y])

shape1_pos
shape2_pos

unpack[shape1_neg = shape1, shape2_neg = shape2] <-
  fit_beta_shapes(empirical_data$Score[!empirical_data$y])

shape1_neg
shape2_neg

ideal_roc <- sensitivity_and_specificity_s12p12n(
  seq(0, 1, 0.1),
  shape1_pos = shape1_pos,
  shape1_neg = shape1_neg,
  shape2_pos = shape2_pos,
  shape2_neg = shape2_neg)


empirical_roc <- build_ROC_curve(
  modelPredictions = empirical_data$Score,
  yValues = empirical_data$y
)

# # should look very similar
# library(ggplot2)
# ggplot(mapping = aes(x = 1 - Specificity, y = Sensitivity)) +
#   geom_line(data = empirical_roc, color='DarkBlue') +
#   geom_line(data = ideal_roc, color = 'Orange')

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