sc.merge {LGDtoolkit}R Documentation

Special case merging procedure

Description

sc.merge performs procedure of merging special case bins with one from complete cases. This procedure can be used not only for LGD model development, but also for PD and EAD, i.e. for all models that have categorical risk factors.

Usage

sc.merge(x, y, sc = "SC", sc.merge = "closest", force.trend = "modalities")

Arguments

x

Categorical risk factor.

y

Target variable.

sc

Vector of special case values. Default is set to "SC".

sc.merge

Merging method. Available options are: "first", "last" and "closest". Default value is "closest" and it is determined as the bin with the closest average target rate.

force.trend

Defines how initial summary table will be ordered. Possible options are:
"modalities" and "y.avg". If "modalities" is selected, then merging will be performed forward based on alphabetic order of risk factor modalities. On the other hand, if "y.avg" is selected, then bins merging will be performed forward based on increasing order of mean of target variable per modality.

Value

The command sc.merge generates a list of two objects. The first object, data frame summary.tbl presents a summary table of final binning, while x.trans is a vector of recoded values.

Examples

library(monobin)
library(LGDtoolkit)
data(lgd.ds.c)
rf.03.bin.s <- sts.bin(x = lgd.ds.c$rf_03, y = lgd.ds.c$lgd)
rf.03.bin.s[[1]]
table(rf.03.bin.s[[2]])
lgd.ds.c$rf_03_bin <- rf.03.bin.s[[2]]
rf.03.bin.c <- sc.merge(x = lgd.ds.c$rf_03_bin, 
			y = lgd.ds.c$lgd, 
			sc = "SC", 
			sc.merge = "closest", 
			force.trend = "modalities")
str(rf.03.bin.c)
rf.03.bin.c[[1]]
table(rf.03.bin.c[[2]])

[Package LGDtoolkit version 0.2.0 Index]