bin: A constructor to bin objects

Description Usage Arguments Details Value Examples

View source: R/constructor.R

Description

A (helper) constructor to create objects of class bin. Each bin object inherits from the class list.

Usage

1
2
3
4
5
6
7
bin(
  num_obl = integer(),
  num_def = integer(),
  min_score = double(),
  max_score = double(),
  ...
)

Arguments

num_obl

An integer representing the number of obligors (customers). This value must include both defaults and non-defaults.

num_def

An integer representing the number of defaults. The defaults is the stock of obligors that are (currently) in non-default state but defaults at least once in the next 12-month period (typically).

min_score

A double representing the minimum score.

max_score

A double representing the maximum score.

...

Optional parameters passed on to the constructor. Used internally to set is_merged to TRUE as part of the merge functionality.

Details

Validation is performed on the arguments before passing on the values to the constructor. Also, a print method exists for bin objects.

Value

An object of class bin. The structure of each bin is the following

num_obl

The number of obligors (customers).

num_def

The number of defaults.

dr

The default rate.

odds

The odds ratio.

min_score

The minimum score.

mid_score

The midpoint score (simple average of min_score and max_score).

max_score

The maximum score.

is_merged

A boolean. TRUE indicates the bin has been merged with other bins. FALSE implies the bin is identical to the initialized bin. The merged status is visible in the print() output of bin objects.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# create a single bin object
single_bin <- bin(num_obl = 100, num_def = 5, min_score = 30, max_score = 60)
print(single_bin)

# create a list of bins
bins <- list(
          bin(num_obl = 100, num_def = 5, min_score = 30, max_score = 60),
          bin(num_obl = 200, num_def = 5, min_score = 61, max_score = 80)
          )
print(bins)

rrunner/binsmlr documentation built on July 19, 2020, 12:41 a.m.