| scr_grades | R Documentation |
Cuts the production score into grades whose PD is monotone. The grade
boundaries are score cut points, direction-aware: grade 1 is the safest
(the highest scores under higher_is_safer). Three constructions:
"geometric" builds a scr_master_scale() between percentiles 1
and 99 of the calibrated PD and converts its PD bounds into scores
through the calibrated alignment; "quantile" cuts equal-count score
bands (cut points moved half-way between neighboring scores, so a
boundary never sits on an observed value); "supplied" grades by the PD
bands of a given master scale.
scr_grades(
x,
calibration = NULL,
master_scale = NULL,
n_grades = NULL,
method = NULL,
min_obligors = NULL,
min_defaults = NULL,
monotone = TRUE,
pd_source = NULL,
sample = "holdout",
dr = NULL
)
x |
An |
calibration |
An |
master_scale |
An |
n_grades, method, min_obligors, min_defaults, pd_source |
|
monotone |
Repair non-monotone grade PDs by pooling. |
sample |
Sample of the scorecard used to build the grades. |
dr |
Optional |
Grades below min_obligors obligors or min_defaults defaults are
merged with the neighbor of closer default rate; the sequence of grade
PDs is then repaired by pool-adjacent-violators when monotone = TRUE,
and every merge is recorded in repairs. The grade PD (pd_be) is the
long-run average of the grade default rates when a default-rate series
by grade is given in dr (pd_source = "lra"), the sample default rate
of the grade otherwise, or the mean of the calibrated individual PDs
(pd_source = "mean_pd"). Concentration is reported as the Herfindahl
index, the coefficient of variation of the grade shares and the
Herfindahl-based hi index.
An object of class scr_grades: table (grade, label,
score_lo, score_hi, pd_lo, pd_hi, n, share, defaults,
dr, pd_mean, pd_be, merged_from, and n_series, t_series
when a series is given), breaks (ascending score cut points),
band_grade (grade of every score band, ascending), direction,
method, pd_source, master_scale, alignment (calibrated),
alignment_score (the scorecard's), concentration (hhi, cv,
hi, k), repairs, ledger, moc (empty, filled by
scr_moc()), dr (the pooled series), rows (score, outcome and
grade of the sample), scorecard, sample, ct, sample_rate.
Also calibration (the scr_pd_calibration when one was given),
n_grades_requested, min_obligors, min_defaults, target and
config.
The series must be keyed by the final grades of this same call. Run
scr_grades() once, grade the cohort panel with predict.scr_grades(),
build the series with scr_default_rate() (grade =) and pass it as
dr in a second call with identical arguments (or in scr_moc() and
scr_pd_validate(), which read it the same way).
Other irb-pd:
predict.scr_grades(),
predict.scr_pd(),
scr_calibrate(),
scr_master_scale(),
scr_migration(),
scr_moc(),
scr_pd(),
scr_pd_pit_ttc(),
scr_pd_validate()
cfg <- scr_config(verbose = FALSE, nthread = 1, use_ranger = FALSE,
use_lightgbm = FALSE, xgb_rounds = 40, n_boot = 10)
res <- scr_select(scr_demo, "default", config = cfg, drop = c("id", "churn"),
date_col = "ref_date")
sc <- scr_scorecard(res)
cal <- scr_calibrate(sc, target = 0.06)
gr <- scr_grades(sc, cal, n_grades = 7, min_defaults = 10)
gr
gr$table[, c("grade", "score_lo", "score_hi", "n", "dr", "pd_be")]
# grade a cohort panel with the score cut points (the panel score is a
# different scale; the demo only shows the mechanics)
head(predict(gr, score = scr_demo_panel$score))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.