| Item | Value |
|---|---|
| R | R version 4.5.2 (2025-10-31) |
| Platform | aarch64-apple-darwin20 |
| Quarto | 1.8.26 |
| Packages | In sync with renv.lock |
| probcal | 0.2.0 |
| forecastdom | 0.1.0 |
| falsifyr | 1.0.0 |
| xgboost | 1.7.11.1 |
| sandwich | 3.1.1 |
Reproducibility
How to rerun the analysis and where the results can mislead
Every number on this site is computed from synthetic data generated by R/simulate.R from seed 34, with every analysis choice set in params.yaml. Nothing is downloaded during a render, so rendering the same commit with the same package versions gives the same results. This page explains how to rebuild the site, records the environment it was built in, and states where the results can mislead.
Quick start
The code and data are in the GitHub repository patrick-lefler/three-questions-for-any-risk-model. To rebuild everything from a clean copy:
git clone https://github.com/patrick-lefler/three-questions-for-any-risk-model
cd three-questions-for-any-risk-model
Rscript -e 'renv::restore()' # once: install the package versions pinned in renv.lock
Rscript run_all.RThe rendered site is written to docs/. run_all.R runs the scripts in the Pipeline table in order, stops at the first failure, clears the Quarto freeze cache, calls quarto render, then runs the word count and the page tests. To re-render the pages from the artifacts already in data/ without rerunning the analysis, run quarto render instead.
Environment
How to read the table
Each row is one piece of software this page was built with and its version. The “Packages” row says whether the installed R packages match the versions pinned in renv.lock.
What the table tells you
If your versions match these and the packages are in sync, rebuilding the project should give the same numbers. If they differ, small differences in the results may come from the software rather than the analysis.
Pipeline
| Script | What it does | Main outputs |
|---|---|---|
R/simulate.R |
Generates the synthetic NorthPoint vendor-incident panel with three planted features (about 1.5% incident rate, confounding by vendor size, patch-latency drift after month 36) and checks them | vendor_panel.csv/.parquet, vendors.csv, truth.rds |
R/fit_models.R |
Trains the VendorScore black box (xgboost) and the bank’s own incident-association model; keeps scores only | vendorscore.csv/.parquet, models.rds |
R/check_packages.R |
Gate 0: checks probcal, forecastdom and falsifyr against the panel |
package_check.txt |
R/analysis_calibration.R |
Page 2: calibration of the raw scores and the recalibration overlay | calibration.rds |
R/analysis_forecast.R |
Page 3: raw VendorScore against a 12-month rolling average | forecast.rds |
R/analysis_fragility.R |
Page 4: specification curve, deletion search and 40-seed sweep (about 2 minutes) | fragility.rds, specification_manifest.csv, seed_sweep.csv, deletion_path.csv, falsifyr_attacks.csv |
R/build_manifest.R |
Writes the audit artifacts | analysis_manifest.csv, checksums.csv, session_info.txt |
tests/run_tests.R |
Runs the simulation and artifact test suites | test_results.csv |
All outputs are written to data/. The scripts share R/params.R (reads params.yaml), R/windows.R (the analysis windows) and R/baseline.R (the bank’s baseline model). Each script reads the files written by the ones before it, so run them in this order. The pages source only R/common.R (palette, plot theme, formatters) and read the artifacts in data/; they never refit a model.
Data
All data are synthetic. R/simulate.R generates a panel of 300 vendors over 48 months from seed 34 (set through the SIM_SEED environment variable, default 34). The simulator’s own parameters live in that script and are listed under simulator in params.yaml for reference only. Every other file in data/ is written by the pipeline, so the whole folder can be regenerated from code in the repository. R/build_manifest.R records the checksums of the last pipeline run in data/checksums.csv.
The checksums below identify the exact files used in this render. A different checksum means a different file. The generator script and params.yaml are included because any edit to them changes the data.
| File | Size (KB) | MD5 |
|---|---|---|
R/simulate.R |
7.6 | d23c42f71a3b2f4011f64274e1a0c9db |
params.yaml |
3.5 | 868d22feea4d02bb366e400025184ff0 |
data/vendor_panel.csv |
1,409.1 | 3f4a18c5b449013fa6f8ea6af4933851 |
data/vendor_panel.parquet |
201.1 | bf08cf62131289990ff35964b97c6002 |
data/vendors.csv |
13.1 | a19579f3146cb64d7f2a35f0a6eeb2a2 |
data/truth.rds |
0.3 | 725b9727a6efe18ead573e834610fd8b |
data/vendorscore.csv |
422.3 | aca9f74bebaf8caedee52d62eb38a24a |
data/vendorscore.parquet |
122.1 | be697b3a4edfea85f4cde3e80430f76b |
data/models.rds |
2,339.9 | 690050059fb75d19ea67cd12e1371634 |
data/package_check.txt |
0.8 | 8b12d0e2d1e6e2dee93e78b3eebab046 |
data/calibration.rds |
7.8 | fa6a8fe51a34871967f1fb39c6fc2312 |
data/forecast.rds |
1.4 | 2cb768611a78e66a70b5f9e99fa57049 |
data/fragility.rds |
2,588.3 | 5ee269c22f72703b87b0ffe8dc238756 |
data/specification_manifest.csv |
5.7 | c49471ceb8b6b770eb07f1094c2d64c7 |
data/seed_sweep.csv |
6.2 | cbc8d6a2c4dad35a64e51e88a56543b9 |
data/deletion_path.csv |
1.7 | 984976191850e3f3448fdd5ffa038b49 |
data/falsifyr_attacks.csv |
51.2 | 2dcf754d8c439a684824ac54fc855b6d |
data/analysis_manifest.csv |
3.0 | 8fd18ff28050a83da3b70ffd51a2d71d |
How to read the table
Each row is one data file. The MD5 column is a checksum: a short fingerprint computed from the file’s exact contents, so changing even one character gives a completely different fingerprint.
What the table tells you
Anyone rerunning the analysis can compute the same checksums on their copies. If every fingerprint matches, they are working from identical inputs; a mismatch means a file differs, and any difference in results should be traced to that file first.
Parameters and seeds
Every analysis choice lives in params.yaml, which the scripts read. Each value is labelled as an assumption, a convention or a feature planted in the synthetic data, with a range over which a sensitivity check would be reasonable. The table shows the main ones.
Show the code
w <- function(n) paste(range(pp("windows", n)), collapse = "–")
tab <- data.frame(
Setting = c("Random seed", "Windows: classifier / overlay fit / overlay test",
"Score sharpening", "Risk-band boundaries", "Resampling draws",
"Trimming rule", "Deletion budget", "Significance level"),
Value = c(pp("seed"), sprintf("%s / %s / %s", w("classifier_train"), w("calibration_fit"), w("overlay_eval")),
pp("vendorscore", "sharpen"), sprintf("%s, %s", pct(pp("calibration", "band_low_upper"), 0), pct(pp("calibration", "band_medium_upper"), 0)),
format(pp("calibration", "bootstrap_draws"), big.mark = ","), sprintf("top %s of patch latency", pct(1 - pp("fragility", "trim_percentile"), 0)),
pp("fragility", "deletion_budget"), pct(pp("fragility", "alpha"), 0)),
Basis = c("assumption", "assumption", "planted", "assumption", "convention", "assumption", "assumption", "convention"))
knitr::kable(tab)| Setting | Value | Basis |
|---|---|---|
| Random seed | 34 | assumption |
| Windows: classifier / overlay fit / overlay test | 1–30 / 31–36 / 37–48 | assumption |
| Score sharpening | 1.5 | planted |
| Risk-band boundaries | 1%, 3% | assumption |
| Resampling draws | 1,000 | convention |
| Trimming rule | top 1% of patch latency | assumption |
| Deletion budget | 80 | assumption |
| Significance level | 5% | convention |
How to read the table
Each row is a setting that shapes the results. The last column says whether it is an analyst’s assumption, a standard convention, or a feature planted in the synthetic data.
What the table tells you
Most settings are assumptions. Changing the windows, risk bands or deletion budget would change the reported numbers, so each is recorded in one place.
Every random stream is seeded explicitly. R/simulate.R calls set.seed() with the SIM_SEED value (default 34); R/fit_models.R, R/analysis_calibration.R and R/analysis_fragility.R each call set.seed(par_get("seed")) at the top. The xgboost model is trained with nthread = 1, and no step runs in parallel, so results do not depend on the number of cores. The seed sweep on page 4 reruns the generator with seeds 1 to 40 in temporary folders and never touches data/.
Tests
tests/run_tests.R runs two test suites before the site is rendered and records the results in data/test_results.csv:
| Suite | Script | Checks passed | Status |
|---|---|---|---|
| simulation | tests/test_simulate.R |
34 | passed |
| artifacts | tests/test_fit_models.R |
72 | passed |
How to read the table
Each row is one test suite from the last pipeline run. “Simulation” checks that the generator plants the intended features and that the same seed gives the same panel; “artifacts” checks the fitted models, windows, baseline, benchmark and resampling.
What the table tells you
All 106 checks passed on the run that produced these results. If a rebuild reports fewer passes or a failure, the artifacts in data/ differ from those behind this site.
After rendering, tests/test_pages.R checks the rendered pages (no errors, word budget, figure and table limits, reader notes) and tests/check_links.R checks every internal and external link. These page checks are not recorded in the table.
Caching
- Analysis artifacts (
data/*.rds,data/*.csv). The pipeline scripts write them; the pages only read them. They are committed to git, soquarto renderon a fresh clone works without rerunning the analysis. Nothing invalidates them automatically: after editing a script orparams.yaml, runRscript run_all.Rto rebuild them. - Quarto freeze (
_freeze/)._quarto.ymlsetsfreeze: auto, so a fullquarto renderre-executes a page only when that page’s.qmdfile changes. Edits to theR/scripts or to the artifacts indata/do not count as a change.run_all.Rdeletes_freeze/before rendering for this reason. After changing anything else, render each page explicitly (for examplequarto render index.qmd), because Quarto always executes a page that is rendered on its own._freeze/is not in git.
Known limitations
Limits of reproducibility
- Bit-for-bit equality is expected only on the same platform and package versions. Floating-point and BLAS differences across machines can change low-order digits.
- The three testing packages (
probcal0.2.0,forecastdom0.1.0,falsifyr1.0.0) are young CRAN releases whose defaults may change between versions;renv::restore()installs the pinned versions from the CRAN archive. The VendorScore scores depend on the xgboost version. - Quarto versions affect rendering, not the numbers.
Model limitations
- Synthetic data. Confounding, regime shift and overconfidence are planted. Real use needs NorthPoint’s vendor-month panel, incident definition and dated SOC 2 reports.
- Few events. 75 evaluation incidents and 18 forecast months limit power; more history could change pages 2 and 3.
- Thin overlay window. Six months and 28 incidents is little. A real overlay needs a refit schedule and tolerances set in advance.
- Information timing. Start-of-month availability of patch latency and financial health is assumed; real feeds need timestamps.
- One dataset. Seed 34 was chosen in development; the seed sweep on page 4 checks repeatability only.
- Partial validation. Scores and outcomes only; the vendor’s internals stay unseen.
The results show how the three questions can be put to a black-box score using only its outputs and the bank’s own outcomes. They are not evidence about any real vendor model. Treat the numbers as an illustration of the method, and rerun the analysis on real data before drawing conclusions about a specific model.
Licenses
The code on this site is released under the MIT License. The data are generated by the project’s own code and carry the same license. Third-party software keeps its own terms:
| Source | Terms |
|---|---|
probcal, forecastdom, falsifyr |
MIT (probcal, forecastdom, falsifyr on CRAN) |
xgboost |
Apache License 2.0 |
arrow |
Apache License 2.0 or later |
sandwich (vendor-clustered standard errors) |
GPL-2 or GPL-3 |
Session information
The site was built with R and Quarto. The pages load ggplot2 and also call knitr, scales, yaml, dplyr, purrr, tibble, renv and sessioninfo. The analysis scripts also use probcal, forecastdom, falsifyr, sandwich, xgboost and arrow, and the tests use testthat, xml2 and chromote. Package versions are pinned in renv.lock; run renv::restore() to install them.