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.R

The 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

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

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)
Table 1: Main analysis settings and their basis. The full register, with sensitivity ranges, is in params.yaml.
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/.

# Single register of every analysis parameter, read by the R scripts (R/params.R).
# basis: "assumption" = a choice made by the analyst; "convention" = a standard
# default; "planted" = a deliberate feature of the synthetic design.
# range: values over which a sensitivity check would be reasonable (not all were run).
# The simulator's own parameters live in R/simulate.R (validated; not edited here);
# they are listed under `simulator` for reference only and are NOT read from this file.

seed:
  value: 34
  basis: "assumption: selected during development from seeds 1-40 (26 of 40 pass the generator's checks)"
  range: "1-40 (seed sweep on page 4)"

windows:
  classifier_train: {value: [1, 30],  basis: "assumption: vendor's training months",  range: "fixed by the generator's train/test split"}
  calibration_fit:  {value: [31, 36], basis: "assumption: six months, out of sample for the classifier", range: "3-12 months"}
  overlay_eval:     {value: [37, 48], basis: "assumption: all months remaining after the calibration window", range: "set by calibration_fit"}
  forecast_eval:    {value: [31, 48], basis: "assumption: all months after classifier training", range: "fixed"}

vendorscore:
  sharpen:           {value: 1.5,  basis: "planted: overconfidence, logit scaled around the training base rate", range: "1.0-2.0"}
  xgb_eta:           {value: 0.05, basis: "assumption: the vendor's hidden choice",  range: "0.02-0.2"}
  xgb_max_depth:     {value: 3,    basis: "assumption: the vendor's hidden choice",  range: "2-6"}
  xgb_min_child_weight: {value: 5, basis: "assumption: the vendor's hidden choice",  range: "1-20"}
  xgb_subsample:     {value: 0.8,  basis: "assumption: the vendor's hidden choice",  range: "0.5-1"}
  xgb_colsample:     {value: 0.8,  basis: "assumption: the vendor's hidden choice",  range: "0.5-1"}
  xgb_nrounds:       {value: 150,  basis: "assumption: the vendor's hidden choice",  range: "50-500"}

calibration:
  ece_bins:        {value: 10,   basis: "convention", range: "5-20"}
  bootstrap_draws: {value: 1000, basis: "convention: vendor-history resamples", range: "500-5000"}
  band_low_upper:    {value: 0.01, basis: "assumption: illustrative Low/Medium boundary (monthly incident probability)", range: "0.005-0.02"}
  band_medium_upper: {value: 0.03, basis: "assumption: illustrative Medium/High boundary", range: "0.02-0.05"}

forecast:
  benchmark_months: {value: 12, basis: "assumption: rolling-average length", range: "6-24"}
  shift_month:      {value: 36, basis: "planted: last month before patch latency drifts (generator)", range: "fixed"}

fragility:
  alpha:             {value: 0.05, basis: "convention: pre-registered kill threshold", range: "0.01-0.10"}
  trim_percentile:   {value: 0.99, basis: "assumption: drop patch_latency above this panel percentile", range: "0.95-0.995"}
  deletion_budget:   {value: 80,   basis: "assumption: maximum greedy deletions", range: "40-200"}
  deletion_shortlist: {value: 15,  basis: "assumption: candidates refitted per step", range: "5-50"}
  falsifyr_intensity: {value: "normal", basis: "assumption", range: "fast / normal / deep"}

