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: patch
changes:
fixed:
- Added mortgage and private rent targets.
17 changes: 14 additions & 3 deletions policyengine_uk_data/datasets/imputations/income.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,25 @@ def impute_over_incomes(
DataFrame with imputed income components.
"""
dataset = dataset.copy()
input_df = Microsimulation(dataset=dataset).calculate_dataframe(
["age", "gender", "region"]
)
sim = Microsimulation(dataset=dataset)
input_df = sim.calculate_dataframe(["age", "gender", "region"])
original_income_total = dataset.person[IMPUTATIONS].copy().sum().sum()
output_df = model.predict(input_df)

for column in output_variables:
dataset.person[column] = output_df[column].fillna(0).values

new_income_total = dataset.person[IMPUTATIONS].sum().sum()
adjustment_factor = new_income_total / original_income_total
# Adjust rent and mortgage interest and capital repayments proportionally
dataset.household["rent"] = dataset.household["rent"] * adjustment_factor
dataset.household["mortgage_interest_repayment"] = (
dataset.household["mortgage_interest_repayment"] * adjustment_factor
)
dataset.household["mortgage_capital_repayment"] = (
dataset.household["mortgage_capital_repayment"] * adjustment_factor
)

return dataset


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ reforms:
parameters:
gov.hmrc.child_benefit.amount.additional: 25
- name: Reduce Universal Credit taper rate to 20%
expected_impact: -27.2
expected_impact: -30.9
parameters:
gov.dwp.universal_credit.means_test.reduction_rate: 0.2
- name: Raise Class 1 main employee NICs rate to 10%
Expand Down
2 changes: 1 addition & 1 deletion policyengine_uk_data/utils/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def calibrate_local_areas(
area_count: int,
weight_file: str,
dataset_key: str = "2025",
epochs: int = 256,
epochs: int = 512,
excluded_training_targets=[],
log_csv=None,
verbose: bool = False,
Expand Down
26 changes: 24 additions & 2 deletions policyengine_uk_data/utils/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ def pe_count(*variables):
target_names.append("hmrc/salary_sacrifice_contributions")
target_values.append(SS_CONTRIBUTIONS_2024 * uprating_factor)

print(target_names[-4:], target_values[-4:])

# Add two-child limit targets.
child_is_affected = (
sim.map_result(
Expand Down Expand Up @@ -574,6 +572,30 @@ def pe_count(*variables):
target_names.append("nts/households_two_plus_vehicles")
target_values.append(total_households * NTS_TWO_PLUS_VEHICLE_RATE)

RENT_ESTIMATE = {
"private_renter": 1_400
* 12
* 4.7e6, # https://www.ons.gov.uk/economy/inflationandpriceindices/bulletins/privaterentandhousepricesuk/january2025
"owner_mortgage": 1_100 * 12 * 7.5e6,
}

# Housing affordability targets
# Total mortgage payments (capital + interest)
mortgage_capital = pe("mortgage_capital_repayment")
mortgage_interest = pe("mortgage_interest_repayment")
total_mortgage = mortgage_capital + mortgage_interest
df["housing/total_mortgage"] = total_mortgage
target_names.append("housing/total_mortgage")
target_values.append(RENT_ESTIMATE["owner_mortgage"])

# Total rent by tenure type
rent = pe("rent")
tenure_type = sim.calculate("tenure_type", map_to="household").values

df["housing/rent_private"] = rent * (tenure_type == "RENT_PRIVATELY")
target_names.append("housing/rent_private")
target_values.append(RENT_ESTIMATE["private_renter"])

combined_targets = pd.concat(
[
targets,
Expand Down