# roc.lr: Receiver Operating Characteristic (ROC) curve In dannyjameswilliams/danielR: Collection of Danny's R Code

## 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

 1 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; β) := X β ≥ 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,…,J, the True Positive Rate (TPR) and False Positive Rate (FPR) can be calculated as

TPR(j) = ∑ I(f(x_i;β) ≥q t_j)/∑ I(y_i = 1),

FPR(j) = \frac{∑ I(f(x_i;β) < t_j)}{∑ 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 Feb. 1, 2021, 6:39 p.m.