Learn R Programming

InformationValue (version 1.2.3)

ks_stat: ks_stat

Description

Compute the Kolmogorov-Smirnov statistic

Usage

ks_stat(actuals, predictedScores, returnKSTable = FALSE)

Arguments

actuals
The actual binary flags for the response variable. It can take a numeric vector containing values of either 1 or 0, where 1 represents the 'Good' or 'Events' while 0 represents 'Bad' or 'Non-Events'.
predictedScores
The prediction probability scores for each observation. If your classification model gives the 1/0 predcitions, convert it to a numeric vector of 1's and 0's.
returnKSTable
If set to TRUE, returns the KS table used to calculate the KS statistic instead. Defaults to FALSE.

Value

The KS statistic for a given actual values of a binary response variable and the respective prediction probability scores.

Details

Compute the KS statistic for a given actuals and predicted scores for a binary response variable. KS statistic is calculated as the maximum difference between the cumulative true positive and cumulative false positive rate. Set returnKSTable to TRUE to see the calculations from ks_table.

Examples

Run this code
data('ActualsAndScores')
ks_stat(actuals=ActualsAndScores$Actuals, predictedScores=ActualsAndScores$PredictedScores)

Run the code above in your browser using DataLab