How to rerun the analysis

Every number on this site comes from synthetic inputs in params.yaml and data/, and from results computed by the scripts in R/. Nothing is downloaded, and every random draw is seeded, so running the same commit with the same package versions gives the same results. The pages never compute the heavy results themselves: they read cached results from data/results/. The decision-map slider recomputes the closed-form walk-away point in the browser, using a JavaScript file that the pipeline checks against R. This page explains how to rebuild the results, lists the inputs with their checksums, shows the tests, and records the software environment.

Quick start

  1. Clone the GitHub repository and open the project folder in RStudio or Positron.
  2. Restore the packages with renv::restore() (see Software environment). You need R 4.3 or later and Quarto 1.5 or later.
  3. From a terminal in the project root, rebuild the results, run the tests and render the site:
Rscript R/run_all.R
Rscript -e 'testthat::test_dir("tests/testthat")'
quarto render

The rendered site is written to docs/. Run R/run_all.R with Rscript from a terminal, not with source() in an R console: it ends with quit(), which would close your session. It exits with an error status if any diagnostic fails. To look at the site locally, run quarto preview, which renders it and opens it in your browser. The sliders need a web server, so they don’t work when a page is opened straight from disk; on GitHub Pages they work as is.

Pipeline

R/run_all.R sources the scripts below in order, calls each script’s main_*() function, runs the diagnostics and saves every result to data/results/. Later scripts use functions from earlier ones, so sourcing a later script on its own in a fresh session fails.

Script What it does Main outputs
R/00_params.R Reads params.yaml into constants, the base case and the three firm profiles; sets the project paths BASE, PROFILES, INPUT_SPEC, seeds
R/01_utils.R Closed-form costs and walk-away point, triangular and Beta samplers, formatters, result read/write helpers Shared functions
R/20_walkaway.R Reference cases, decision-map boundaries, the cost components of the three paths, the leak-term sensitivity and firm profiles walkaway.rds
R/30_mc_drivers.R Monte Carlo over all inputs; first-order variance shares for the walk-away point and the pay decision, on five seeds and at three demand spreads mc_drivers.rds
R/31_bargaining.R The crew’s belief grid, its best demand and the Bayesian update after a payment or refusal Shared functions
R/32_reputation.R 10-year repeated game for every attack rate on the slider, the targeting-response sweep and the pay-once credibility test in present value reputation.rds, reputation_grid.rds
R/35_sensitivity.R One-at-a-time swings and the market-calibration run sensitivity.rds
R/80_diagnostics.R The checks shown on the Governance page, including the JavaScript–R parity check and the discounting and deviate-once checks diagnostics.rds
R/run_all.R Runs all of the above All results

assets/js/walkaway.js holds the walk-away formula used by the decision-map slider; the parity diagnostic runs this same file in R through the V8 package. Every page sources R/00_params.R, R/01_utils.R and R/90_theme.R (labels, colors and the plot and table styles) in a hidden first chunk. R/99_wordcount.R is an internal prose-length check whose output is printed to the terminal only.

Data

All inputs are synthetic and illustrative, written for this project. params.yaml holds every number: base values, ranges, seeds and simulation settings (see Parameters and seeds). data/inputs.csv holds the labels, units and sources shown in the inputs table on The Game page; it contains no numbers. data/assumptions_register.csv holds the text of the register on the Governance page. The files in data/results/ are generated by R/run_all.R and committed, so the site renders without rerunning the analysis.

The checksums below identify the exact files used in this render. A different checksum means a different file.

Display code
input_files <- c("params.yaml", "data/inputs.csv", "data/assumptions_register.csv", "assets/js/walkaway.js")
result_files <- file.path("data", "results", c(
  "walkaway.rds", "mc_drivers.rds", "reputation.rds", "reputation_grid.rds",
  "sensitivity.rds", "diagnostics.rds"
))
tibble(
  Kind = c(rep("Input", length(input_files)), rep("Cached result", length(result_files))),
  File = c(input_files, result_files)
) |>
  mutate(
    `Size (KB)` = file.size(file.path(PROJECT_ROOT, File)) / 1e3,
    MD5 = unname(tools::md5sum(file.path(PROJECT_ROOT, File)))
  ) |>
  gt() |>
  tab_header(title = md("**Files used in this render**"), subtitle = paste0("Rendered ", Sys.Date())) |>
  fmt_number(columns = `Size (KB)`, decimals = 1) |>
  gt_board() |>
  cols_align(align = "left", columns = c(Kind, File, MD5))
Table 1: Input files and cached results used in this render.
Files used in this render
Rendered 2026-11-19
Kind File Size (KB) MD5
Input params.yaml 3.1 fcb6291dfa9700b1b4faf2f5128c0c8f
Input data/inputs.csv 1.7 9466e052b0b8789a586a8885c25e3e23
Input data/assumptions_register.csv 1.6 1efb783f5710efa32a59d60e56535f16
Input assets/js/walkaway.js 0.7 04f08ceb5b7ab91163e9da4dc95b1f1b
Cached result data/results/walkaway.rds 3.0 a84d23bc5d3ef0850e841986d6991bd5
Cached result data/results/mc_drivers.rds 2.0 a8e532b8cc383510a2119959de60a4a3
Cached result data/results/reputation.rds 8.5 8c75024427ae28ae326f7de5cef1bd60
Cached result data/results/reputation_grid.rds 2.7 8df4e6613e64337ecdf626288bdeff04
Cached result data/results/sensitivity.rds 1.2 3abe40abd1019092058bb250a9c198ed
Cached result data/results/diagnostics.rds 1.0 ef01c1277568eb41cbdf5146c133f808

How to read the table. Each row is one file the site depends on: 4 hand-written inputs and 6 cached results produced by the scripts. The size is in kilobytes. The MD5 column is a checksum, a short fingerprint computed from the file’s exact contents; changing even one character gives a completely different fingerprint. The subtitle gives the date this page was rendered.

What the table tells you. Anyone rerunning the analysis can compute the same fingerprints on their copies. Matching input fingerprints mean identical starting points, and the results should then match too. If a result fingerprint differs while the inputs match, check the package versions first, since a different version of R or a package can change random draws or rounding.

Parameters and seeds

Every setting lives in params.yaml, and each model input is labeled as an assumption, with its range. Every random stream is seeded explicitly: the Monte Carlo in R/30_mc_drivers.R uses seed 20261118, and the seed-stability check reruns it with the next 4 seeds. The reputation simulation in R/32_reputation.R uses seed 7. It draws one set of random numbers and reuses them for every attack rate, firm and policy, so the slider chart moves smoothly instead of jittering. The event-level check in R/80_diagnostics.R uses seed 20261120.

Display code
fmt_dist <- \(s) {
  par <- unlist(s$par)
  switch(s$dist, tri = sprintf("Triangular(%s)", paste(par, collapse = ", ")),
         beta = sprintf("Beta(%s)", paste(par, collapse = ", ")), fixed = "Fixed",
         ratio_of_p_np = sprintf("p_np × Triangular(%s)", paste(par, collapse = ", ")))
}
tibble(
  Name = names(INPUT_SPEC),
  Base = purrr::map_dbl(names(INPUT_SPEC), \(n) BASE[[n]]),
  Distribution = purrr::map_chr(INPUT_SPEC, fmt_dist),
  Status = purrr::map_chr(INPUT_SPEC, "status")
) |>
  gt() |>
  fmt_number(columns = Base, decimals = 2, drop_trailing_zeros = TRUE) |>
  gt_board() |>
  cols_align(align = "left", columns = -Base)
Table 2: Model inputs in params.yaml.
Name Base Distribution Status
c 0.5 Triangular(0.25, 0.5, 0.9) assumption
T_r 10 Triangular(3, 10, 30) assumption; context from Sophos State of Ransomware 2025
b 0.8 Beta(8, 2) assumption
T_fail 35 Triangular(20, 35, 60) assumption
q 0.85 Beta(17, 3) assumption
T_d 6 Triangular(3, 6, 12) assumption
d_pay 3 Triangular(1, 3, 6) assumption
s 0.1 Beta(2, 18) assumption; sanctions risk per OFAC 2021 advisory
kappa 1 Fixed illustrative simplification; OFAC liability is strict
K_pay 0.5 Triangular(0.2, 0.5, 1.5) assumption
K_leak 4 Triangular(1, 4, 10) assumption
p_np 0.8 Triangular(0.6, 0.8, 0.95) assumption
p_p 0.6 p_np × Triangular(0.5, 0.75, 0.95) assumption; re-extortion data as directional support only
t_detect 2 Triangular(1, 2, 7) assumption

How to read the table. Each row is one model input from params.yaml, the single file that sets every number in the analysis. The base column is the value used for the worked example and the firm profiles. The distribution is the range drawn from in the Monte Carlo: a triangular range lists its lowest, most likely and highest values, and a Beta range lists its two shape values. The status marks each input as an assumption and names any supporting source.

What the table tells you. To test a different view, change a value in params.yaml and rerun the pipeline; no code needs editing. Simulation settings such as the number of draws, the crew’s starting belief and the attack-rate grid sit in the same file, below the inputs. The seeds fix every random draw, so two people with the same file get the same numbers.

Tests

Two layers of checks guard the results. Unit tests in tests/testthat/ check the closed-form model against the seven reference cases and the worked example from the project outline, the indifference condition, the staged-path reference values, the samplers, the crew’s opening demand and the share of incidents in which paying the base demand is cheaper. They run again each time this page is rendered, and the table below shows the results. The pipeline diagnostics (12 of 12 passing in this build) are shown on the Governance page.

