auc: Calculate exact AUCs based on the distribution of risk in a...

aucR Documentation

Calculate exact AUCs based on the distribution of risk in a population


Provided a distribution of risk in a population, this function calculates the exact AUC of a model that produces the risk estimates. For example, a logistic regression model built with a normal linear predictor yields logit-normal distributed predicted risks. The AUC from the logistic regression model is the same as the AUC estimated from the distribution of the predicted risks, independent of the outcome. This method for AUC calculation is useful for simulation studies where the predicted risks are a mixture of two distributions. The exact prevalence of the outcome can easily be calculated, along with the exact AUC of the model.


auc_density(density, cut.points = seq(from = 0, to = 1, by = 0.001), ...)




a function name that describes the continuous probability density function of the risk from 0 to 1.


sequence of points in [0, 1] where the sensitivity and specificity are calculated. More points lead to a more precise estimate of the AUC. Default is seq(from = 0, to = 1,by = 0.001).


arguments for the function specified in density. For example, dbeta(x, shape1=1, shape2=1) has need for two additional arguments to specify the density function (shape1 and shape2).


histogram object from graphics::hist


Returns a list sensitivity and specificity at each cut point, the expected value or mean risk, and the AUC associated with the distribution.


Daniel D Sjoberg


auc_density(density = dbeta, shape1 = 1, shape2 = 1)

runif(10000) %>%
  hist(breaks = 250) %>%

ddsjoberg/bstfun documentation built on July 4, 2023, 10:59 a.m.