Repository navigation
Add a UK example that replicates a household targeting rule - #710
Open
vahid-ahmadi wants to merge 1 commit into
Open
vahid-ahmadi wants to merge 1 commit into
vahid-ahmadi wants to merge 1 commit into
Conversation
Shows the steps an outside replication needs and the docs do not cover: person-to-household maxima, the benefit unit to household join through person ids (map_to from a larger entity shares values), reported versus modelled benefit receipt, after-housing-costs deciles and fixed-budget amounts. Uses the published energy bill targeting options as the case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 of 9 tasks
vahid-ahmadi
marked this pull request as ready for review
October 23, 2026 21:59
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
Adds
examples/household_targeting_uk.py, a worked replication of a published household-level targeting rule, and lists it indocs/examples.mdand the README.Published UK analyses often define eligibility with a rule that is not a PolicyEngine variable. Reproducing one as a new user, the steps that took time were not in the docs:
person_household_id;sim.calculate("household_id", map_to="benunit")looks like the way to do it, but mapping from a larger entity to a smaller one shares the value among the smaller units (a household value of 1 becomes 2/3 and 1/3 for two benefit units of two and one people). That is right for amounts and wrong for ids and flags; the example joins through the person-level ids instead and says why;*_reported) and modelled entitlement;household_income_decileranks people by income before housing costs, while HBAI headline distributions and many publications use after housing costs. The example builds an AHC ranking explicitly;household_equivalisation_bhcis the HBAI-rescaled modified OECD scale (couple = 1.0), and a threshold on the unrescaled form passes far more households;The case is the energy bill discount options in "Billing me softly" (August 2026). The example links https://github.com/PolicyEngine/uk-energy-reforms, which implements those options as a policyengine-uk reform with the published figures beside PolicyEngine's.
Output
Run on 6.10.1 with the bundle's Microcosm UK 2024-25, fiscal year 2024-25:
The publication reports about 40%, 75%, about 25%, £175 and 490,000 for the matching figures. The example prints PolicyEngine's numbers only; it does not claim to match.
It needs the private UK data, like the other UK population examples, so it does not run in CI.
ruff checkandruff format --checkpass.🤖 Generated with Claude Code