impact_code: transform high cardinality categorical variables

Description Usage Arguments Details Value Examples

View source: R/impact_code.R

Description

impact_code transforms a categorical variable into a continuous one using Impact Coding described in this paper.

Usage

1
impact_code(.data, formula, binary = T)

Arguments

.data

the data frame the data is contained in

formula

a formula specifying the dependent and independent variables to use

binary

is the dependent variable a binary variable? Logical value

Details

Missing values in the categorical variable will be treated as another level. If you want to ignore missing values you will need to do so prior to calling impact_code.

Value

a data frame that includes the levels of the categorical variable and the smoothed estimate of the dependent variable.

Examples

1
2
impact_code(mtcars, am ~ cyl)
impact_code(iris, Petal.Width ~ Species, binary = F)

mattmills49/modeler documentation built on May 21, 2019, 1:25 p.m.