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

Description Usage Arguments Details Value See Also


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.


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



The dataset containing the response and desired variable


Character string containing the name of the variable


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"


Character string specifying the name of the response variable


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


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


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.


A two column tbl containing the bin and the WOE value

See Also


Other metrics: information_value

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