Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forecast to 2027 #550

Merged
merged 20 commits into from
Mar 24, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
9,440 changes: 7,566 additions & 1,874 deletions docs/book/model/validation.ipynb

Large diffs are not rendered by default.

Binary file modified openfisca_uk/calibration/frs_weights.h5
Binary file not shown.
Binary file added openfisca_uk/data/baseline_benefits.h5
Binary file not shown.
14 changes: 7 additions & 7 deletions openfisca_uk/parameters/benefit/housing_benefit/takeup.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description: Share of eligible Housing Benefit recipients that participate
nikhilwoodruff marked this conversation as resolved.
Show resolved Hide resolved
values:
2025-01-01: 0.719
2024-01-01: 0.786
2023-01-01: 0.831
2022-01-01: 0.855
2021-01-01: 0.879
2020-01-01: 0.898
2019-01-01: 0.941
2025-01-01: 1.0
2024-01-01: 1.0
2023-01-01: 1.0
2022-01-01: 1.0
2021-01-01: 1.0
2020-01-01: 1.0
2019-01-01: 1.0
metadata:
label: Housing Benefit take-up rate
name: HB_takeup
Expand Down
14 changes: 7 additions & 7 deletions openfisca_uk/parameters/benefit/income_support/takeup.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description: Share of eligible Income Support recipients that participate
values:
2025-01-01: 0.092
2024-01-01: 0.171
2023-01-01: 0.237
2022-01-01: 0.304
2021-01-01: 0.371
2020-01-01: 0.435
2019-01-01: 0.528
2025-01-01: 1.0
2024-01-01: 1.0
2023-01-01: 1.0
2022-01-01: 1.0
2021-01-01: 1.0
2020-01-01: 1.0
2019-01-01: 1.0
metadata:
label: Income Support take-up rate
name: IS_takeup
Expand Down
14 changes: 7 additions & 7 deletions openfisca_uk/parameters/benefit/pension_credit/takeup.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description: Share of eligible Pension Credit recipients that participate
values:
2025-01-01: 0.645
2024-01-01: 0.638
2023-01-01: 0.634
2022-01-01: 0.616
2021-01-01: 0.63
2020-01-01: 0.648
2019-01-01: 0.637
2025-01-01: 0.463
2024-01-01: 0.4524
2023-01-01: 0.4483
2022-01-01: 0.4207
2021-01-01: 0.4239
2020-01-01: 0.4273
2019-01-01: 0.4261
metadata:
label: Pension Credit take-up rate
name: PC_takeup
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description: Share of eligible Child Tax Credit recipients that participate
values:
2025-01-01: 0.514
2024-01-01: 0.538
2023-01-01: 0.567
2022-01-01: 0.601
2021-01-01: 0.623
2020-01-01: 0.686
2019-01-01: 0.745
2025-01-01: 1.0
2024-01-01: 1.0
2023-01-01: 1.0
2022-01-01: 1.0
2021-01-01: 1.0
2020-01-01: 1.0
2019-01-01: 1.0
metadata:
label: Child Tax Credit take-up rate
unit: /1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
description: Share of eligible Working Tax Credit recipients that participate
values:
2025-01-01: 0.438
2024-01-01: 0.482
2023-01-01: 0.512
2022-01-01: 0.541
2021-01-01: 0.497
2020-01-01: 0.597
2019-01-01: 0.644
2025-01-01: 1.0
2024-01-01: 1.0
2023-01-01: 1.0
2022-01-01: 1.0
2021-01-01: 1.0
2020-01-01: 1.0
2019-01-01: 1.0
metadata:
label: Working Tax Credit take-up rate
name: WTC_takeup
Expand Down
14 changes: 7 additions & 7 deletions openfisca_uk/parameters/benefit/universal_credit/takeup.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
description: Universal Credit takeup rate
values:
2025-01-01: 0.652
2024-01-01: 0.65
2023-01-01: 0.647
2022-01-01: 0.644
2021-01-01: 0.637
2020-01-01: 0.676
2019-01-01: 0.571
2025-01-01: 0.8717
2024-01-01: 0.8637
2023-01-01: 0.8555
2022-01-01: 0.8472
2021-01-01: 0.8366
2020-01-01: 0.869
2019-01-01: 0.7447
metadata:
unit: /1
13 changes: 13 additions & 0 deletions openfisca_uk/parameters/hmrc/child_benefit/takeup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: Share of eligible Child Benefit recipients that participate
values:
2025-01-01: 0.7588
2024-01-01: 0.7616
2023-01-01: 0.7625
2022-01-01: 0.764
2021-01-01: 0.7639
2020-01-01: 0.771
2019-01-01: 0.7768
metadata:
label: Child Benefit take-up rate
name: CB_takeup
unit: /1
22 changes: 0 additions & 22 deletions openfisca_uk/parameters/hmrc/child_benefit/takeup_rate.yaml

