| scr_pd_validate | R Documentation |
Runs the standard battery on a monthly panel with the default flag and
the grade (or the score) at every month: obligors non-defaulted at each
cohort start form the population, the outcome is a default within
horizon months, exactly as scr_default_rate() does.
scr_pd_validate(
x,
newdata,
id = "id",
date = "date",
default = "default",
grade = NULL,
score = NULL,
auc_init = NULL,
cv_init = NULL,
tests = c("jeffreys", "binomial", "normal", "hl", "multi_period", "auc",
"concentration", "psi", "migration"),
alpha = 0.05,
lights = NULL,
pd_column = c("pd_final", "pd_moc", "pd_be"),
horizon = 12L,
by = NULL,
n_boot = NULL,
seed = NULL
)
x |
An |
newdata |
A |
id, date, default |
Column names. |
grade |
Column name of the grade at every month; |
score |
Column name of the production score at every month, optional. |
auc_init |
Development AUC; |
cv_init |
Development coefficient of variation; |
tests |
Subset of the battery to run. |
alpha |
Significance level of the binomial critical count. |
lights |
Two p-value thresholds (red at or below the first, amber at
or below the second, green above; the convention shared with the LGD
and EAD validations); |
pd_column |
Grade PD tested: |
horizon, by |
Cohort window in months and frequency ( |
n_boot, seed |
Bootstrap resamples and seed of the discrimination interval. |
Per grade (pooled over cohorts) and per cohort and
grade: Jeffreys p = F_Beta(PD; D + 1/2, N - D + 1/2), the binomial
P(X >= D) with its critical count at alpha, the normal z, and
the traffic light on the Jeffreys p-value. Portfolio: the same tests
on the totals, Hosmer-Lemeshow over the grades (K degrees of
freedom: the grade PDs are not fitted on the validation sample), the
multi-period normal test over the cohort differences DR_t - PD_t
(BCBS Working Paper 14, 2005) and the Brier score.
AUC, Gini and KS with a bootstrap interval
(scr_metrics()) on the score when a score column exists,
otherwise on the grade; the S statistic against auc_init
((AUC_init - AUC_curr) / se, with the DeLong standard error of
the current AUC), p = 1 - Phi(S).
PSI of the grade distribution against the development
sample per cohort (scr_psi()); the migration matrix pooled over
the cohorts whose end date is observed (scr_migration()); the
concentration test on the coefficient of variation of the latest
cohort against cv_init.
An object of class scr_pd_validation: calibration (per
grade, pooled), calibration_cohort (per cohort and grade),
portfolio (per cohort), portfolio_tests (list: n, d, dr,
pd, p_jeffreys, p_binomial, hl_chi2, hl_df, hl_p,
multi_period_z, multi_period_p, brier), discrimination,
stability (psi table, migration, concentration), summary
(one row per test with statistic, p_value, light; the light is
"grey" when the row has no testable result, such as a missing p-value
or the descriptive migration bandwidth), light (the worst light of the
summary: red, then amber, then green; "grey" when no row has a
testable result), n_cohorts, alpha, lights.
portfolio_tests also carries critical, z, p_normal, n_cohorts
and pd_column; the object also has horizon, by, pd_column and
target.
Other irb-pd:
predict.scr_grades(),
predict.scr_pd(),
scr_calibrate(),
scr_grades(),
scr_master_scale(),
scr_migration(),
scr_moc(),
scr_pd(),
scr_pd_pit_ttc()
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)
pd <- scr_pd(scr_moc(scr_grades(sc, n_grades = 6, min_defaults = 10), "C", method = "ci_binomial"))
# the validation panel: default flag at every month plus the grade at the
# cohort start; here the behavioural score of the panel is graded with the
# cut points of the PD model
d <- scr_default(scr_demo_panel, "id", "ref_date", dpd = "dpd", config = cfg)
pnl <- merge(d$flags, scr_demo_panel[, c("id", "ref_date", "score")],
by.x = c("id", "date"), by.y = c("id", "ref_date"))
pnl$grade <- predict(pd, score = pnl$score, type = "grade")
v <- scr_pd_validate(pd, pnl, id = "id", date = "date", default = "default",
grade = "grade", score = "score", by = "quarter")
v
v$summary
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.