Skip to content

Add an opt-in, columns-only UK firm VAT composition from the Supply and Use Tables - #1786

Draft
vahid-ahmadi wants to merge 24 commits into
mainfrom
uk-firm-vat-composition
Draft

vahid-ahmadi wants to merge 24 commits into
mainfrom
uk-firm-vat-composition

Conversation

@vahid-ahmadi

Copy link
Copy Markdown
Contributor

Summary

This is the sixth PR in the UK firm stack. It sits above 4d (#1785, uk-firm-consumption-turnover) and carries the commits of every PR below it. Review only the last five commits. Its own commits add three opt-in pieces, and none changes the default build.

  1. VAT composition, columns only (firm_vat_composition.py, --vat-composition-dir, which needs --consumption-dir).
    • What it adds: Microcosm-only firm_sut_* columns for each SIC section:
      • the standard-, reduced-, zero-rated and exempt shares of turnover;
      • the export share;
      • the VAT rate on purchases;
      • the ratio of intermediate consumption to sales.
    • Where the shares come from: the ONS Supply and Use Tables 2024 (Blue Book 2026), read product by product through the VAT Act 1994: Schedules 7A, 8 and 9, and s.30(6).
    • Section G: ABS 2024 turnover is the gross-sales base for trade.
    • No policyengine-uk input changes, so VAT is still scored on all-standard-rated supplies.
    • Receipt: the section shares, and eight relief checks against HMRC tax relief statistics (January 2026). The checks are never targets.
  2. Paybill anchors, report only (firm_paybill_anchor.py, --paybill-anchor-dir).
    • Anchors: ONS D.11 wages and salaries (DTWL, 2024), and PAYE RTI aggregate pay and payrolled employees (2024-25).
    • Receipt: the build's paybill and employees divided by each anchor.
    • The binding guard (ASHE jobs × mean pay, 0.85–1.25) is unchanged.
  3. Capex fixture and design note (docs/uk-firm-capex-design.md).
    • Contents: ONS business investment by asset (2024) and ABS capex by section (2024).
    • Not read by any build: taxable profit is drawn after allowances, so feeding capex to policyengine-uk would deduct allowances twice.

What was tried and not adopted: the calibration seam

UKFirmVATCompositionRules and rescale_uk_firm_input_costs let calibration see the composition: VAT on zero-, reduced-rated and exempt supplies, the section input VAT rate, and input costs rescaled to the SUT ratio. They stay in the module as experimental code. No flag reaches them, because they failed review.

Full 2024-25 builds (f644ab023 tree, reference opt-in flags, pe-uk 0d1c25010):

Reference (R1) Seam (R2), seed 42 Seed 2 Seed 3
VAT liability band accuracy (bar 0.999) 0.9992 0.998973 0.997182 0.998228
employment / hmrc_bands / ons_population 0.9995 / 1.0000 / 0.9998 0.9993 / 1.0000 / 0.9995 0.9991 / 0.9997 / 1.0000 0.9991 / 0.9999 / 0.9991
VAT by section, sum of absolute errors vs HMRC (held out) £79.8bn £168.0bn £165.6bn —
Private turnover vs BPE £5.52tn 0.50 0.57 0.57 0.57

Why the seam fails. Applied to the reference weights without a re-solve, the composition cuts modelled VAT from £182.6bn to £110.6bn. The frame carries about half of BPE's private turnover, so realistic net rates cannot reach HMRC's liability totals. The solver closes the gap by moving weight into sections with a high net rate: I at 3.6× HMRC, F at 2.3× and G at 0.19×.

Sector calibration doesn't help. Turning on the existing calibrate_vat_liability_sector on top of the seam (thinned, seed 1) fixes VAT by section (£40.5bn) but breaks the band fit (0.9784).

Where these numbers come from. They are local runs on the pre-split tree (f644ab023) with the first version of the shares. Nothing in this PR reproduces them, because the seam has no flag.

The shipped shares changed after that review, at the code review's direction:

  • Consumer-service exports (I55, I56, P85, Q86, R90–R93, S96) are no longer treated as zero-rated: they are mostly non-residents' spending in the UK.
  • Section G is weighted by ABS division turnover, and its goods resold are priced at their business purchase rate.

The changes are not tuned to HMRC VAT by sector. Applied to the reference weights with no re-solve:

  • I, P, R and S move toward HMRC's figures.
  • G moves away (£32.5bn to £22.1bn, against £56.7bn).
  • The summed section error grows from £108.0bn to £115.8bn.

Relief checks (model base ÷ HMRC relief cost ÷ rate, 2024-25)

Relief Ratio
Food 1.044
Domestic fuel and power 0.999
New dwellings 0.892
Children's clothing 0.866
Water and sewerage 0.846
Domestic passenger transport (rail, bus and coach) 0.720
Printed matter 1.563
Prescription drugs 0 (not modelled)

Assumptions (all labelled in the module and the treatment table)

  • Section-uniform shares: every firm in a section gets the section mix.
  • SUT demand basis: demand is at purchasers' prices, including imports.
  • Mixed products: the judgement shares carry assumed.
  • New dwellings: 0.6 of dwellings GFCF is new build.
  • Public administration (O84): treated as exempt; s.33 and s.41 refunds are not modelled.
  • Prescription drugs: zero-rating at dispensing is not modelled.
  • Capital purchases: left out of the input VAT rate.

Validation

  • Flags off is bit-identical:
    • Thinned builds, seeds 1–3, and a full build of this tree with flags off match PR 2 (b11c37e58) on every shared column.
    • Every extra column comes from PR 3's attributes, including firm_is_charity.
  • The columns-only full build matches the same build without --vat-composition-dir on every shared column, weights included.
  • Tests: the focused firm tests and test_uk_receipt_counts.py pass; ruff passes; ci_test_plan verify is ok.
  • Extractor checks: each extractor's --check matches the committed CSVs, against downloads whose sha256 is pinned.

Reviews

  • Method review (gate B1): passed with fixes.
  • Numbers review (gate B2): narrowed this PR to columns only; the seam failed.
  • Code review: push after fixes; the fixes are applied.
  • Re-review of the fixes: the designated reviewer model was unavailable. A substitute fresh-context review found no must-fixes, and its should-fixes are applied.

Sources (pinned in provenance.json, with URL, edition and sha256)

  • ONS Supply and Use Tables 1997–2024 (BB26, October 2026), supublicationtablesbb26.xlsx, sha256 716c9e02…
  • ONS Annual Business Survey 2024 results (26 May 2026), abssectionsas.xlsx, sha256 9e548c5c…
  • VAT Act 1994, Schedules 7A, 8 and 9, legislation.gov.uk XML, provisions as at 1 October 2026
  • HMRC tax relief statistics (January 2026), tax_relief_statistics_january_2026.ods, sha256 fa94a61f…
  • ONS DTWL, QNA (30 September 2026); ONS/HMRC PAYE RTI, November 2026 release
  • ONS Business investment by asset (30 September 2026)

🤖 Generated with Claude Code

vahid-ahmadi and others added 24 commits November 26, 2026 12:39
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… against them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port sector-conditional employment, two-universe calibration with per-band
registration propensity, stratified thinning with base weights and
in_frame/vat_scope flags from firm-microsim-paper. Solve with the public
solve_constraint_system (fixes #636) and use the paper's input-ratio
imputation (fixes #258). Add the UKFirmRules seam keyed by firm_id, the
firm universe helpers, and a policyengine-uk-named firm table export.
Name policyengine-uk as the firm rules home in docs/firm-support-plan.md.

Refs #1705, PolicyEngine/policyengine-uk#2939.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commit the paper's processed 2024-25 tables with provenance and golden
numbers from paper runs at aa1ce07 (full, fast and CI modes, seed 42).
The engine-free test runs a thinned build and checks exact targets and
propensities plus distributional tolerances; tools/firm_paper_parity.py
prints the full comparison table.

Refs #1705.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Share the HMRC band names between firm_universe and firm_generation,
remove the unused assign_vat_flags and calculate_vat_liability_values,
add UKFirmGenerationConfig.with_vintage, prove thinned solves start
from base weights, feed a generated population through the
policyengine-uk firm table, rename the parity tool to
tools/uk_firm_paper_parity.py, and correct the changelog and docs.

Refs #1705.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hash the reference JSON in the fixture provenance with the commands
that produced it, assert the golden full run reproduces the paper's
published 2024-25 headline, reuse the shared HMRC band names, and note
the parity test in the firm support plan.

Refs #1705.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
policyengine-uk gives period Y the parameter values in force on 30 April
Y, so the 2024-25 vintage is period 2024 (the £90k threshold) and
2023-24 is period 2023. Read test fixtures as UTF-8 and clarify the
#258 changelog.

Refs #1705.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pts comparison

Carved from #1706's state at bd59841 without the region, legal-status and
paybill steps, which move to later PRs of the split. The input-status map
covers the 71 policyengine-uk inputs at the committed 0d1c25010 snapshot,
with only the base columns set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apart from the rule period

The same-seed thinned 2024-25 population (295,271 rows) is identical,
checked exactly against the code before this commit on the same main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…what this PR sets

Fable review fixes: the support plan and README no longer say the
policyengine-uk adapter is unimplemented; the receipts paybill caveat no
longer describes an imputation this PR does not contain; note 4 cites the
ONS publication; a FirmRuleOutputs without the VAT output raises ValueError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ompanies and non-profits to charities

Region and legal status from ONS UK Business 2025 Tables 8, 12 and 13 (Table 15 held out), the export-group registry with the attributes group, value-free target candidates, and the receipt's data year per input group. ONS status 4 now exports as COMPANY and a public body, status 7 as a charity (assumed); LLPs are a caveat only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paybill, the pay split below the secondary threshold, Employment Allowance flags and take-up, BPE headcount and the labour link, public sector headcount and the 250+ headcount tail, each opt-in and assumed, with sources, data years and receipts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Taxable profit from HMRC Corporation Tax statistics liability bands (CT in-sample) and R&D expenditure from HMRC R&D tax credit statistics, each opt-in and assumed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Rateable value from the VOA rating-list stock, opt-in and assumed; the MHCLG empty-property figures as a standalone reader, not wired into the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mposition for UK firms

Household, intermediate and other final sales by SIC division from the ONS Supply and Use Tables 2024, the household purchases decomposition by source of supply, and the opt-in BPE turnover tail and re-pairing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Section shares of standard, reduced, zero-rated and exempt supplies, the
input VAT rate and an input-ratio target, read through VATA 1994 Sch 7A, 8
and 9; ABS 2024 section G turnover as the trade gross-sales base. New files
only; not wired into the build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ONS D.11 wages and salaries (DTWL, 2024) and PAYE RTI aggregate pay and
payrolled employees (2024-25), pinned by sha256, with report-only ratios.
The VAT composition gains a columns-only helper that leaves every scored
column unchanged; the calibration seam is documented as failing gate B2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ew fixes

--vat-composition-dir adds Microcosm-only firm_sut_* share columns and a
receipt section; --paybill-anchor-dir reports paybill over ONS D.11 and PAYE
RTI. Review fixes: consumer-service exports keep their UK treatment, section
G is weighted by ABS division turnover and its goods resold are priced at the
business purchase rate, relief costs are extracted from the pinned ODS, all
relief ratios are pinned, the reader validates the treatment table, and the
calibration seam is documented as failing gate B2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…provenance wording

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant