if (requireNamespace('data.table', quietly = TRUE)) {
# don't multi-thread during CRAN checks
data.table::setDTthreads(1)
}
beta_example <- function(
n,
shape1_pos, shape2_pos,
shape1_neg, shape2_neg) {
d <- data.frame(
y = sample(
c(TRUE, FALSE),
size = n,
replace = TRUE),
score = 0.0
)
d$score[d$y] <- rbeta(sum(d$y), shape1 = shape1_pos, shape2 = shape2_pos)
d$score[!d$y] <- rbeta(sum(!d$y), shape1 = shape1_neg, shape2 = shape2_neg)
d
}
d1 <- beta_example(
100,
shape1_pos = 6,
shape2_pos = 5,
shape1_neg = 1,
shape2_neg = 2)
ROCPlot(
d1,
xvar = "score",
truthVar = "y", truthTarget = TRUE,
title="Example ROC plot",
estimate_sig = TRUE,
add_beta_ideal_curve = TRUE,
add_convex_hull = TRUE)
Run the code above in your browser using DataLab