Search code examples
rlogistic-regressionconfidence-intervalprecision-recall

How to calculate 95% CI for area under the precision recall curve in R


I calculate area under the precision recall curve using the Mleval package. The Mleval package provides 95% CI for the AUROC but not AUPRC. Is there a package that provides 95% CI for AUPRC?


Solution

  • The precrec library gives an AUC for precision-recall as well as ROC, as shown in this example with dummy data:

    library(precrec)
    
    set.seed(1)
    
    ## Create sample datasets with 100 positives and 100 negatives
    samps <- create_sim_samples(2, 100, 100, "good_er")
    
    ## Single model & multiple test datasets
    smmdat <- mmdata(samps[["scores"]], samps[["labels"]],
                     modnames = samps[["modnames"]],
                     dsids = samps[["dsids"]])
    
    mod <- evalmod(smmdat)
    auc_ci(mod)
    #>   modnames curvetypes      mean        error lower_bound upper_bound n
    #> 1  good_er        ROC 0.8192000 0.0007839856   0.8184160    0.819984 2
    #> 2  good_er        PRC 0.8603505 0.0154645417   0.8448859    0.875815 2
    

    Created on 2022-03-06 by the reprex package (v2.0.1)