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

Change _lsr to _behavioral_response #5321

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: minor
changes:
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 @@ -67,7 +67,7 @@
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 @@

def formula(person, period, parameters):
lsr = parameters(period).gov.simulation.labor_supply_responses
employment_income = person("employment_income_before_lsr", period)
employment_income = person(

Check warning on line 80 in policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py#L80

Added line #L80 was not covered by tests
"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 @@
1_726e3,
]

earnings = person("employment_income_before_lsr", period) + person(
"self_employment_income_before_lsr", period
)
earnings = person(

Check warning on line 141 in policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py#L141

Added line #L141 was not covered by tests
"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 @@
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 @@

def formula(person, period, parameters):
lsr = parameters(period).gov.simulation.labor_supply_responses
employment_income = person("employment_income_before_lsr", period)
employment_income = person(

Check warning on line 193 in policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py#L193

Added line #L193 was not covered by tests
"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 @@ -241,22 +245,24 @@
"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",
],
)
simulation = person.simulation
Expand All @@ -280,9 +286,11 @@

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 @@
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 @@
definition_period = YEAR

def formula(person, period, parameters):
original = person("weekly_hours_worked_before_lsr", period)
original = person(

Check warning on line 33 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L33

Added line #L33 was not covered by tests
"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(

Check warning on line 38 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L38

Added line #L38 was not covered by tests
"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(

Check warning on line 43 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L43

Added line #L43 was not covered by tests
"employment_income_before_behavioral_response", period
)
original_self_emp = person(

Check warning on line 46 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L46

Added line #L46 was not covered by tests
"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 @@
definition_period = YEAR

def formula(person, period, parameters):
original = person("weekly_hours_worked_before_lsr", period)
original = person(

Check warning on line 66 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L66

Added line #L66 was not covered by tests
"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(

Check warning on line 71 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L71

Added line #L71 was not covered by tests
"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(

Check warning on line 76 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L76

Added line #L76 was not covered by tests
"employment_income_before_behavioral_response", period
)
original_self_emp = person(

Check warning on line 79 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L79

Added line #L79 was not covered by tests
"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