Add rail_usage variable derived from rail_subsidy_spending#227
Merged
Conversation
Derives rail_usage (quantity at base year prices) from rail_subsidy_spending by dividing by the fare index for the survey year (2021): rail_usage = rail_subsidy_spending / 1.010 This enables policyengine-uk to properly decompose rail spending into price × quantity, allowing reforms to modify the fare_index parameter independently of usage quantity. Related: PolicyEngine/policyengine-uk#1406 Fixes: #226 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Import system from policyengine_uk to access parameters - Add get_fare_index_survey_year() function that tries to read gov.dft.rail.fare_index from parameters, falls back to 1.010 - This allows the code to work both before and after policyengine-uk PR #1406 is merged 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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 a
rail_usagevariable to the dataset representing rail usage quantity at base year (2020) prices.Implementation
Where
RAIL_FARE_INDEX_SURVEY_YEAR = 1.010(the 2021 fare index from policyengine-uk).Why This Matters
This enables policyengine-uk PR #1406 to properly decompose rail spending into price × quantity:
Without this change, the policyengine-uk formula would be a tautology:
rail_usage = spending / fare_index(computed each year)rail_subsidy_spending = rail_usage × fare_index = spending(no change!)With this change,
rail_usageis derived once at the survey year and stored in the dataset. This allows reforms to modifyfare_indexand see actual effects onrail_subsidy_spending.Use Case
The Autumn Budget 2025 rail fares freeze policy freezes fares in 2026 while ridership continues to grow. Proper price × quantity decomposition enables:
fare_indexparameterrail_usageRelated
🤖 Generated with Claude Code