Skip to content

Commit

Permalink
Change _lsr to _behavioral_response
Browse files Browse the repository at this point in the history
  • Loading branch information
Mshuning committed Oct 31, 2024
1 parent f1ecf38 commit 7203d33
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 46 deletions.
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 / fixed:
- Change _lsr to _behavioral_response.
34 changes: 25 additions & 9 deletions policyengine_us/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,30 @@ def __init__(self, *args, **kwargs):
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)
self.set_input(
"employment_income_before_behavioral_response",
known_period,
array,
)
employment_income.delete_arrays(known_period)

self_employment_income = self.get_holder("self_employment_income")
for known_period in employment_income.get_known_periods():
array = self_employment_income.get_array(known_period)
self.set_input(
"self_employment_income_before_lsr", known_period, array
"self_employment_income_before_behavioral_response",
known_period,
array,
)
self_employment_income.delete_arrays(known_period)

weekly_hours = self.get_holder("weekly_hours_worked")
for known_period in weekly_hours.get_known_periods():
array = weekly_hours.get_array(known_period)
self.set_input(
"weekly_hours_worked_before_lsr", known_period, array
"weekly_hours_worked_before_behavioral_response",
known_period,
array,
)
weekly_hours.delete_arrays(known_period)

Expand Down Expand Up @@ -160,22 +168,30 @@ def __init__(self, *args, **kwargs):
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)
self.set_input(
"employment_income_before_behavioral_response",
known_period,
array,
)
employment_income.delete_arrays(known_period)

self_employment_income = self.get_holder("self_employment_income")
for known_period in self_employment_income.get_known_periods():
array = self_employment_income.get_array(known_period)
self.set_input(
"self_employment_income_before_lsr", known_period, array
"self_employment_income_before_behavioral_response",
known_period,
array,
)
self_employment_income.delete_arrays(known_period)

weekly_hours = self.get_holder("weekly_hours_worked")
for known_period in weekly_hours.get_known_periods():
array = weekly_hours.get_array(known_period)
self.set_input(
"weekly_hours_worked_before_lsr", known_period, array
"weekly_hours_worked_before_behavioral_response",
known_period,
array,
)
weekly_hours.delete_arrays(known_period)

Expand All @@ -200,9 +216,9 @@ def __init__(self, *args, **kwargs):
"capital_gains",
]
] + [
"employment_income_before_lsr",
"self_employment_income_before_lsr",
"weekly_hours_worked_before_lsr",
"employment_income_before_behavioral_response",
"self_employment_income_before_behavioral_response",
"weekly_hours_worked_before_behavioral_response",
"capital_gains_before_response",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
is_full_time_student: true
age: 18
is_disabled: false
weekly_hours_worked_before_lsr: false
weekly_hours_worked_before_behavioral_response: false
is_parent: false
output:
is_snap_ineligible_student: true
Expand All @@ -15,7 +15,7 @@
is_full_time_student: true
age: 17
is_disabled: false
weekly_hours_worked_before_lsr: false
weekly_hours_worked_before_behavioral_response: false
is_parent: false
output:
is_snap_ineligible_student: false
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def formula(person, period, parameters):
simulation = person.simulation
measurement_branch = simulation.get_branch("lsr_measurement")
baseline_branch = simulation.get_branch("baseline").get_branch(
"baseline_lsr_measurement"
"baseline_behavioral_response_measurement"
)
measurement_person = measurement_branch.populations["person"]
baseline_person = baseline_branch.populations["person"]
Expand Down Expand Up @@ -49,7 +49,7 @@ def formula(person, period, parameters):
simulation = person.simulation
measurement_branch = simulation.get_branch("lsr_measurement")
baseline_branch = simulation.get_branch("baseline").get_branch(
"baseline_lsr_measurement"
"baseline_behavioral_response_measurement"
)
measurement_person = measurement_branch.populations["person"]
baseline_person = baseline_branch.populations["person"]
Expand All @@ -67,7 +67,7 @@ def formula(person, period, parameters):
return np.clip(relative_change, -wage_change_bound, wage_change_bound)


class income_elasticity_lsr(Variable):
class income_elasticity_behavioral_response(Variable):
value_type = float
entity = Person
label = "income elasticity of labor supply response"
Expand All @@ -77,9 +77,11 @@ class income_elasticity_lsr(Variable):

def formula(person, period, parameters):
lsr = parameters(period).gov.simulation.labor_supply_responses
employment_income = person("employment_income_before_lsr", period)
employment_income = person(
"employment_income_before_behavioral_response", period
)
self_employment_income = person(
"self_employment_income_before_lsr", period
"self_employment_income_before_behavioral_response", period
)
earnings = employment_income + self_employment_income
income_change = person("relative_income_change", period)
Expand Down Expand Up @@ -136,9 +138,9 @@ def formula(person, period, parameters):
1_726e3,
]

earnings = person("employment_income_before_lsr", period) + person(
"self_employment_income_before_lsr", period
)
earnings = person(
"employment_income_before_behavioral_response", period
) + person("self_employment_income_before_behavioral_response", period)
earnings_decile = (
np.searchsorted(earnings_decile_markers, earnings) + 1
)
Expand Down Expand Up @@ -178,7 +180,7 @@ def formula(person, period, parameters):
return elasticities


class substitution_elasticity_lsr(Variable):
class substitution_elasticity_behavioral_response(Variable):
value_type = float
entity = Person
label = "substitution elasticity of labor supply response"
Expand All @@ -188,9 +190,11 @@ class substitution_elasticity_lsr(Variable):

def formula(person, period, parameters):
lsr = parameters(period).gov.simulation.labor_supply_responses
employment_income = person("employment_income_before_lsr", period)
employment_income = person(
"employment_income_before_behavioral_response", period
)
self_employment_income = person(
"self_employment_income_before_lsr", period
"self_employment_income_before_behavioral_response", period
)
earnings = employment_income + self_employment_income
wage_change = person("relative_wage_change", period)
Expand Down Expand Up @@ -223,7 +227,7 @@ def formula(person, period, parameters):
"lsr_measurement", clone_system=True
) # A branch without LSRs
baseline_branch = simulation.get_branch("baseline").get_branch(
"baseline_lsr_measurement", clone_system=True
"baseline_behavioral_response_measurement", clone_system=True
) # Already created by default
baseline_branch.tax_benefit_system.parameters.simulation = (
measurement_branch.tax_benefit_system.parameters.simulation
Expand All @@ -241,22 +245,24 @@ def formula(person, period, parameters):
"self_employment_income_behavioral_response"
)
branch.set_input(
"employment_income_before_lsr",
"employment_income_before_behavioral_response",
period,
person("employment_income_before_lsr", period),
person("employment_income_before_behavioral_response", period),
)
branch.set_input(
"self_employment_income_before_lsr",
"self_employment_income_before_behavioral_response",
period,
person("self_employment_income_before_lsr", period),
person(
"self_employment_income_before_behavioral_response", period
),
)

response = add(
person,
period,
[
"income_elasticity_lsr",
"substitution_elasticity_lsr",
"income_elasticity_behavioral_response",
"substitution_elasticity_behavioral_response",
],
)

Expand All @@ -275,9 +281,11 @@ class employment_income_behavioral_response(Variable):