This file was deleted.

22 changes: 21 additions & 1 deletion openfisca_uk/tools/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openfisca_uk.entities import *
import numpy as np
import warnings
from openfisca_uk.initial_setup import set_default
from openfisca_uk.initial_setup import REPO, set_default
from openfisca_uk.reforms.presets.current_date import use_current_parameters
from openfisca_uk.reforms.presets.average_parameters import (
average_parameters as apply_parameter_averaging,
Expand Down Expand Up @@ -80,6 +80,7 @@ def __init__(
duplicate_records: bool = False,
adjust_weights: bool = True,
average_parameters: bool = False,
add_baseline_benefits: bool = True,
):
if adjust_weights:
duplicate_records = True
Expand Down Expand Up @@ -193,6 +194,25 @@ def close():
).values,
)

# Add baseline benefits

if add_baseline_benefits:
with h5py.File(REPO / "data" / "baseline_benefits.h5", "r") as f:
for year in list(range(2019, 2026)):
for benefit in [
"universal_credit",
"pension_credit",
"working_tax_credit",
"child_tax_credit",
"income_support",
"housing_benefit",
]:
self.simulation.set_input(
f"baseline_has_{benefit}",
year,
np.array(f[f"{year}/{benefit}"]) > 0,
)

if average_parameters:
self.simulation.tax_benefit_system.parameters = (
apply_parameter_averaging(
Expand Down
62 changes: 45 additions & 17 deletions openfisca_uk/tools/takeup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
from openfisca_uk import parameters
import os
from openfisca_uk import REPO, parameters
from openfisca_uk.tools.simulation import Microsimulation
import h5py

BENEFITS = [
"universal_credit",
"pension_credit",
"child_benefit",
"working_tax_credit",
"child_tax_credit",
"income_support",
"housing_benefit",
"JSA_income",
]

YEARS = list(range(2019, 2026))


def add_takeup_parameters():
Expand All @@ -8,50 +24,62 @@ def add_takeup_parameters():

from openfisca_uk import Microsimulation

years = list(range(2019, 2026))

baseline = Microsimulation()
full_benefit_claimants = Microsimulation()
for year in years:
for year in YEARS:
full_benefit_claimants.set_input(
"claims_all_entitled_benefits",
year,
[True] * len(baseline.calc("benunit_id", period=year)),
)

VARIABLES = [
"universal_credit",
"pension_credit",
"working_tax_credit",
"child_tax_credit",
"income_support",
"housing_benefit",
]

takeup_parameters = [
parameters.benefit.universal_credit.takeup,
parameters.benefit.pension_credit.takeup,
parameters.hmrc.child_benefit.takeup,
parameters.benefit.tax_credits.working_tax_credit.takeup,
parameters.benefit.tax_credits.child_tax_credit.takeup,
parameters.benefit.income_support.takeup,
parameters.benefit.housing_benefit.takeup,
parameters.benefit.JSA.income.takeup,
]

for variable, parameter in zip(VARIABLES, takeup_parameters):
for variable, parameter in zip(BENEFITS, takeup_parameters):
parameter.values_list = []
for year in years:
print(f"{variable}:")
for year in YEARS:
baseline_claimants = (
baseline.calc(variable, period=year) > 0
).sum()
maximum_claimants = (
full_benefit_claimants.calc(variable, period=year) > 0
).sum()
takeup_rate = round(baseline_claimants / maximum_claimants, 4)
print(
f"\t{year}: {baseline_claimants/1e6:.2f}m / {maximum_claimants/1e6:.2f}m = {takeup_rate:.1%}"
)
parameter.update(
value=round(baseline_claimants / maximum_claimants, 3),
value=takeup_rate,
period=f"year:{year}:1",
)
print(f"{variable} benefit takeup parameter:\n\n{parameter}")

print("PARAMETERS:")
for parameter in takeup_parameters:
print(f"\t{parameter.name}: \n{parameter}\n\n")


def generate_baseline_benefit_variables():
baseline = Microsimulation(add_baseline_benefits=False)
filepath = REPO / "data" / "baseline_benefits.h5"
os.remove(filepath)
with h5py.File(filepath, "w") as f:
for year in YEARS:
for benefit in BENEFITS:
f[f"{year}/{benefit}"] = baseline.calc(
benefit, period=year
).values


if __name__ == "__main__":
generate_baseline_benefit_variables()
add_takeup_parameters()
4 changes: 2 additions & 2 deletions openfisca_uk/variables/government/dwp/JSA_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def formula(benunit, period, parameters):
any_unemployed = benunit.any(unemployed_members)
# Cannot claim Income Support.
not_on_income_support = benunit("income_support", period) == 0
on_legacy_benefits = benunit("claims_legacy_benefits", period)
already_claiming = aggr(benunit, period, ["JSA_income_reported"]) > 0
return (
hours_eligible
& all_under_SP_age
& any_unemployed
& not_on_income_support
& on_legacy_benefits
& already_claiming
)


Expand Down
6 changes: 3 additions & 3 deletions openfisca_uk/variables/government/dwp/housing_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class housing_benefit_eligible(Variable):

def formula(benunit, period, parameters):
social = benunit.any(benunit.members("in_social_housing", period))
claims_legacy_benefits = benunit("claims_legacy_benefits", period)
return claims_legacy_benefits & (
social | benunit("LHA_eligible", period)
already_claiming = (
aggr(benunit, period, ["housing_benefit_reported"]) > 0
)
return already_claiming & (social | benunit("LHA_eligible", period))


class would_claim_HB(Variable):
Expand Down
10 changes: 6 additions & 4 deletions openfisca_uk/variables/government/dwp/income_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def formula(benunit, period, parameters):
claims_all_entitled_benefits = benunit(
"claims_all_entitled_benefits", period
)
baseline = benunit("baseline_has_is", period)
baseline = benunit("baseline_has_income_support", period)
takeup_rate = parameters(period).benefit.housing_benefit.takeup
return select(
[reported_is | claims_all_entitled_benefits, ~baseline, True],
Expand All @@ -35,7 +35,7 @@ def formula(benunit, period, parameters):
)


class baseline_has_is(Variable):
class baseline_has_income_support(Variable):
label = "Receives Income Support (baseline)"
entity = BenUnit
definition_period = YEAR
Expand Down Expand Up @@ -105,12 +105,14 @@ def formula(benunit, period, parameters):
has_carers = aggr(benunit, period, ["is_carer_for_benefits"]) > 0
none_SP_age = ~benunit.any(benunit.members("is_SP_age", period))
has_ESA_income = benunit("ESA_income", period) > 0
claims_legacy_benefits = benunit("claims_legacy_benefits", period)
already_claiming = (
aggr(benunit, period, ["income_support_reported"]) > 0
)
return (
(has_carers | lone_parent_with_young_child)
& none_SP_age
& ~has_ESA_income
& claims_legacy_benefits
& already_claiming
)


Expand Down
Loading