Skip to content

Commit

Permalink
Add variables
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Feb 9, 2024
1 parent 4d76a33 commit 8e3ae3d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
20 changes: 20 additions & 0 deletions cps_taxcalc_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,26 @@
"df = pd.read_csv(\"cps.csv.gz\")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2012, 2013, 2014])"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.dep"
]
},
{
"cell_type": "code",
"execution_count": 16,
Expand Down
68 changes: 67 additions & 1 deletion tax_microdata_benchmarking/create_flat_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,66 @@ class tc_EIC(TaxCalcVariableAlias):
label = "EITC-qualifying children"

def formula(tax_unit, period, parameters):
return add(tax_unit, period, ["is_eitc_qualifying_child"])
return min_(
add(tax_unit, period, ["is_eitc_qualifying_child"]),
3, # Must be capped in the data rather than the policy for Tax-Calculator
)


class tc_nu18(TaxCalcVariableAlias):
label = "number of people under 18"

def formula(tax_unit, period, parameters):
person = tax_unit.members
age = person("age", period)
return tax_unit.sum(age < 18)


class tc_n1820(TaxCalcVariableAlias):
label = "number of people 18-20"

def formula(tax_unit, period, parameters):
person = tax_unit.members
age = person("age", period)
return tax_unit.sum((age >= 18) & (age <= 20))


class tc_nu13(TaxCalcVariableAlias):
label = "number of people under 13"

def formula(tax_unit, period, parameters):
person = tax_unit.members
age = person("age", period)
return tax_unit.sum(age < 13)


class tc_nu06(TaxCalcVariableAlias):
label = "number of people under 6"

def formula(tax_unit, period, parameters):
person = tax_unit.members
age = person("age", period)
return tax_unit.sum(age < 6)


class tc_n24(TaxCalcVariableAlias):
label = "number of people eligible for the CTC"
adds = ["ctc_qualifying_children"]


class tc_elderly_dependents(TaxCalcVariableAlias):
label = "number of elderly dependents"

def formula(tax_unit, period, parameters):
person = tax_unit.members
age = person("age", period)
is_tax_unit_dependent = person("is_tax_unit_dependent", period)
return tax_unit.sum((age >= 65) * is_tax_unit_dependent)


class tc_f2441(TaxCalcVariableAlias):
label = "CDCC-qualifying children"
adds = ["count_cdcc_eligible"]


class taxcalc_extension(Reform):
Expand All @@ -150,6 +209,13 @@ def apply(self):
tc_s006,
tc_FLPDYR,
tc_EIC,
tc_nu18,
tc_n1820,
tc_nu13,
tc_nu06,
tc_n24,
tc_elderly_dependents,
tc_f2441,
)


Expand Down

0 comments on commit 8e3ae3d

Please sign in to comment.