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

Exclude students from the SNAP unit with certain exceptions. #4975

Merged
merged 15 commits into from
Oct 15, 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
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:
- Exclude students from the SNAP unit with certain exceptions.
14 changes: 14 additions & 0 deletions policyengine_us/parameters/gov/usda/snap/max_allotment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ main:
- range(1, 9)
label: SNAP max allotment
CONTIGUOUS_US:
0:
2020-10-01: 0
1:
2020-10-01: 204
2021-01-01: 234
Expand Down Expand Up @@ -64,6 +66,8 @@ main:
2023-10-01: 1_751
2024-10-01: 1_756
AK_URBAN:
0:
2020-10-01: 0
1:
2020-10-01: 251
2021-01-01: 289
Expand Down Expand Up @@ -121,6 +125,8 @@ main:
2023-10-01: 2_246
2024-10-01: 2_265
AK_RURAL_1:
0:
2020-10-01: 0
1:
2020-10-01: 320
2021-01-01: 368
Expand Down Expand Up @@ -178,6 +184,8 @@ main:
2023-10-01: 2_865
2024-10-01: 2_888
AK_RURAL_2:
0:
2020-10-01: 0
1:
2020-10-01: 390
2021-01-01: 448
Expand Down Expand Up @@ -235,6 +243,8 @@ main:
2023-10-01: 3_487
2024-10-01: 3_516
GU:
0:
2020-10-01: 0
1:
2020-10-01: 300
2021-01-01: 345
Expand Down Expand Up @@ -292,6 +302,8 @@ main:
2023-10-01: 2_581
2024-10-01: 2_588
HI:
0:
2020-10-01: 0
1:
2020-10-01: 375
2021-01-01: 432
Expand Down Expand Up @@ -349,6 +361,8 @@ main:
2023-10-01: 3_166
2024-10-01: 3_102
VI:
0:
2020-10-01: 0
1:
2020-10-01: 262
2021-01-01: 301
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
description: The United States includes students in the Supplemental Nutrition Assistance Program unit if their age falls into the following range.
brackets:
- threshold:
2018-01-01: 0
amount:
2018-01-01: true
- threshold:
2018-01-01: 18
amount:
2018-01-01: false
- threshold:
2018-01-01: 50
amount:
2018-01-01: true

metadata:
type: single_amount
threshold_unit: year
amount_unit: bool
label: SNAP student age eligibility threshold
reference:
- title: 7 U.S. Code § 2015 - Eligibility disqualifications (e)(1)
href: https://www.law.cornell.edu/uscode/text/7/2015
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
description: The United States includes students who work more than this number of weekly hours in the Supplemental Nutrition Assistance Program unit.

values:
2005-01-01: 20

metadata:
unit: hours
label: SNAP student working hours threshold
period: week
reference:
- title: 7 U.S. Code § 2015 - Eligibility disqualifications (e)(4)
href: https://www.law.cornell.edu/uscode/text/7/2015
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,75 @@
meets_snap_categorical_eligibility: false
output:
is_snap_eligible: true

- name: One ineligible student present
period: 2022
input:
people:
person1:
is_snap_ineligible_student: false
person2:
is_snap_ineligible_student: false
person3:
is_snap_ineligible_student: true
spm_units:
spm_unit1:
members: [person1, person2, person3]
meets_snap_gross_income_test: true
meets_snap_net_income_test: true
meets_snap_asset_test: true
meets_snap_categorical_eligibility: false
output:
is_snap_eligible: true

- name: Every person ineligible
period: 2022
input:
people:
person1:
is_snap_ineligible_student: true
person2:
is_snap_ineligible_student: true
person3:
is_snap_ineligible_student: true
spm_units:
spm_unit1:
members: [person1, person2, person3]
meets_snap_gross_income_test: true
meets_snap_net_income_test: true
meets_snap_asset_test: true
meets_snap_categorical_eligibility: false
output:
is_snap_eligible: false

- name: Single ineligible student
period: 2022
input:
people:
person1:
is_snap_ineligible_student: true
spm_units:
spm_unit1:
members: [person1]
meets_snap_gross_income_test: true
meets_snap_net_income_test: true
meets_snap_asset_test: true
meets_snap_categorical_eligibility: false
output:
is_snap_eligible: false

- name: Single eligible person
period: 2022
input:
people:
person1:
is_snap_ineligible_student: false
spm_units:
spm_unit1:
members: [person1]
meets_snap_gross_income_test: true
meets_snap_net_income_test: true
meets_snap_asset_test: true
meets_snap_categorical_eligibility: false
output:
is_snap_eligible: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- name: Student who does not meet any exemption criteria
period: 2022
input:
is_full_time_student: true
age: 18
is_disabled: false
weekly_hours_worked: false
is_parent: false
output:
is_snap_ineligible_student: true

- name: Student who is under the age limit
period: 2022
input:
is_full_time_student: true
age: 17
is_disabled: false
weekly_hours_worked: false
is_parent: false
output:
is_snap_ineligible_student: false
50 changes: 50 additions & 0 deletions policyengine_us/tests/policy/baseline/gov/usda/snap/snap_unit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- name: Household with one ineligible studnet
period: 2022
input:
people:
person1:
is_snap_ineligible_student: false
person2:
is_snap_ineligible_student: false
person3:
is_snap_ineligible_student: true
spm_units:
spm_unit1:
members: [person1, person2, person3]
spm_unit_size: 3
output:
snap_unit_size: 2

