简体   繁体   中英

Calculate AUC for the ROC in R

I'm quite new to R and I was wondering how can i achieve following thing: I have two vectors (of the same length), one contains sensitivity (tpr) values and the other corresponding 1-specificity (fpr) values. I would like to create a ROC curve and calculate area under curve. Is there some simple way of doing that? I tried to use auc function from the AUC package, but when using auc(tpr, fpr) i get an error: Error in auc(tpr, fpr) : object 'ans' not found.

If you have TPR and FPR you can calculate the area under the curve using a trapezoidal approximation. This can be calculated in R using the trapz function.

By plotting TPR vs FPR you will be able to visualise the curve. Perhaps start with this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM