ks: Kolmogorov-Smirnov statistic for predicted binary response

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/ks.R

Description

Takes in actual binary response and predicted probabilities, and returns table used for KS computation and KS value

Usage

1
ks(y, yhat)

Arguments

y

actual binary response

yhat

predicted probabilities corresponding to the actual binary response

Details

Kolmogorov-Smirnov statistic can be easily computed using ks function. It not only computes the statistic but also returns the table used for ks computation. A chart is also plotted for quick visualization of split between percentage of responders and non-responders. Deciles are used for computation.

Appropriate elements of the 2 element list (ie. ksTable or ks) can be picked using the code given in the example.

Value

a two element list: table for KS computation and KS value itself

Author(s)

Akash Jain

See Also

accuracy, auc, iv, splitdata

Examples

1
2
3
4
5
6
7
8
# A 'data.frame' with y and yhat
df <- data.frame(y = c(1, 0, 1, 1, 0),
                 yhat = c(0.86, 0.23, 0.65, 0.92, 0.37))

# KS table and value
ltKs <- ks(y = df[, 'y'], yhat = df[, 'yhat'])
ksTable <- ltKs$ksTable
KS <- ltKs$ks

Example output



StatMeasures documentation built on May 2, 2019, 1:44 p.m.