Skip to content

Instantly share code, notes, and snippets.

@revodavid
Created August 2, 2016 15:13
Show Gist options
  • Select an option

  • Save revodavid/d88be24806cabbdace431f34cc8661a1 to your computer and use it in GitHub Desktop.

Select an option

Save revodavid/d88be24806cabbdace431f34cc8661a1 to your computer and use it in GitHub Desktop.
set.seed(1)
N <- 2000
P <- 0.01
rare_success <- sample(c(TRUE, FALSE), N, replace=TRUE, prob=c(P, 1-P))
guess_not <- rep(0, N)
plot(roc(rare_success, guess_not), print.auc=TRUE)
##
## Call:
## roc.default(response = rare_success, predictor = guess_not)
##
## Data: guess_not in 1978 controls (rare_success FALSE) < 22 cases (rare_success TRUE).
## Area under the curve: 0.5
simp_roc <- simple_roc(rare_success, guess_not)
with(simp_roc, lines(1 - FPR, TPR, col="blue", lty=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment