woe.tbl: Weights of evidence (WoE) table

View source: R/02_BIVARIATE_ANALYSIS.R

woe.tblR Documentation

Weights of evidence (WoE) table

Description

woe.tbl calculates WoE and information value for given target variable and risk factor along with accompanied metrics needed for their calculation. WoE table reports:

  • bin: Risk factor group (bin).

  • no: Number of observations per bin.

  • ng: Number of good cases (where target is equal to 0) per bin.

  • nb: Number of bad cases (where target is equal to 1) per bin.

  • pct.o: Percentage of observations per bin.

  • pct.g: Percentage of good cases (where target is equal to 0) per bin.

  • pct.b: Percentage of bad cases (where target is equal to 1) per bin.

  • dr: Default rate per bin.

  • so: Number of all observations.

  • sg: Number of all good cases.

  • sb: Number of all bad cases.

  • dist.g: Distribution of good cases per bin.

  • dist.b: Distribution of bad cases per bin.

  • woe: WoE value.

  • iv.b: Information value per bin.

  • iv.s: Information value of risk factor (sum of individual bins' information values).

Usage

woe.tbl(tbl, x, y, y.check = TRUE)

Arguments

tbl

Data frame which contains target variable (y) and analyzed risk factor (x).

x

Selected risk factor.

y

Selected target variable.

y.check

Logical, if target variable (y) should be checked for 0/1 values. Default value is TRUE. Change of this parameter to FALSE can be handy for calculation of WoE based on model predictions. Concretely, it is used only in calculation of marginal information value (MIV) in stepMIV.

Value

The command woe.tbl returns the data frame with WoE and information value calculations along with accompanied metrics.

See Also

bivariate for automatic bivariate analysis.

Examples

suppressMessages(library(PDtoolkit))
data(gcd)
#categorize numeric risk factors
gcd$age.bin <- woe.bin(x = gcd$age, y = gcd$qual, y.type = "bina")[[2]]
#generate woe table
woe.tbl(tbl = gcd, x = "age.bin", y = "qual")

PDtoolkit documentation built on Sept. 20, 2023, 9:06 a.m.