| scr_lgd | R Documentation |
Fits the standard two-stage structure on the RDS of scr_workout():
\mathrm{LGD} = P(\mathrm{cure}\mid x)\,\mathrm{LGD}^{\mathrm{cure}} + \big(1 - P(\mathrm{cure}\mid x)\big)\,\mathrm{E}[\mathrm{LGD}\mid \mathrm{no\ cure}, x]
The cure stage is a binary model on is_cure with the scorecard
machinery: optimal binning of the drivers on the training cohorts, WOE,
hold-out revalidation with frozen bins and a logistic regression on the
WOE columns with the sign check (every coefficient positive). The
severity stage bins the same drivers against the realized LGD of
the non-cures with scr_bin_continuous() (bin means, monotone, at least
lgd_min_defaults_bin defaults per bin, hold-out revalidated) and fits a
fractional logit (glm with a quasi-binomial family on the bin means)
or, with lgd_severity = "beta", a beta regression through the
betareg package. LGD^cure is the mean realized LGD of the cures on
train (costs and the discount effect, never zero by decree).
scr_lgd(
x,
drivers,
config = scr_config(),
holdout = 0.3,
date_col = "default_date"
)
x |
An |
drivers |
Column names of the RDS to use as drivers. |
config |
A |
holdout |
Share of the cohorts held out (by default date). |
date_col |
Column of the RDS with the default date. |
The split is by cohort of default: the last holdout share of the
default dates is the hold-out. Metrics on both samples: RMSE, MAE,
R-squared, Spearman rho, Somers' D of the prediction with respect to
the realized LGD (generalized AUC (D + 1) / 2) with a bootstrap
confidence interval, and the loss capture ratio. Pools come from
scr_lgd_pools(). The object carries a provisional downturn (type 3
add-on, or none, by configuration) and no floor until
scr_lgd_downturn() and scr_lgd_floor() run.
An object of class scr_lgd: split, drivers, cure (fit,
features, coef, sign_check, bins, holdout), severity (fit, features,
coef, engine, sign_check, bins), lgd_cure, has_cures, scored (one
row per default: sample, p_cure, severity, lgd_pred, pool,
lgd_real), bins_idx, samples (predicted vs realized by decile of
the prediction), metrics, pools, downturn, floors, workout
(the profile and summary of the RDS), model_card, ledger, config.
Other irb-lgd:
scr_elbe(),
scr_lgd_downturn(),
scr_lgd_floor(),
scr_lgd_pools(),
scr_lgd_validate(),
scr_workout()
cfg <- scr_config(verbose = FALSE, nthread = 1, n_boot = 20)
wo <- scr_workout(scr_demo_lgd, scr_demo_lgd_cashflows, rates = scr_demo_rates, config = cfg)
m <- scr_lgd(wo, drivers = c("product", "ltv", "prior_dpd_max", "months_on_book", "region"),
config = cfg)
m
m$pools[, c("pool", "n", "lra", "lra_ew", "moc_c", "lgd_dt")]
m$metrics
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.