Repository navigation
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
Draft
vahid-ahmadi wants to merge 24 commits into
vahid-ahmadi wants to merge 24 commits into
Conversation
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>
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.firm_vat_composition.py,--vat-composition-dir, which needs--consumption-dir).firm_sut_*columns for each SIC section:firm_paybill_anchor.py,--paybill-anchor-dir).docs/uk-firm-capex-design.md).What was tried and not adopted: the calibration seam
UKFirmVATCompositionRulesandrescale_uk_firm_input_costslet 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 (
f644ab023tree, reference opt-in flags, pe-uk0d1c25010):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_sectoron 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:
The changes are not tuned to HMRC VAT by sector. Applied to the reference weights with no re-solve:
Relief checks (model base ÷ HMRC relief cost ÷ rate, 2024-25)
Assumptions (all labelled in the module and the treatment table)
assumed.Validation
b11c37e58) on every shared column.firm_is_charity.--vat-composition-diron every shared column, weights included.test_uk_receipt_counts.pypass; ruff passes;ci_test_plan verifyis ok.--checkmatches the committed CSVs, against downloads whose sha256 is pinned.Reviews
Sources (pinned in
provenance.json, with URL, edition and sha256)supublicationtablesbb26.xlsx, sha256716c9e02…abssectionsas.xlsx, sha2569e548c5c…tax_relief_statistics_january_2026.ods, sha256fa94a61f…🤖 Generated with Claude Code