Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: minor
changes:
added:
- rail_usage variable derived from rail_subsidy_spending / fare_index at survey year, enabling fare reforms to modify prices independently of usage quantity
30 changes: 30 additions & 0 deletions policyengine_uk_data/datasets/imputations/services/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,31 @@
"""

from policyengine_uk.data import UKSingleYearDataset
from policyengine_uk.system import system
from .nhs import impute_nhs_usage
from .etb import impute_public_services, create_efrs_input_dataset

# ETB survey year (most recent year in ETB data)
ETB_SURVEY_YEAR = 2021

# Fallback fare index for 2021 if parameter not yet available in policyengine-uk
# This is the cumulative fare index from base year 2020 (+1.0% from 2020)
FALLBACK_FARE_INDEX_2021 = 1.010


def get_fare_index_survey_year() -> float:
"""
Get the rail fare index for the ETB survey year.

Attempts to read from policyengine-uk parameters, falls back to
hardcoded value if parameter not yet available.
"""
try:
return system.parameters.gov.dft.rail.fare_index(ETB_SURVEY_YEAR)
except AttributeError:
# Parameter not yet available in policyengine-uk
return FALLBACK_FARE_INDEX_2021


def impute_services(
dataset: UKSingleYearDataset,
Expand Down Expand Up @@ -44,6 +66,14 @@ def impute_services(
.values
)

# Derive rail_usage (quantity at base year prices) from rail_subsidy_spending
# rail_usage = rail_subsidy_spending / fare_index at survey year
# This allows reforms to modify fare_index independently of usage quantity
fare_index_survey_year = get_fare_index_survey_year()
dataset.household["rail_usage"] = (
dataset.household["rail_subsidy_spending"] / fare_index_survey_year
)

visit_variables = [
"a_and_e_visits",
"admitted_patient_visits",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.