Cost-benefit analysis primitives from the HM Treasury Green Book, in R.
The Green Book is HM Treasury’s guidance on how to appraise and evaluate proposals involving UK public spending. It sets the rules every central-government department, devolved administration, and arm’s-length body follows when deciding whether a policy, programme, or capital project is worth funding. The latest edition was published in 2026.
The guidance covers six core areas:
The Green Book is supplemented by topic-specific guidance from HMT, DESNZ, DfT, and DHSC.
A practitioner appraising a public-spending option typically:
Today this is mostly done in spreadsheets, with discount factors and
parameter tables hand-typed from PDFs. greenbook puts the
same primitives in R so an appraisal becomes code that can be tested,
reviewed, and reproduced.
No existing R or Python package implements the Green Book. UK appraisal practitioners hand-roll the same discount factors and parameter lookups every time. The arithmetic is simple but the parameters change: STPR is kinked across six bands, optimism bias has a six-category schedule, DESNZ publishes a carbon path to 2100, METB shifted from 30 to 20 percent in 2018.
greenbook solves three problems:
gb_appraisal
carries vintage metadata for the parameter tables it used.
gb_data_versions() shows source and last-updated date for
every bundled table.The package is pure computation: no network calls, no API keys.
Bundled parameter tables in inst/extdata/ are refreshed via
data-raw/ scripts.
# install.packages("greenbook") # not yet on CRAN
# Development version:
devtools::install_github("charlescoverdale/greenbook")library(greenbook)
# 10-year cashflow: capex in years 0-2, benefits in years 3-9
costs <- c(100, 50, 50, 0, 0, 0, 0, 0, 0, 0)
benefits <- c(0, 0, 0, 30, 30, 30, 30, 30, 30, 30)
# One-call full appraisal with optimism bias and METB
app <- gb_appraise(
costs, benefits,
ob = "non_standard_buildings", ob_mitigation = 0.5,
metb = TRUE,
base_year = 2024
)
summary(app)
# Equivalent annual net benefit
gb_eanc(app)
# Distributional weighting
gb_dist_weighted_npv(
cashflow = rep(30, 5),
recipient_income = rep(15000, 5),
income_data = seq(10000, 100000, length.out = 10)
)
# Carbon emissions
gb_carbon_npv(rep(100, 7), 2024:2030, base_year = 2024)
# Wellbeing
gb_wellby(1, persons = 100, years = 5, base_year = 2024)
# Inspect bundled vintages
gb_data_versions()| Family | Functions |
|---|---|
| Discounting | gb_stpr(), gb_discount_factor(),
gb_discount(), gb_npv(),
gb_eanc() |
| Real / nominal | gb_deflator(), gb_real(),
gb_rebase() |
| Optimism bias | gb_optimism_bias(), gb_apply_ob(),
gb_categories() |
| Distributional | gb_dist_weight(),
gb_dist_weighted_npv() |
| Valuation | gb_wellby(), gb_vpf(),
gb_qaly() |
| Carbon | gb_carbon_value(), gb_carbon_npv() |
| Adjustments | gb_metb() |
| Appraisal | gb_appraise(), gb_compare(),
gb_progression(), gb_place_based(),
gb_economic_case(), gb_validate() |
| Risk | gb_risk_register() |
| Sensitivity | gb_sensitivity_ob() |
| Reporting | gb_headline(), gb_cost_per_unit(),
gb_to_latex(), gb_to_excel(),
gb_to_word() |
| Lookups | gb_schedule_table(),
gb_data_versions() |
Every parameter table is sourced from a published HMT, DfT, or DESNZ
workbook. gb_data_versions() returns the full
provenance.
| Table | Source |
|---|---|
| STPR schedule | HMT Green Book 2022 Annex A6 |
| GDP deflator (1990-2024, 2024 = 100) | HMT GDP deflators, December 2025 Quarterly National Accounts release |
| Optimism bias upper bounds | HMT Supplementary Green Book Guidance: Optimism Bias (Mott MacDonald 2002) |
| METB | HMT Green Book 2022 |
| WELLBY (10k / 13k / 16k, 2019 prices) | HMT Wellbeing Guidance for Appraisal, July 2021 |
| QALY (DHSC 70k / NICE 20k, 30k) | DHSC Supplementary Green Book Guidance + NICE HTA |
| VPF (anchored 2023 = GBP 2,474,341) | DfT TAG data book v2.03FC, December 2025, Table A4.1.1 (WTP element) |
| DESNZ carbon (2020-2050, 2022 prices) | DESNZ Valuation of Energy Use and GHG Emissions for Appraisal, November 2023, Table 3 |
data-raw/ contains the refresh scripts: each downloads
the published workbook, parses the relevant sheet, and rewrites the
bundled CSV.
If you use greenbook in published work, please cite
via:
citation("greenbook")The package citation and the underlying HM Treasury Green Book are both returned.
Report bugs or request features at GitHub Issues.
cost-benefit-analysis, appraisal, hm-treasury, green-book, public-policy, economics, discounting, npv, social-time-preference-rate, optimism-bias, distributional-weighting, wellby, value-of-statistical-life, carbon-valuation, desnz