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

Fix cliff impacts #997

Merged
merged 6 commits into from
Nov 19, 2024
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
8 changes: 8 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- bump: patch
changes:
added:
- marginal_tax_rate_delta parameter
- marginal_tax_rate_adults parameter
changed:
- Refactored cliff_gap variable to use marginal_tax_rate_delta parameter
- Refactored marginal_tax_rate variable to use both new parameters
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description: Number of adults to simulate a marginal tax rate for, in each household.
values:
0000-01-01: 2
metadata:
unit: int
label: Number of adults to simulate a marginal tax rate for
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Amount by which employment_income is increased to calculate marginal tax rate.
values:
0000-01-01: 1_000
metadata:
unit: currency-GBP
41 changes: 8 additions & 33 deletions policyengine_uk/variables/household/cliff.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ class cliff_evaluated(Variable):

def formula(person, period, parameters):
adult_index_values = person("adult_index", period)
cliff_adult_count = 2
cliff_adult_count = parameters(
period
).gov.simulation.marginal_tax_rate_adults
return adult_index_values <= cliff_adult_count


Expand All @@ -20,47 +22,20 @@ class cliff_gap(Variable):
entity = Person
label = "cliff gap"
unit = GBP
documentation = "Amount of income lost if this person's employment income increased by £2,000."
documentation = "Amount of income lost if this person's employment income increased by delta amount."
definition_period = YEAR

def formula(person, period, parameters):
DELTA = 2_000
cliff_values = np.zeros(person.count, dtype=np.float32)
simulation = person.simulation
adult_index_values = person("adult_index", period)
cliff_adult_count = 2
for adult_index in range(1, 1 + cliff_adult_count):
alt_simulation = simulation.get_branch(
f"adult_{adult_index}_2k_pay_rise"
)
mask = adult_index_values == adult_index
for variable in simulation.tax_benefit_system.variables:
if variable not in simulation.input_variables:
alt_simulation.delete_arrays(variable)
alt_simulation.set_input(
"employment_income",
period,
person("employment_income", period) + mask * DELTA,
)
alt_person = alt_simulation.person
household_net_income = person.household(
"household_net_income", period
)
household_net_income_higher_earnings = alt_person.household(
"household_net_income", period
)
increase = (
household_net_income_higher_earnings - household_net_income
)
cliff_values += where(mask & (increase < 0), -increase, 0)
return cliff_values
delta = parameters(period).gov.simulation.marginal_tax_rate_delta
mtr = person("marginal_tax_rate", period)
return max_(0, (mtr - 1) * delta)


class is_on_cliff(Variable):
value_type = bool
entity = Person
label = "is on a tax-benefit cliff"
documentation = "Whether this person would be worse off if their employment income were $2,000 higher."
documentation = "Whether this person would be worse off if their employment income were higher by delta amount."
definition_period = YEAR

def formula(person, period, parameters):
Expand Down
10 changes: 6 additions & 4 deletions policyengine_uk/variables/household/marginal_tax_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class marginal_tax_rate(Variable):
unit = "/1"

def formula(person, period, parameters):
p = parameters(period).gov.simulation
mtr_values = np.zeros(person.count, dtype=np.float32)
simulation = person.simulation
adult_index_values = person("adult_index", period)
DELTA = 1_000
for adult_index in [1, 2]:
delta = p.marginal_tax_rate_delta
adult_count = p.marginal_tax_rate_adults
for adult_index in range(1, 1 + adult_count):
alt_simulation = simulation.get_branch(
f"adult_{adult_index}_pay_rise"
)
Expand All @@ -32,7 +34,7 @@ def formula(person, period, parameters):
alt_simulation.set_input(
"employment_income",
period,
person("employment_income", period) + mask * DELTA,
person("employment_income", period) + mask * delta,
)
alt_person = alt_simulation.person
household_net_income = person.household(
Expand All @@ -44,5 +46,5 @@ def formula(person, period, parameters):
increase = (
household_net_income_higher_earnings - household_net_income
)
mtr_values += where(mask, 1 - increase / DELTA, 0)
mtr_values += where(mask, 1 - increase / delta, 0)
return mtr_values
Loading