| scr_psi | R Documentation |
PSI = sum((p - q) * ln(p / q)) over bins frozen on the base. Reports
both thresholds side by side: the traditional fixed one (< 0.10
"stable", 0.10-0.25 "moderate", >= 0.25 "shift") and the
sample-size-adjusted critical value of Yurdakul and Naranjo (2020), under
which the PSI is asymptotically (1/n + 1/m) * chi-squared(B - 1). With
n = m = 1000 and ten bins the 5% critical value is 0.034, not 0.10; on a
monthly base of a hundred thousand rows, PSI = 0.01 is already
significant. The fixed threshold remains what the market knows; the
adjusted one is what the statistics support.
scr_psi(
base,
compare,
levels = NULL,
breaks = NULL,
n_groups = 10L,
alpha = 0.05,
thresholds = c(0.1, 0.25)
)
base |
Reference vector (the "development" distribution). |
compare |
Vector to compare. |
levels |
For categorical vectors: the levels to consider. |
breaks |
For numeric vectors: frozen cut points. |
n_groups |
Number of bands when |
alpha |
Significance level of the adjusted threshold. |
thresholds |
The two fixed thresholds: below the first the flag is
|
Rows where base or compare is NA, or that fall outside breaks or
levels, are not counted. A band empty in both samples is left out of
the index and of the degrees of freedom B - 1; when a populated band is
empty on one side only, 0.5 is added to every populated band of both
samples.
A list of class scr_psi with psi, flag_fixed, critical
(adjusted critical value), flag_adjusted ("stable" or "shift"),
n_base, n_compare, n_bins (bands declared; the degrees of
freedom count only the populated ones) and table (per band: n_base,
n_compare, pct_base, pct_compare, psi_band).
The thresholds and alpha used are stored and printed.
Yurdakul, B. and Naranjo, J. (2020). Statistical properties of the population stability index. Journal of Risk Model Validation, 14(4), 89-100.
Other metrics:
scr_iv(),
scr_metrics()
set.seed(2)
base <- stats::rnorm(5000)
new <- stats::rnorm(5000, mean = 0.15)
p <- scr_psi(base, new)
p
p$table
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.