psi: psi

Description Usage Arguments Details Value Author(s) References Examples

View source: R/psi.r

Description

Compute the psi

psi calculates the popolation stability index.

Usage

1
2
3
4
5
psi(original, current, cut.points = NULL,
  cut.levels = ifelse(is.null(cut.points), 5L, NULL))

psi(original, current, cut.points = NULL,
  cut.levels = ifelse(is.null(cut.points), 5L, NULL))

Arguments

original

The original set of a measurement, should be a factor or numeric

current

The current set of a measurement, should be a factor or numeric

cut.points

It won't work if original and current are factors, and it cannot be NULL if original and current are numerical. This function uses this argument to bin original and current with left-closed right-open intervals.

cut.levels

specifies how many levels to split a numeric variable. If cut.points is provided, this parameter will be ignored. When using this parameter, a numeric variable will be split using cut.

x_train

expected or training variable, should be a factor

x_test

observed or actual variable, should be a factor

Details

Population stability index (PSI) or system stability index (SSI)

Check whether the population on which the model is currently being used is similar to the population that was used to develop it.

psi measures the stablity of the population. Usually we can believe the population stays the same as the past if psi is less than 0.1, and a significant shift can be recognised if psi is greater than 0.25. The outcome of this function is a numeric, with details stored as attributes. You can use summary function to see all of the detailed information. Fot the situation where some of the levels has no element in either original population or current population and the psi does not exist for such levels, the empty levels will not be taken into account and a warning will inform you of this. Again, by using summary you could know everything inside.

Value

psi value

a psi object

Author(s)

Nguyen Ngoc Binh nguyenngocbinhneu@gmail.com

Siyuan Yao

References

P395, Credit risk analytics - Measurement technique, applications and examples Rules of thumb when using psi:

PSI shift
----------------- ----------------
< 0.1 no significant shift (green traffic light)
0.1 to 0.25 moderate shift (yellow traffic light)
> 0.25 significant shift (red traffic light)

https://www.quora.com/What-is-population-stability-index

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data('hmeq')
library(rsample)
hmeq1 <- hmeq[,c("bad", "reason", "job")]
spl <- initial_split(hmeq1)
train_df <- training(spl)
test_df <- testing(spl)
psi1 <- psi(train_df$job, test_df$job)

data('iris')
train <- sample(nrow(iris), nrow(iris) * .7)
train.species <- iris$Species[train]
test.species <- iris$Species[-train]
p <- psi(train.species, test.species)
p
summary(p)

nguyenngocbinh/scorecard.sea documentation built on Jan. 4, 2020, 11:43 a.m.