Skip to content

Commit

Permalink
Add improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed May 23, 2024
1 parent ce8bca6 commit 8b79a0e
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 18 deletions.
7 changes: 7 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- bump: minor
changes:
fixed:
- New benefit claimants are now accounted for in reforms.
added:
- Abolition switch for State Pension payments.
- Freeze switch for Pension Credit payments.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Remove all State Pension payments.
values:
2000-01-01: false
metadata:
unit: bool
label: Abolish State Pension
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Freeze Pension Credit payments. Set all Pension Credit payments to what they are under baseline policy.
values:
2000-01-01: false
metadata:
unit: currency-GBP
label: Freeze Pension Credit
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
description: Universal Credit takeup rate
values:
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
2019-01-01: 0.63 # From PolicyEngine microsimulation (UC claimants vs eligible households).
metadata:
unit: /1
13 changes: 8 additions & 5 deletions policyengine_uk/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,14 @@ def __init__(self, *args, **kwargs):

# Labor supply responses

employment_income = self.get_holder("employment_income")
for known_period in employment_income.get_known_periods():
array = employment_income.get_array(known_period)
self.set_input("employment_income_before_lsr", known_period, array)
employment_income.delete_arrays(known_period)
for simulation in list(self.branches.values()) + [self]:
employment_income = simulation.get_holder("employment_income")
for known_period in employment_income.get_known_periods():
array = employment_income.get_array(known_period)
simulation.set_input(
"employment_income_before_lsr", known_period, array
)
employment_income.delete_arrays(known_period)


class IndividualSim(CoreIndividualSim): # Deprecated
Expand Down
10 changes: 8 additions & 2 deletions policyengine_uk/variables/gov/dwp/housing_benefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ class housing_benefit_pre_benefit_cap(Variable):
def formula(benunit, period, parameters):
entitlement = benunit("housing_benefit_entitlement", period)
eligible = benunit("housing_benefit_eligible", period)
would_claim = benunit("would_claim_HB", period)
return would_claim * entitlement * eligible
return entitlement * eligible


class housing_benefit(Variable):
Expand All @@ -250,6 +249,7 @@ class housing_benefit(Variable):
definition_period = YEAR
value_type = float
unit = GBP
defined_for = "would_claim_HB"

def formula(benunit, period, parameters):
housing_benefit_entitlement = benunit(
Expand All @@ -269,3 +269,9 @@ class baseline_housing_benefit_entitlement(Variable):
definition_period = YEAR
value_type = float
unit = GBP

def formula(benunit, period, parameters):
if benunit.simulation.baseline is None:
return 1
baseline = benunit.simulation.baseline.populations["benunit"]
return baseline("housing_benefit_entitlement", period)
14 changes: 12 additions & 2 deletions policyengine_uk/variables/gov/dwp/pension_credit/pension_credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@ class pension_credit(Variable):
value_type = float
unit = GBP
reference = "https://www.legislation.gov.uk/ukpga/2002/16/contents"
defined_for = "would_claim_pc"
adds = ["pension_credit_entitlement"]

def formula(benunit, period, parameters):
entitlement = benunit("pension_credit_entitlement", period)
would_claim = benunit("would_claim_pc", period)
amount = entitlement * would_claim

freeze = parameters(period).gov.contrib.freeze_pension_credit
baseline = benunit.simulation.baseline
if freeze and baseline is not None:
return baseline.populations["benunit"]("pension_credit", period)
else:
return amount
12 changes: 12 additions & 0 deletions policyengine_uk/variables/gov/dwp/tax_credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,21 @@ class baseline_wtc_entitlement(Variable):
definition_period = YEAR
value_type = float

def formula(benunit, period, parameters):
if benunit.simulation.baseline is None:
return 1
baseline = benunit.simulation.baseline.populations["benunit"]
return baseline("wtc_entitlement", period)


class baseline_ctc_entitlement(Variable):
label = "Receives Child Tax Credit (baseline)"
entity = BenUnit
definition_period = YEAR
value_type = float

def formula(benunit, period, parameters):
if benunit.simulation.baseline is None:
return 1
baseline = benunit.simulation.baseline.populations["benunit"]
return baseline("wtc_entitlement", period)
48 changes: 46 additions & 2 deletions policyengine_uk/variables/gov/dwp/universal_credit.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,56 @@ def formula(benunit, period, parameters):
current_uc_claimant = (
add(benunit, period, ["universal_credit_reported"]) > 0
)
brought_into_claim = benunit(
"is_brought_into_uc_claimant_status", period
)
is_in_microsimulation = hasattr(benunit.simulation, "dataset")
if is_in_microsimulation:
return current_uc_claimant
return current_uc_claimant | brought_into_claim
return True


class is_brought_into_uc_claimant_status(Variable):
label = "brought into UC claimant status"
entity = BenUnit
definition_period = YEAR
value_type = bool

def formula(benunit, period, parameters):
if benunit.simulation.baseline is None:
return False
uc_entitled = benunit("is_uc_entitled", period)
uc_entitled_baseline = benunit("is_uc_entitled_baseline", period)
takeup = parameters(period).gov.dwp.universal_credit.takeup
takes_up_given_new_claimant = random(benunit) < takeup
return (
uc_entitled & ~uc_entitled_baseline & takes_up_given_new_claimant
)


class is_uc_entitled(Variable):
label = "meets the means test for Universal Credit"
entity = BenUnit
definition_period = YEAR
value_type = bool

def formula(benunit, period, parameters):
uc = benunit("universal_credit_pre_benefit_cap", period)
return uc > 0


class is_uc_entitled_baseline(Variable):
label = "meets the means test for Universal Credit under baseline law"
entity = BenUnit
definition_period = YEAR
value_type = bool

def formula(benunit, period, parameters):
baseline = benunit.simulation.baseline.populations["benunit"]
uc = baseline("universal_credit_pre_benefit_cap", period)
return uc > 0


class is_UC_eligible(Variable):
value_type = bool
entity = BenUnit
Expand Down Expand Up @@ -581,7 +625,6 @@ class universal_credit_pre_benefit_cap(Variable):
category = BENEFIT
adds = ["UC_maximum_amount"]
subtracts = ["UC_income_reduction"]
defined_for = "would_claim_UC"


class universal_credit(Variable):
Expand All @@ -590,6 +633,7 @@ class universal_credit(Variable):
definition_period = YEAR
value_type = float
unit = GBP
defined_for = "would_claim_UC"

def formula(benunit, period, parameters):
uc_max_entitlement = benunit(
Expand Down
2 changes: 2 additions & 0 deletions policyengine_uk/variables/input/income.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class state_pension(Variable):

def formula(person, period, parameters):
gov = parameters(period).gov
if gov.contrib.abolish_state_pension:
return 0
relative_increase = gov.contrib.cec.state_pension_increase
uprating = 1 + relative_increase
sp = gov.dwp.state_pension
Expand Down

0 comments on commit 8b79a0e

Please sign in to comment.