def formula(person, period, parameters):
lsr = person("labor_supply_behavioral_response", period)
employment_income = person("employment_income_before_lsr", period)
employment_income = person(
"employment_income_before_behavioral_response", period
)
self_employment_income = person(
"self_employment_income_before_lsr", period
"self_employment_income_before_behavioral_response", period
)
earnings = employment_income + self_employment_income
emp_share = np.ones_like(earnings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def formula(person, period, parameters):
p = parameters(period).gov.usda.snap.student
age_eligible = p.age_threshold.calc(age)
disabled = person("is_disabled", period)
hours_worked = person("weekly_hours_worked_before_lsr", period)
hours_worked = person(
"weekly_hours_worked_before_behavioral_response", period
)
hours_eligible = hours_worked >= p.working_hours_threshold
# The parental status applies to children under 6 (under 12
# if no care available)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class weekly_hours_worked(Variable):
documentation = "Hours worked per week on average."
definition_period = YEAR
adds = [
"weekly_hours_worked_before_lsr",
"weekly_hours_worked_before_behavioral_response",
"weekly_hours_worked_behavioural_response",
]


class weekly_hours_worked_before_lsr(Variable):
class weekly_hours_worked_before_behavioral_response(Variable):
value_type = float
entity = Person
label = "average weekly hours worked (before labor supply responses)"
Expand All @@ -30,14 +30,22 @@ class weekly_hours_worked_behavioural_response_income_elasticity(Variable):
definition_period = YEAR

def formula(person, period, parameters):
original = person("weekly_hours_worked_before_lsr", period)
original = person(
"weekly_hours_worked_before_behavioral_response", period
)
lsr = person("labor_supply_behavioral_response", period)
if (lsr != 0).any():
income_effect = person("income_elasticity_lsr", period)
income_effect = person(
"income_elasticity_behavioral_response", period
)
else:
income_effect = 0
original_emp = person("employment_income_before_lsr", period)
original_self_emp = person("self_employment_income_before_lsr", period)
original_emp = person(
"employment_income_before_behavioral_response", period
)
original_self_emp = person(
"self_employment_income_before_behavioral_response", period
)
original_earnings = original_emp + original_self_emp
lsr_relative_change = np.where(
original_earnings == 0, 0, income_effect / original_earnings
Expand All @@ -55,14 +63,22 @@ class weekly_hours_worked_behavioural_response_substitution_elasticity(
definition_period = YEAR

def formula(person, period, parameters):
original = person("weekly_hours_worked_before_lsr", period)
original = person(
"weekly_hours_worked_before_behavioral_response", period
)
lsr = person("labor_supply_behavioral_response", period)
if (lsr != 0).any():
substitution_effect = person("substitution_elasticity_lsr", period)
substitution_effect = person(
"substitution_elasticity_behavioral_response", period
)
else:
substitution_effect = 0
original_emp = person("employment_income_before_lsr", period)
original_self_emp = person("self_employment_income_before_lsr", period)
original_emp = person(
"employment_income_before_behavioral_response", period
)
original_self_emp = person(
"self_employment_income_before_behavioral_response", period
)
original_earnings = original_emp + original_self_emp
lsr_relative_change = np.where(
original_earnings == 0, 0, substitution_effect / original_earnings
Expand Down
8 changes: 4 additions & 4 deletions policyengine_us/variables/input/income.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
label = "Income"


class employment_income_before_lsr(Variable):
class employment_income_before_behavioral_response(Variable):
value_type = float
entity = Person
label = "employment income before labor supply responses"
Expand All @@ -13,7 +13,7 @@ class employment_income_before_lsr(Variable):
uprating = "calibration.gov.irs.soi.employment_income"


class self_employment_income_before_lsr(Variable):
class self_employment_income_before_behavioral_response(Variable):
value_type = float
entity = Person
label = "self-employment income before labor supply responses"
Expand All @@ -30,7 +30,7 @@ class employment_income(Variable):
unit = USD
definition_period = YEAR
adds = [
"employment_income_before_lsr",
"employment_income_before_behavioral_response",
"employment_income_behavioral_response",
]
uprating = "calibration.gov.irs.soi.employment_income"
Expand All @@ -44,7 +44,7 @@ class self_employment_income(Variable):
documentation = "Self-employment non-farm income."
definition_period = YEAR
adds = [
"self_employment_income_before_lsr",
"self_employment_income_before_behavioral_response",
"self_employment_income_behavioral_response",
]
uprating = "calibration.gov.irs.soi.self_employment_income"
Expand Down

0 comments on commit 7203d33

Please sign in to comment.