auc | R Documentation |

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), ...)
auc_histogram(x)
```

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

`cut.points` |
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). |

`x` |
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) %>%
auc_histogram()
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.