From 7203d33995b46ed5222291420cb5950d01c77c93 Mon Sep 17 00:00:00 2001 From: Matty <31402450+Mshuning@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:24:20 +0000 Subject: [PATCH 1/3] Change `_lsr` to `_behavioral_response` Fixes #5258 --- changelog_entry.yaml | 4 ++ policyengine_us/system.py | 34 +++++++++---- .../student/is_snap_ineligible_student.yaml | 4 +- .../labor_supply_response.py | 48 +++++++++++-------- .../student/is_snap_ineligible_student.py | 4 +- .../income/person/weekly_hours_worked.py | 36 ++++++++++---- policyengine_us/variables/input/income.py | 8 ++-- 7 files changed, 92 insertions(+), 46 deletions(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..8b574a9a0b0 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added / fixed: + - Change _lsr to _behavioral_response. diff --git a/policyengine_us/system.py b/policyengine_us/system.py index e224cbe7e90..7124fef795f 100644 --- a/policyengine_us/system.py +++ b/policyengine_us/system.py @@ -106,14 +106,20 @@ 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) @@ -121,7 +127,9 @@ def __init__(self, *args, **kwargs): 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) @@ -160,14 +168,20 @@ 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) @@ -175,7 +189,9 @@ def __init__(self, *args, **kwargs): 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) @@ -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", ] diff --git a/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/student/is_snap_ineligible_student.yaml b/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/student/is_snap_ineligible_student.yaml index 3b2c6d2572b..51394b19b7a 100644 --- a/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/student/is_snap_ineligible_student.yaml +++ b/policyengine_us/tests/policy/baseline/gov/usda/snap/eligibility/student/is_snap_ineligible_student.yaml @@ -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 @@ -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 diff --git a/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py b/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py index 08dcd99ed48..edfe125b57c 100644 --- a/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py +++ b/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py @@ -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"] @@ -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"] @@ -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" @@ -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) @@ -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 ) @@ -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" @@ -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) @@ -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 @@ -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", ], ) @@ -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) diff --git a/policyengine_us/variables/gov/usda/snap/eligibility/student/is_snap_ineligible_student.py b/policyengine_us/variables/gov/usda/snap/eligibility/student/is_snap_ineligible_student.py index e235cc80c2f..d1de642908d 100644 --- a/policyengine_us/variables/gov/usda/snap/eligibility/student/is_snap_ineligible_student.py +++ b/policyengine_us/variables/gov/usda/snap/eligibility/student/is_snap_ineligible_student.py @@ -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) diff --git a/policyengine_us/variables/household/income/person/weekly_hours_worked.py b/policyengine_us/variables/household/income/person/weekly_hours_worked.py index 158cfe5f2a0..a1597f8d28b 100644 --- a/policyengine_us/variables/household/income/person/weekly_hours_worked.py +++ b/policyengine_us/variables/household/income/person/weekly_hours_worked.py @@ -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)" @@ -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 @@ -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 diff --git a/policyengine_us/variables/input/income.py b/policyengine_us/variables/input/income.py index 02a1995bdf3..b164af677b7 100644 --- a/policyengine_us/variables/input/income.py +++ b/policyengine_us/variables/input/income.py @@ -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" @@ -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" @@ -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" @@ -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" From 86189dcfd50de305405ffdb2ec27f73c583b4049 Mon Sep 17 00:00:00 2001 From: Matty <31402450+Mshuning@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:44:45 +0000 Subject: [PATCH 2/3] Change `_lsr` to `_behavioral_response` Fixes #5258 --- .../labor_supply_response/labor_supply_response.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py b/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py index edfe125b57c..c639f58dfe7 100644 --- a/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py +++ b/policyengine_us/variables/gov/simulation/labor_supply_response/labor_supply_response.py @@ -11,7 +11,9 @@ class relative_income_change(Variable): def formula(person, period, parameters): simulation = person.simulation - measurement_branch = simulation.get_branch("lsr_measurement") + measurement_branch = simulation.get_branch( + "behavioral_response_measurement" + ) baseline_branch = simulation.get_branch("baseline").get_branch( "baseline_behavioral_response_measurement" ) @@ -47,7 +49,9 @@ class relative_wage_change(Variable): def formula(person, period, parameters): simulation = person.simulation - measurement_branch = simulation.get_branch("lsr_measurement") + measurement_branch = simulation.get_branch( + "behavioral_response_measurement" + ) baseline_branch = simulation.get_branch("baseline").get_branch( "baseline_behavioral_response_measurement" ) @@ -224,7 +228,7 @@ def formula(person, period, parameters): return 0 measurement_branch = simulation.get_branch( - "lsr_measurement", clone_system=True + "behavioral_response_measurement", clone_system=True ) # A branch without LSRs baseline_branch = simulation.get_branch("baseline").get_branch( "baseline_behavioral_response_measurement", clone_system=True From a08e72d626e2e176f2173797d8a2380717a1389f Mon Sep 17 00:00:00 2001 From: Matty <31402450+Mshuning@users.noreply.github.com> Date: Fri, 1 Nov 2024 08:00:49 +0000 Subject: [PATCH 3/3] changelog --- changelog_entry.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 8b574a9a0b0..24b5d89551d 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,4 @@ - bump: minor changes: - added / fixed: + fixed: - Change _lsr to _behavioral_response.