- name: Everybody eligible
period: 2022
input:
people:
person1:
is_snap_ineligible_student: false
person2:
is_snap_ineligible_student: false
person3:
is_snap_ineligible_student: false
spm_units:
spm_unit1:
members: [person1, person2, person3]
spm_unit_size: 3
output:
snap_unit_size: 3

- name: No eligible people
period: 2022
input:
people:
person1:
is_snap_ineligible_student: true
person2:
is_snap_ineligible_student: true
person3:
is_snap_ineligible_student: true
spm_units:
spm_unit1:
members: [person1, person2, person3]
spm_unit_size: 3
output:
snap_unit_size: 0
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ def formula(spm_unit, period, parameters):
categorical_eligibility = spm_unit(
"meets_snap_categorical_eligibility", period
)
return normal_eligibility | categorical_eligibility
person = spm_unit.members
eligible_person_present = spm_unit.any(
~person("is_snap_ineligible_student", period)
)
return (
normal_eligibility | categorical_eligibility
) & eligible_person_present
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from policyengine_us.model_api import *


class is_snap_ineligible_student(Variable):
value_type = bool
entity = Person
label = "Is an ineligible student for SNAP"
documentation = "Whether this person is an ineligible student for SNAP and can not be counted towards the household size"
definition_period = YEAR
reference = "https://www.law.cornell.edu/uscode/text/7/2015"

def formula(person, period, parameters):
student = person(
"is_full_time_student", period
) # part-time students should also count
age = person("age", period)
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", period)
hours_eligible = hours_worked >= p.working_hours_threshold
# The parental status applies to children under 6 (under 12
# if no care available)
# Single parents with children under 12 are also eligible
is_parent = person("is_parent", period)
return student & ~(
age_eligible | disabled | hours_eligible | is_parent
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ def formula(spm_unit, period, parameters):
period
).gov.usda.snap.income.deductions.standard
state_group = spm_unit.household("state_group_str", period)
capped_household_size = min_(spm_unit("spm_unit_size", period), 6)
unit = spm_unit("snap_unit_size", period)
capped_household_size = clip(unit, 1, 6)
return standard_deductions[state_group][capped_household_size]
2 changes: 1 addition & 1 deletion policyengine_us/variables/gov/usda/snap/income/snap_fpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class snap_fpg(Variable):
definition_period = MONTH

def formula(spm_unit, period, parameters):
n = spm_unit("spm_unit_size", period.this_year)
n = spm_unit("snap_unit_size", period.this_year)
state_group = spm_unit.household("state_group_str", period.this_year)
year = period.start.year
month = period.start.month
Expand Down
4 changes: 2 additions & 2 deletions policyengine_us/variables/gov/usda/snap/snap_max_allotment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def formula(spm_unit, period, parameters):
MAX_HOUSEHOLD_SIZE_UNDER_MAIN = 8
snap_region = spm_unit.household("snap_region_str", period)
household_size = min_(
spm_unit("spm_unit_size", period), MAX_HOUSEHOLD_SIZE_UNDER_MAIN
spm_unit("snap_unit_size", period), MAX_HOUSEHOLD_SIZE_UNDER_MAIN
)
additional_members = max_(
0,
spm_unit("spm_unit_size", period) - MAX_HOUSEHOLD_SIZE_UNDER_MAIN,
spm_unit("snap_unit_size", period) - MAX_HOUSEHOLD_SIZE_UNDER_MAIN,
)
main_allotment = max_allotments.main[snap_region][household_size]
additional_allotment = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def formula(spm_unit, period, parameters):
]

# Minimum benefits only apply to households up to a certain size.
size = spm_unit("spm_unit_size", period)
size = spm_unit("snap_unit_size", period)
eligible = size <= snap.min_allotment.maximum_household_size
min_allotment = eligible * min_allotment.rate * relevant_max_allotment

Expand Down
15 changes: 15 additions & 0 deletions policyengine_us/variables/gov/usda/snap/snap_unit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from policyengine_us.model_api import *


class snap_unit_size(Variable):
value_type = int
entity = SPMUnit
label = "SNAP unit"
definition_period = YEAR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would work right?

Suggested change
adds = ["spm_unit_size"]
subtracts = ["is_snap_ineligible_student"]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I capped the formula at 0 to avoid negative values for units with just one student

def formula(spm_unit, period, parameters):
unit_size = spm_unit("spm_unit_size", period)
person = spm_unit.members
ineligible_student = person("is_snap_ineligible_student", period)
ineligible_students = spm_unit.sum(ineligible_student)
return max_(unit_size - ineligible_students, 0)
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def formula(person, period, parameters):
# male and has some children in their own household (provided in the
# CPS).
female = person("is_female", period)
has_children = person("own_children_in_household", period) > 0
has_children = person("is_parent", period)
return ~female & has_children
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def formula(person, period, parameters):
# (provided in the CPS).
# 2. Breastfeeding (user-input).
female = person("is_female", period)
has_children = person("own_children_in_household", period) > 0
has_children = person("is_parent", period)
breastfeeding = person("is_breastfeeding", period)
return breastfeeding | (female & has_children)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from policyengine_us.model_api import *


class is_parent(Variable):
value_type = bool
entity = Person
label = "Is a parent"
definition_period = YEAR

def formula(person, period, parameters):
return person("own_children_in_household", period) > 0
Loading