scr_ead_data: Build the realized-CCF reference data set from facility...

View source: R/ead.R

scr_ead_dataR Documentation

Build the realized-CCF reference data set from facility snapshots

Description

One row per default event (or per event and reference date under the variable-horizon comparison), with the facility as it stood at the reference date and the realized exposure at default (EAD) at the default date, from which the realized credit conversion factor (CCF) follows. The reference date follows config$ccf_horizon: "fixed" takes the snapshot ccf_horizon_months before the default month (the nearest earlier snapshot when that month is missing; the first snapshot for a facility younger than the horizon, flagged FAST_DEFAULT); "cohort" takes the start of the calendar cohort window in which the default falls; "variable" takes every snapshot in the horizon before the default, for comparison only.

Usage

scr_ead_data(
  snapshots,
  facility_id,
  obligor_id = NULL,
  date_col,
  limit,
  drawn,
  default_date = NULL,
  defaulted = NULL,
  drivers = NULL,
  config = scr_config(),
  keep_rows = FALSE
)

Arguments

snapshots

A data.frame or data.table with one row per facility and month.

facility_id, date_col, limit, drawn

Column names of the facility identifier, the snapshot month, the limit and the drawn amount.

obligor_id

Column name of the obligor, optional. With config$default_level = "obligor" a default of any facility of the obligor is a default of all its facilities observed at that date.

default_date

Either the name of a column of snapshots holding the default date of the facility (NA when it never defaults) or a data.frame with the facility identifier column (same name as facility_id) and a default_date column, one row per event.

defaulted

Column name of a 0/1 default flag per snapshot, alternative to default_date: every run of ones opens an event at its first month.

drivers

Column names measured at the reference date and carried into the data set (candidate drivers of the pools). utilisation_ref, limit_ref, drawn_ref and horizon_months are always available.

config

A scr_config(); keys ⁠ccf_*⁠, post_default_drawings_in, default_level.

keep_rows

If TRUE, keeps every candidate event with its exclusion rule in rows.

Details

The realized measure per row follows config$ccf_measure: under "auto" the undrawn-limit factor (CCF) when the utilization at the reference date is below ccf_u_star and the limit factor (LF) at or above it; rows with nothing undrawn or over the limit at the reference date are always routed to the limit factor (ZERO_UNDRAWN, OVER_LIMIT_AT_REF), never dropped. The raw realized value is kept in ccf_raw; ccf carries the value after the optional floor (ccf_floor_realised) and cap (ccf_cap_realised), both logged in the funnel (NEGATIVE_CCF_FLOORED, CCF_ABOVE_ONE). The realized EAD is the drawn amount at the default date, uncapped; with post_default_drawings_in = "ccf" it is the maximum drawn amount over the default event when defaulted is given.

Value

An object of class scr_ead_data: rds (one row per event: event_id, facility_id, obligor_id, ref_date, default_date, cohort, horizon_months, fast_default, limit_ref, drawn_ref, undrawn_ref, utilisation_ref, limit_default, limit_change, ead_realised, measure, ccf_raw, ccf, rule, drivers), funnel (rule, action, n, share), summary (simple and exposure-weighted averages by cohort and measure, with a total row), lra (long-run averages and shares), meta, ledger, config and rows (with keep_rows = TRUE).

References

Basel Committee on Banking Supervision (2023). The Basel Framework, CRE32 and CRE36. Moral, G. (2006). EAD estimates for facilities with explicit limits. In Engelmann, B. and Rauhmeier, R. (eds), The Basel II Risk Parameters. Springer.

See Also

Other irb-ead: scr_bin_continuous(), scr_ead(), scr_ead_downturn(), scr_ead_validate()

Examples

cfg <- scr_config(verbose = FALSE)
ed <- scr_ead_data(scr_demo_ead, facility_id = "facility_id", obligor_id = "obligor_id",
                   date_col = "ref_date", limit = "limit", drawn = "drawn",
                   defaulted = "defaulted",
                   drivers = c("product", "months_on_book", "dpd"), config = cfg)
ed
ed$funnel
head(ed$rds[, c("facility_id", "ref_date", "default_date", "utilisation_ref", "measure", "ccf")])

scorecraft documentation built on Dec. 6, 2026, 1:09 a.m.