woe: Generate a weight of evidence (WoE) table

Description Usage Arguments Value See Also Examples

View source: R/woe.R

Description

woe() produces a weight of evidence table, evaluating x as the independent variable and y as the dependent variable. It depends on an S3 generic function bin for binning the values of x. Character, factor and logical vectors for x are all treated as categorical. Numeric vectors are treated as continuous (numeric) as long as they have more distinct values than the number of bins (numBins) specified, otherwise they are treated as categorical. Integer vectors are handled as numeric vectors.

Usage

1
woe(x, y, ...)

Arguments

x

character, factor, logical or numeric vector (independent variable)

y

logical, integer or numeric vector that is coercable to numeric with unique values of 0 and 1 (dependent variable)

...

further arguments passed to bin

Value

A data frame with class "mt_woe" summarizing the weight of evidence and information value calculations for an independent variable x with respect to a binary dependent variable y.

See Also

bin, infoValue, woeDT

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# factor
woe(iris$Species, round(runif(nrow(iris))))

# numeric - equally spaced vs. equally sized bins
x <- rnorm(1000, mean = 100, sd = 5)
y <- round(runif(1000))
woe(x, y)
woe(x, y, equalBinSize = TRUE)

# evaluate all columns in a data frame
wl <- lapply(mtcars, woe, y = round(runif(nrow(mtcars))))
names(wl)
wl$mpg
# create table of total info values
iv <- unlist(lapply(wl, infoValue))
data.frame(
    Variable = names(iv), 
    InformationValue = as.numeric(iv),
    stringsAsFactors = FALSE
)

dnegrey/miscTools documentation built on May 3, 2019, 2:57 p.m.