smbinning.factor.custom: Customized Binning on Factor Variables

Description Usage Arguments Value Examples

View source: R/smbinning.R

Description

It gives the user the ability to combine categories and create new attributes for a given characteristic. Once these new attribues are created in a list (called groups), the funtion generates a table for the uniques values of a given factor variable.

Usage

1
smbinning.factor.custom(df, y, x, groups)

Arguments

df

A data frame.

y

Binary response variable (0,1). Integer (int) is required. Name of y must not have a dot.

x

A factor variable with at least 2 different values. Value Inf is not allowed.

groups

Specifies customized groups created by the user. Name of x must not have a dot.

Value

The command smbinning.factor.custom generates an object containing the necessary information and utilities for binning. The user should save the output result so it can be used with smbinning.plot, smbinning.sql, and smbinning.gen.factor.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Load library and its dataset
library(smbinning) # Load package and its data

# Example: Customized binning for a factor variable
# Notation: Groups between double quotes
result=smbinning.factor.custom(
  smbsimdf1,x="inc",
  y="fgood",
  c("'W01','W02'",        # Group 1
    "'W03','W04','W05'",  # Group 2
    "'W06','W07'",        # Group 3
    "'W08','W09','W10'")) # Group 4
result$ivtable

Example output

Loading required package: sqldf
Loading required package: gsubfn
Loading required package: proto
Loading required package: RSQLite
Loading required package: partykit
Loading required package: grid
Loading required package: libcoin
Loading required package: mvtnorm
Loading required package: Formula
Warning message:
no DISPLAY variable so Tk is not available 
     Cutpoint CntRec CntGood CntBad CntCumRec CntCumGood CntCumBad PctRec
1     W01/W02    273     133    140       273        133       140 0.1092
2 W03/W04/W05    516     336    180       789        469       320 0.2064
3     W06/W07    502     428     74      1291        897       394 0.2008
4 W08/W09/W10    989     923     66      2280       1820       460 0.3956
5     Missing    220     180     40      2500       2000       500 0.0880
6       Total   2500    2000    500        NA         NA        NA 1.0000
  GoodRate BadRate    Odds  LnOdds     WoE     IV
1   0.4872  0.5128  0.9500 -0.0513 -1.4376 0.3069
2   0.6512  0.3488  1.8667  0.6242 -0.7621 0.1463
3   0.8526  0.1474  5.7838  1.7551  0.3688 0.0243
4   0.9333  0.0667 13.9848  2.6380  1.2517 0.4124
5   0.8182  0.1818  4.5000  1.5041  0.1178 0.0012
6   0.8000  0.2000  4.0000  1.3863  0.0000 0.8911

smbinning documentation built on May 1, 2019, 10:06 p.m.