woe_single: Calculate the Weights of Evidence for a variable, given...

Description Usage Arguments Details Value See Also

Description

This function will calculate the Weight of Evidence for each bin of a given variable, according to a specified binary response. A vector of bins can be supplied, or a pre-binned variable can be supplied.

Usage

1
woe_single(dat, var, bins = 0, response, warn = TRUE, auto_merge = FALSE)

Arguments

dat

The dataset containing the response and desired variable

var

Character string containing the name of the variable

bins

Either a numeric vector specifying the cutpoints for the desired variable, or 0. If 0, the function assumes that the variable is already binned, and throws an error if it is not of type "factor"

response

Character string specifying the name of the response variable

warn

Logical- should the function print a warning if a given bin contains only one level of the response (and hence has a WOE of +/- Inf)? Recommended to keep this to TRUE; FALSE option is provided for using this function in programming

auto_merge

Logical. If bins contain only one value of the response, should they be merged with an adjacent bin? If set to TRUE and warn is set to FALSE, the function can modify your data without telling you- be careful

Details

woe_single allows the user to easily calculate Weights of Evidence for arbitrary bins for a given variable. The function will throw an error if bins is 0 and the supplied variable is not a factor. The idea is for the user to supply their own bins obtained using, for example, one of the useful functions in the modellingTools package, such as vector_bin. When bins have only one level of the response, the WOE will be +/-; by default the function will not prevent this and issue a warning. You can turn off warnings and have the function auto-merge bins using the supplied options, but be sure to inspect the results carefully.

Value

A two column tbl containing the bin and the WOE value

See Also

information_value

Other metrics: information_value


awstringer/modellingTools documentation built on May 11, 2019, 4:11 p.m.