Display code
tests <- testthat::test_dir(
  file.path(PROJECT_ROOT, "tests", "testthat"),
  reporter = "silent", stop_on_failure = FALSE
) |>
  as.data.frame() |>
  transmute(
    File = file, Test = test, Expectations = nb,
    Result = if_else(failed == 0 & !error & !skipped, "Pass", "FAIL")
  )
tests |>
  gt() |>
  gt_board() |>
  cols_align(align = "left", columns = c(File, Test, Result))
Table 3: Unit test results from rendering this page.
File Test Expectations Result
test-walkaway.R walk-away point matches the outline's reference cases 1 Pass
test-walkaway.R worked example costs match at D = 2.5 4 Pass
test-walkaway.R indifference holds at the walk-away point 1 Pass
test-walkaway.R slope is about $0.31M per restore day and zero-crossing is consistent 2 Pass
test-walkaway.R triangular sampler has the right mean 1 Pass
test-walkaway.R crew's opening demand is about $2.5M and beliefs stay normalized 4 Pass
test-walkaway.R staged path matches reference values and is never worse with instant detection 7 Pass
test-walkaway.R paying the base demand is cheaper in most simulated incidents 2 Pass

How to read the table. Each row is one unit test. The expectations column counts the individual comparisons inside it, such as one computed walk-away point against its reference value. “Pass” means every comparison in the test held. Here 8 of 8 tests passed, covering 22 comparisons in total. Each test’s name says what it checks, and the file column shows where to find it in tests/testthat/.

What the table tells you. The formulas behind every page reproduce the reference values to within one hundredth of a million dollars, and the walk-away point is exactly where paying and refusing cost the same. A failure here would mean the code no longer matches the documented model, and the site’s numbers should not be used until it is fixed.

Caching

  • Results cache (data/results/*.rds). Written by R/run_all.R and read by every page. It is not invalidated automatically: after changing params.yaml or any script, rerun Rscript R/run_all.R. The files are committed to git so the site renders from a fresh clone.
  • 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 R/ scripts or new results do not count as a change. After rerunning the pipeline, render each page explicitly (for example quarto render governance.qmd) or delete _freeze/ first. _freeze/ is not committed.

Licenses

The code on this site is released under the MIT License. The project redistributes no third-party data: every input is synthetic and written for this project. The publications cited on the Governance page are quoted briefly and linked; they remain under their publishers’ terms.

Software environment

The site was built with R and Quarto. The pages load dplyr, ggplot2 and gt, and the scripts also call purrr, tibble, tidyr, readr, scales, yaml, V8, testthat and sessioninfo. The two sliders use Observable JS, which is built into Quarto. 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  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/New_York
#>  date     2026-11-19
#>  pandoc   3.10 @ /Applications/Positron.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>  quarto   1.8.26 @ /Applications/quarto/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package      * version date (UTC) lib source
#>  P base64enc      0.1-6   2026-02-02 [?] CRAN (R 4.5.2)
#>  P brio           1.1.5   2024-04-24 [?] CRAN (R 4.5.0)
#>  P cli            3.6.6   2026-04-09 [?] CRAN (R 4.5.2)
#>  P commonmark     2.0.0   2025-07-07 [?] CRAN (R 4.5.0)
#>  P desc           1.4.3   2023-12-10 [?] CRAN (R 4.5.0)
#>  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 fs             2.1.0   2026-04-18 [?] CRAN (R 4.5.2)
#>  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 gt           * 1.3.0   2026-01-22 [?] 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 htmlwidgets    1.6.4   2023-12-06 [?] CRAN (R 4.5.0)
#>  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 litedown       0.8     2025-11-02 [?] CRAN (R 4.5.0)
#>  P magrittr       2.0.5   2026-04-04 [?] CRAN (R 4.5.2)
#>  P markdown       2.0     2025-03-23 [?] CRAN (R 4.5.0)
#>  P otel           0.2.0   2025-08-29 [?] CRAN (R 4.5.0)
#>  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 pkgload        1.5.3   2026-06-15 [?] CRAN (R 4.5.2)
#>  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] CRAN (R 4.5.0)
#>  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 rprojroot      2.1.1   2025-08-26 [?] CRAN (R 4.5.0)
#>  P S7             0.2.2   2026-04-22 [?] CRAN (R 4.5.2)
#>  P sass           0.4.10  2025-04-11 [?] CRAN (R 4.5.0)
#>  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 testthat     * 3.3.2   2026-01-11 [?] 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 waldo          0.6.2   2025-07-11 [?] CRAN (R 4.5.0)
#>  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 xml2           1.4.1   2025-10-27 [?] CRAN (R 4.5.0)
#>  P yaml           2.3.10  2024-07-26 [?] CRAN (R 4.5.0)
#> 
#>  [1] /Users/patricklefler/Claude/r/2026-11-19_rQuarto_ransomware-pay-or-restore-game-theory/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.
#> 
#> ──────────────────────────────────────────────────────────────────────────────