simulator:   # reference only; validated in R/simulate.R (34 tests); not read from this file
  n_vendors: 300
  n_months: 48
  true_no_soc2_odds_ratio: 1.25
  vendor_size_log_odds: -0.45
  vendor_random_effect_sd: 0.40
  patch_latency_drift_per_month_after_shift: 0.045
  basis: "planted: confounding (size), regime shift (patch latency), rare events (~1.5%)"

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, so quarto render on a fresh clone works without rerunning the analysis. Nothing invalidates them automatically: after editing a script or params.yaml, run Rscript run_all.R to rebuild them.
  • Quarto freeze (_freeze/). _quarto.yml sets freeze: auto, so a full quarto render re-executes a page only when that page’s .qmd file changes. Edits to the R/ scripts or to the artifacts in data/ do not count as a change. run_all.R deletes _freeze/ before rendering for this reason. After changing anything else, render each page explicitly (for example quarto 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 (probcal 0.2.0, forecastdom 0.1.0, falsifyr 1.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

  1. Synthetic data. Confounding, regime shift and overconfidence are planted. Real use needs NorthPoint’s vendor-month panel, incident definition and dated SOC 2 reports.
  2. Few events. 75 evaluation incidents and 18 forecast months limit power; more history could change pages 2 and 3.
  3. Thin overlay window. Six months and 28 incidents is little. A real overlay needs a refit schedule and tolerances set in advance.
  4. Information timing. Start-of-month availability of patch latency and financial health is assumed; real feeds need timestamps.
  5. One dataset. Seed 34 was chosen in development; the seed sweep on page 4 checks repeatability only.
  6. 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.

#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.2 (2025-10-31)
#>  os       macOS Tahoe 26.6.2
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       America/New_York
#>  date     2026-11-20
#>  pandoc   3.6.3 @ /Applications/quarto/bin/tools/ (via rmarkdown)
#>  quarto   1.8.26 @ /usr/local/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package      * version date (UTC) lib source
#>  P cli            3.6.6   2026-04-09 [?] CRAN (R 4.5.2)
#>  P digest         0.6.39  2025-11-19 [?] CRAN (R 4.5.2)
#>  P dplyr          1.2.1   2026-04-03 [?] CRAN (R 4.5.2)
#>  P evaluate       1.0.5   2025-08-27 [?] CRAN (R 4.5.0)
#>  P farver         2.1.2   2024-05-13 [?] CRAN (R 4.5.0)
#>  P fastmap        1.2.0   2024-05-15 [?] CRAN (R 4.5.0)
#>  P generics       0.1.4   2025-05-09 [?] CRAN (R 4.5.0)
#>  P ggplot2      * 4.0.3   2026-04-22 [?] CRAN (R 4.5.2)
#>  P glue           1.8.1   2026-04-17 [?] CRAN (R 4.5.2)
#>  P gtable         0.3.6   2024-10-25 [?] CRAN (R 4.5.0)
#>  P htmltools      0.5.9   2025-12-04 [?] CRAN (R 4.5.2)
#>  P jsonlite       2.0.0   2025-03-27 [?] CRAN (R 4.5.0)
#>  P knitr          1.50    2025-03-16 [?] CRAN (R 4.5.0)
#>  P lifecycle      1.0.5   2026-01-08 [?] CRAN (R 4.5.2)
#>  P magrittr       2.0.5   2026-04-04 [?] CRAN (R 4.5.2)
#>  P pillar         1.11.1  2025-09-17 [?] CRAN (R 4.5.0)
#>  P pkgconfig      2.0.3   2019-09-22 [?] CRAN (R 4.5.0)
#>  P purrr          1.2.2   2026-04-10 [?] CRAN (R 4.5.2)
#>  P R6             2.6.1   2025-02-15 [?] CRAN (R 4.5.0)
#>  P RColorBrewer   1.1-3   2022-04-03 [?] CRAN (R 4.5.0)
#>    renv           1.1.5   2025-07-24 [1] RSPM (R 4.5.2)
#>  P rlang          1.3.0   2026-07-05 [?] CRAN (R 4.5.2)
#>  P rmarkdown      2.30    2025-09-28 [?] CRAN (R 4.5.0)
#>  P S7             0.2.2   2026-04-22 [?] CRAN (R 4.5.2)
#>  P scales         1.4.0   2025-04-24 [?] CRAN (R 4.5.0)
#>  P sessioninfo    1.2.3   2025-02-05 [?] CRAN (R 4.5.2)
#>  P tibble         3.3.1   2026-01-11 [?] CRAN (R 4.5.2)
#>  P tidyselect     1.2.1   2024-03-11 [?] CRAN (R 4.5.0)
#>  P vctrs          0.7.3   2026-04-11 [?] CRAN (R 4.5.2)
#>  P withr          3.0.3   2026-06-19 [?] CRAN (R 4.5.2)
#>  P xfun           0.54    2025-10-30 [?] CRAN (R 4.5.0)
#>  P yaml           2.3.10  2024-07-26 [?] CRAN (R 4.5.0)
#> 
#>  [1] /Users/patricklefler/Claude/r/2026-10-22_rQuarto_three-questions-for-any-risk-model/renv/library/macos/R-4.5/aarch64-apple-darwin20
#>  [2] /Users/patricklefler/Library/Caches/org.R-project.R/R/renv/sandbox/macos/R-4.5/aarch64-apple-darwin20/4cd76b74
#> 
#>  * ── Packages attached to the search path.
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────