Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ks

Kolmogorov-Smirnov statistic for predicted binary response


Description

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

Usage

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

Examples

# 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

StatMeasures

Easy Data Manipulation, Data Quality and Statistical Checks

v1.0
GPL-2
Authors
Akash Jain
Initial release
2015-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.