roc.lr: Receiver Operating Characteristic (ROC) curve

View source: R/LogisticRegression.R

roc.lrR Documentation

Receiver Operating Characteristic (ROC) curve

Description

A method of judging the predictive performance of a model by plotting and/or averaging the probability of predicting the positive class correctly, over multiple thresholds. See 'Details'.

Usage

roc.lr(lrfit, newdata = NULL, plot = TRUE, len = 50)

Arguments

lrfit

an object of class "lr", the output from lr

newdata

an optional data frame to predict from. If ignored, the default data frame is that used to fit the original model.

plot

logical; if TRUE, then the ROC curve is plotted

len

optional; number of different thresholds to use.

Details

A positive prediction from a logistic regression model is made when

f(x; \beta) := X \beta \ge t.

where t is some threshold. See predict.lr for details. A different threshold t_0 will yield a different set of predictions. For a given sequence t_j in [min(t), max(t)], for j=1,\dots,J, the True Positive Rate (TPR) and False Positive Rate (FPR) can be calculated as

TPR(j) = \sum I(f(x_i;\beta) \geq t_j)/\sum I(y_i = 1),

FPR(j) = \frac{\sum I(f(x_i;\beta) < t_j)}{\sum I(y_i = 1)}.

The ROC curve is plotted from the pairs (FPR(j), TPR(j)), and the AUC is calculated as the area under this curve, i.e.

AUC = \int_{j=1}^J TPR(FPR(j))dj.

Value

the AUC value, and a plot of the ROC curve if plot=TRUE


dannyjameswilliams/danielR documentation built on Aug. 20, 2023, 3:25 a.m.