Nothing
#' Synthetic example data
#'
#' A fabricated table so that every example and every vignette runs without
#' a database. On purpose, it carries the defects real data has: sentinel
#' `-999` in several masses (`vl_hist_*`), missing values (`vl_partial_*`),
#' a column that only degrades in the last period (`vl_late`), constant,
#' near-constant, exact duplicate, high cardinality, a redundant pair and
#' pure noise. Without them, the audit funnel would have nothing to show.
#'
#' @format A `data.frame` with 4,200 rows and 41 columns:
#' \describe{
#' \item{`id`}{Identifier (never a candidate; goes in `drop`).}
#' \item{`ref_date`}{Monthly reference date, six periods; the key of the
#' out-of-time split.}
#' \item{`vl_score_01` to `vl_score_12`}{Numerics with decreasing signal.}
#' \item{`vl_hist_01` to `vl_hist_05`}{Numerics with an increasing mass of
#' sentinel `-999`; the signal is in the absence.}
#' \item{`vl_partial_01` to `vl_partial_03`}{Numerics with genuine `NA`.}
#' \item{`vl_late`}{Numeric with `NA`/sentinel in the last period only.}
#' \item{`vl_noise_01` to `vl_noise_06`}{Pure noise.}
#' \item{`vl_constant`, `vl_near_const`, `ds_constant`, `vl_duplicate`,
#' `vl_redundant`, `ds_high_card`}{Structural pathologies.}
#' \item{`ds_region`, `ds_band`, `ds_channel`, `ds_optin`}{Categoricals with
#' signal; `ds_optin` has `NA`.}
#' \item{`default`}{Risk target (0/1, about 14% events).}
#' \item{`churn`}{Propensity target (0/1, about 29% events), for the
#' portfolio examples.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo.R`, seed `20260903`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' str(scr_demo[, 1:6])
#' mean(scr_demo$default)
"scr_demo"
#' Synthetic monthly panel for the default engine and PD calibration
#'
#' 600 obligors observed over 36 months. Days past due evolve as a chain
#' whose slip probability depends on a latent risk; arrears are proportional
#' to the exposure, with a few obligors whose arrears stay below the
#' absolute materiality threshold on purpose; 25 obligors are restructured
#' from month 18; `score` is a behavioral score (higher = safer) with
#' genuine rank-ordering power. Built for [scr_default()],
#' [scr_default_rate()] and the PD grade examples.
#'
#' @format A `data.frame` with 21,600 rows and 7 columns:
#' \describe{
#' \item{`id`}{Obligor identifier.}
#' \item{`ref_date`}{Month (first day), 36 periods from 2023-01.}
#' \item{`dpd`}{Days past due at the snapshot (multiples of 30).}
#' \item{`arrears`}{Overdue amount.}
#' \item{`exposure`}{Total exposure of the obligor (constant).}
#' \item{`restructured`}{Logical distressed-restructuring flag.}
#' \item{`score`}{Behavioral score, higher is safer.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_panel.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' head(scr_demo_panel)
#' mean(scr_demo_panel$dpd >= 90)
"scr_demo_panel"
#' Synthetic exposure snapshot for expected loss, capital and ECL
#'
#' 5,000 exposures in six segments that map one-to-one to the asset classes
#' of the IRB risk-weight function. The PD is a grade PD (constant within
#' asset class and grade; the ten geometric grades start below the
#' regulatory floors on purpose) and the LGD a pool value constant within
#' the segment, so that segment by grade is a homogeneous pool and the
#' production SQL of [scr_capital()] reproduces R exactly. About 3 % of the
#' exposures are in default with a best estimate of expected loss and a
#' provision close to it; the other columns feed the standardized
#' comparison and the accounting stage rule of [scr_ecl()].
#'
#' @format A `data.frame` with 5,000 rows and 21 columns:
#' \describe{
#' \item{`id`}{Exposure identifier.}
#' \item{`segment`}{Reporting segment (`retail_loans`, `mortgages`,
#' `cards_revolver`, `cards_transactor`, `corporate_large`,
#' `corporate_sme`).}
#' \item{`asset_class`}{Asset class of the risk-weight function.}
#' \item{`grade`}{PD grade, `G01` (safest) to `G10`.}
#' \item{`pd`}{One-year PD of the grade (decimal).}
#' \item{`lgd`}{Downturn LGD of the pool (decimal).}
#' \item{`ead`, `drawn`, `undrawn`}{Exposure at default and its split.}
#' \item{`m`}{Effective maturity in years (corporates only).}
#' \item{`sales`}{Annual sales in millions (corporates only).}
#' \item{`ltv`}{Loan-to-value at origination (mortgages only).}
#' \item{`rating`}{External rating (large corporates; `NA` unrated).}
#' \item{`transactor`}{Logical: revolving facility repaid in full monthly.}
#' \item{`defaulted`}{0/1 default flag (about 3 %).}
#' \item{`elbe`}{Best estimate of expected loss of the defaulted rows.}
#' \item{`provision`}{Provision stock.}
#' \item{`stage`}{Accounting stage 1, 2 or 3.}
#' \item{`dpd`}{Days past due.}
#' \item{`pd_orig`}{One-year PD at origination.}
#' \item{`eir`}{Annual effective interest rate.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_portfolio.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' head(scr_demo_portfolio)
#' table(scr_demo_portfolio$asset_class)
"scr_demo_portfolio"
#' Synthetic monthly facility snapshots for the EAD/CCF module
#'
#' 1,200 revolving facilities (cards, overdrafts and revolving lines) of
#' 950 obligors, observed monthly (snapshots dated the first day of the
#' month) over 30 months. Utilization
#' follows a facility-specific level with a mild drift; about 10% of the
#' facilities default, with the utilization ramping up over the twelve
#' months before the default month at an intensity that depends on the
#' drivers a CCF model is expected to find (utilization, product, months on
#' book, days past due). Some defaulters are fully drawn or over the limit
#' at the reference date, some repay before default (negative realized
#' CCF), some have their limit cut before default, a share of all
#' facilities gets a limit change and a few facilities originate inside the
#' window (fast defaults). Built for [scr_ead_data()], [scr_ead()] and
#' [scr_ead_validate()].
#'
#' @format A `data.frame` with 34,811 rows and 9 columns:
#' \describe{
#' \item{`facility_id`}{Facility identifier.}
#' \item{`obligor_id`}{Obligor identifier (a few obligors hold two facilities).}
#' \item{`ref_date`}{Month (first day), 30 periods from 2023-01.}
#' \item{`limit`}{Limit of the facility at the month end.}
#' \item{`drawn`}{Drawn amount at the month end, gross; may exceed the limit.}
#' \item{`product`}{`"card"`, `"overdraft"` or `"line"`.}
#' \item{`months_on_book`}{Age of the facility in months.}
#' \item{`dpd`}{Days past due at the month end (multiples of 30).}
#' \item{`defaulted`}{0/1 flag, 1 from the default month onward.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_ead.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' head(scr_demo_ead)
#' length(unique(scr_demo_ead$facility_id[scr_demo_ead$defaulted == 1]))
"scr_demo_ead"
#' Synthetic default events for the workout LGD examples
#'
#' 900 default events on three products (unsecured, mortgage, auto)
#' observed until 2026-06-30, with the drivers a workout LGD model reads:
#' collateral, loan-to-value, time on book, the worst delinquency before
#' default and the region. Cures return to performing within six months;
#' non-cures recover according to product-specific profiles until a close
#' date; events still running at the observation date are `open`, a few of
#' them older than the maximum recovery period. Thirty facilities default
#' twice after a cure, half of them within nine months, so that
#' [scr_workout()] merges the two spells into one event. Built for
#' [scr_workout()], [scr_lgd()] and the in-default examples.
#'
#' @format A `data.frame` with 900 rows and 12 columns:
#' \describe{
#' \item{`default_id`}{Default event identifier.}
#' \item{`facility_id`}{Facility identifier; repeated for the second defaults.}
#' \item{`default_date`}{Date of default.}
#' \item{`ead`}{Exposure at default.}
#' \item{`product`}{`"unsecured"`, `"mortgage"` or `"auto"`.}
#' \item{`collateral_value`}{Collateral value at default; `0` when unsecured.}
#' \item{`ltv`}{Loan-to-value at default; `0` when unsecured.}
#' \item{`months_on_book`}{Months since origination at default.}
#' \item{`prior_dpd_max`}{Worst days past due in the year before default (multiples of 30).}
#' \item{`region`}{Region of the facility.}
#' \item{`status`}{`"closed"`, `"cured"` or `"open"` at the observation date.}
#' \item{`close_date`}{Date the workout closed or the cure was confirmed; `NA` when open.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_lgd.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' table(scr_demo_lgd$product, scr_demo_lgd$status)
"scr_demo_lgd"
#' Synthetic post-default cash flows of `scr_demo_lgd`
#'
#' Long table of the cash flows of every default event of [scr_demo_lgd]:
#' recoveries spread over up to four years for unsecured facilities, a
#' collateral sale between one and three years in for mortgages, a
#' repossession sale within nine months for cars, direct costs at the start
#' of the workout and at the sale, and a few drawings after default. Cures
#' carry only the payments that brought the facility back to performing.
#'
#' @format A `data.frame` with 5,737 rows and 4 columns:
#' \describe{
#' \item{`default_id`}{Default event identifier, matching [scr_demo_lgd].}
#' \item{`date`}{Date of the cash flow.}
#' \item{`amount`}{Amount, always positive.}
#' \item{`type`}{`"recovery"`, `"direct_cost"` or `"drawing"`.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_lgd.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' head(scr_demo_lgd_cashflows)
#' table(scr_demo_lgd_cashflows$type)
"scr_demo_lgd_cashflows"
#' Synthetic monthly reference rate series
#'
#' A smooth annualized reference rate by month from 2019-01 to 2026-06,
#' falling to two percent in 2020-2021 and rising above thirteen percent
#' in 2022-2023, used by [scr_workout()] as the rate at the default date.
#'
#' @format A `data.frame` with 90 rows and 2 columns:
#' \describe{
#' \item{`date`}{First day of the month.}
#' \item{`rate`}{Annual reference rate as a decimal.}
#' }
#' @source Synthetic. Generated by `data-raw/scr_demo_lgd.R`, seed `20260904`, in the package source
#' repository <https://github.com/evandeilton/scorecraft>.
#' @family data
#' @examples
#' range(scr_demo_rates$rate)
"scr_demo_rates"
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.