Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.83 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Howto Plot ROC curve in R with only known SN/PPV/Cutoff info
  2. #Cutpoint         SN   (1-PPV)
  3. 5       0.56    0.01
  4. 7       0.78    0.19
  5. 9       0.91    0.58
  6.        
  7. ## your data with different labels
  8. dat <- data.frame(cutpoint = c(5, 7, 9),
  9.                   TPR = c(0.56, 0.78, 0.91),
  10.                   FPR = c(0.01, 0.19, 0.58))
  11.  
  12. ## plot version 1    
  13. op <- par(xaxs = "i", yaxs = "i")
  14. plot(TPR ~ FPR, data = dat, xlim = c(0,1), ylim = c(0,1), type = "n")
  15. with(dat, lines(c(0, FPR, 1), c(0, TPR, 1), type = "o", pch = 25, bg = "black"))
  16. text(TPR ~ FPR, data = dat, pos = 3, labels = dat$cutpoint)
  17. abline(0, 1)
  18. par(op)
  19.        
  20. plot(TPR ~ FPR, data = dat, xlim = c(0,1), ylim = c(0,1), type = "n")
  21. with(dat, lines(c(0, FPR, 1), c(0, TPR, 1), type = "o", pch = 25, bg = "black"))
  22. text(TPR ~ FPR, data = dat, pos = 3, labels = dat$cutpoint)
  23. abline(0, 1)