Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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:
- New Jeresy TANF earned income disregards.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey fully excludes 50% earned income for person who enrolled TANF program over this amount of time.

metadata:
unit: month
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 7.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey fully excludes 100% of earned income for person who have enrolled in TANF program below this amount of time.

metadata:
unit: month
label: New Jersey TANF earned income deduction first month threshold
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey excludes this percentage of earned income for household enrolled in TANF for each additional month.

metadata:
unit: /1
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 0.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey excludes this percentage of earned income for 6 consecutive months for person who enrolles in TANF Program and continues work for more than 20h/week after the first month.

metadata:
unit: /1
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 0.75
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey fully excludes this percentage of earned income for person who enrolled in the first month of TANF program.

metadata:
unit: /1
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey excludes this percentage of earned income for household enrolled in TANF for each additional month.

metadata:
unit: /1
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 0.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New Jersey fully excludes this percentage of earned income for person who enrolled in the first month of TANF program.

metadata:
unit: /1
label: New Jersey TANF earned income deduction
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description: New York excludes this percentage of earned income for the purposes of its TANF program.

metadata:
unit: hours
label: New Jeresy TANF
reference:
- title: New Jersey Administrative Code(N.J.A.C 10:90-3.8)
href: https://advance.lexis.com/documentpage/teaserdocument/?pdmfid=1000516&crid=1e9b7e3d-233e-4b7c-898f-b53548066f3f&config=00JAA1YTg5OGJlYi04MTI4LTRlNjQtYTc4Yi03NTQxN2E5NmE0ZjQKAFBvZENhdGFsb2ftaXPxZTR7bRPtX1Jok9kz&pddocfullpath=%2Fshared%2Fdocument%2Fadministrative-codes%2Furn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pddocid=urn%3AcontentItem%3A5XKV-PW31-F22N-X2CF-00008-00&pdcontentcomponentid=234122&pdteaserkey=h1&pditab=allpods&ecomp=8s65kkk&earg=sr0&prid=187e8c01-622c-460c-be94-0bb33d5ca4d2

values:
2022-10-01: 20
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
- name: NJ countable earned income = gross earned income*(1-100%) for first month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 1
hours_worked: 2_080
output:
nj_tanf_countable_earned_income: 0

- name: NJ countable earned income = gross earned income*(1-75%) for applicant with weekly working hours over 20 in 2nd month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 2
hours_worked: 2_080
output:
nj_tanf_countable_earned_income: 1_500

- name: NJ countable earned income = gross earned income*(1-50%) for applicant with weekly working hours under 20 in 2nd month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 2
hours_worked: 988
output:
nj_tanf_countable_earned_income: 3_000

- name: NJ countable earned income = gross earned income*(1-75%) for applicant with weekly working hours over 20 in 7nd month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 7
hours_worked: 2_080
output:
nj_tanf_countable_earned_income: 1_500

- name: NJ countable earned income = gross earned income*(1-50%) for applicant with weekly working hours over 20 in 8nd month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 8
hours_worked: 2_080
output:
nj_tanf_countable_earned_income: 3_000

- name: NJ countable earned income = gross earned income*(1-75%) for applicant with weekly working hours over 20 in 2nd month.
period: 2023
input:
state_code: NJ
nj_tanf_gross_earned_income: 6_000
months_enrolled_in_tanf: 2
hours_worked: 1_040
output:
nj_tanf_countable_earned_income: 1_500
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
from policyengine_us.model_api import *


class nj_tanf_countable_earned_income(Variable):
value_type = float
entity = SPMUnit
label = "New Jersey TANF countable earned income"
unit = USD
definition_period = YEAR
defined_for = StateCode.NJ

def formula(spm_unit, period, parameters):
person = spm_unit.members
# Get gross earned income.
gross_earned_income = spm_unit("nj_tanf_gross_earned_income", period)
p = parameters(
period
).gov.states.nj.njdhs.tanf.income.earned_income_deduction
months_enrolled_in_tanf = person("months_enrolled_in_tanf", period)
weekly_hours_worked = person("weekly_hours_worked", period)
# New Jerset Admin Code 10:90-3.8(b)
person_meet_higher_work_hours_threshold = (
weekly_hours_worked >= p.work_hours_threshold
)
person_enrolled_in_tanf_for_first_month = (
months_enrolled_in_tanf <= p.first_month_threshold
)
person_enrolled_in_tanf_for_consecutive_months = (
months_enrolled_in_tanf <= p.consecutive_month_threshold
) and (months_enrolled_in_tanf > p.first_month_threshold)
person_enrolled_in_tanf_for_additional_months_with_work_hours_over_20 = (
months_enrolled_in_tanf > p.consecutive_month_threshold
and person_meet_higher_work_hours_threshold
)
person_enrolled_in_tanf_for_additional_months_with_Work_hours_below_20 = (
months_enrolled_in_tanf > p.first_month_threshold
)
if person_meet_higher_work_hours_threshold:
Copy link
Contributor

Choose a reason for hiding this comment

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

Since if statements aren't vectorized, we have to use where and select statements instead

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK. Is there an example shows how to use "select" statement or how to use "where" and "select" to achieve the function of "if" there? Originally, we are using a nested where function, it is not so readable although it passes all the test. That's why we are trying to use "if" function.

Copy link
Collaborator

@leogoldman leogoldman May 26, 2023

Choose a reason for hiding this comment

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

@xudonglai0426 see my comment in the review below. Select is much cleaner than nested where (although both are vectorized). if will still achieve the same result, but is not vectorized so it will be much slower.

if person_enrolled_in_tanf_for_first_month:
return gross_earned_income * (
1 - p.higher_work_hours.first_month_percent
)
elif person_enrolled_in_tanf_for_consecutive_months:
return gross_earned_income * (
1 - p.higher_work_hours.consecutive_month_percent
)
elif person_enrolled_in_tanf_for_additional_months_with_work_hours_over_20:
return gross_earned_income * (
1 - p.higher_work_hours.additional_percent
)
else:
if person_enrolled_in_tanf_for_first_month:
return gross_earned_income * (
1 - p.lower_work_hours.first_month_percent
)
elif person_enrolled_in_tanf_for_additional_months_with_Work_hours_below_20:
return gross_earned_income * (
1 - p.lower_work_hours.additional_percent
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from policyengine_us.model_api import *


class months_enrolled_in_tanf(Variable):
value_type = float
entity = Person
label = "Months enrolled in TANF"
definition_period = YEAR
unit = "month"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from policyengine_us.model_api import *


class hours_worked(Variable):
value_type = float
entity = Person
label = "Total amount of hours worked by this person"
definition_period = YEAR
unit = "hour"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from policyengine_us.model_api import *


class weekly_hours_worked(Variable):
value_type = float
entity = Person
label = "Weekly hours"
documentation = "Average weekly hours worked"
definition_period = YEAR
unit = "hour"
quantity_type = FLOW

def formula(person, period, parameters):
return person("hours_worked", period) / WEEKS_IN_YEAR