diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..ef0d0ca9d63 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,5 @@ +- bump: minor + changes: + added: + - Code coverage for SPM Unit. + - Renamed spm_unit_net_income to spm_resources diff --git a/docs/gov/irs/credits/cdcc.ipynb b/docs/gov/irs/credits/cdcc.ipynb index 6f84cd62825..b008fadebfe 100644 --- a/docs/gov/irs/credits/cdcc.ipynb +++ b/docs/gov/irs/credits/cdcc.ipynb @@ -162613,7 +162613,7 @@ "\n", "class ignore_reported(Reform):\n", " def apply(self):\n", - " self.neutralize_variable(\"spm_unit_net_income_reported\")\n", + " self.neutralize_variable(\"spm_resources_reported\")\n", "\n", "\n", "class neutralize_cdcc(Reform):\n", @@ -162625,8 +162625,8 @@ "sim_no_cdcc = Microsimulation((ignore_reported, neutralize_cdcc), year=2020)\n", "\n", "(\n", - " sim.calc(\"spm_unit_net_income\", period=2022).sum()\n", - " - sim_no_cdcc.calc(\"spm_unit_net_income\", period=2022).sum()\n", + " sim.calc(\"spm_resources\", period=2022).sum()\n", + " - sim_no_cdcc.calc(\"spm_resources\", period=2022).sum()\n", ") / 1e6" ] } diff --git a/docs/gov/irs/credits/clean-vehicle.ipynb b/docs/gov/irs/credits/clean-vehicle.ipynb index b4ff4a188b8..8e75f4871ec 100644 --- a/docs/gov/irs/credits/clean-vehicle.ipynb +++ b/docs/gov/irs/credits/clean-vehicle.ipynb @@ -85340,7 +85340,7 @@ " return pd.DataFrame(\n", " dict(\n", " employment_income=sim.calc(\"employment_income\")[0],\n", - " spm_unit_net_income=sim.calc(\"spm_unit_net_income\")[0],\n", + " spm_resources=sim.calc(\"spm_resources\")[0],\n", " credit=sim.calc(\"new_clean_vehicle_credit\")[0],\n", " adults=adults,\n", " children=children,\n", @@ -85362,7 +85362,7 @@ "wide = df.pivot(\n", " index=[\"employment_income\", \"adults\", \"children\"],\n", " columns=\"purchased_qualifying_new_clean_vehicle\",\n", - " values=\"spm_unit_net_income\",\n", + " values=\"spm_resources\",\n", ").reset_index()\n", "wide[\"benefit\"] = wide[True] - wide[False]\n", "\n", @@ -170708,7 +170708,7 @@ " return pd.DataFrame(\n", " dict(\n", " employment_income=sim.calc(\"employment_income\")[0],\n", - " spm_unit_net_income=sim.calc(\"spm_unit_net_income\")[0],\n", + " spm_resources=sim.calc(\"spm_resources\")[0],\n", " credit=sim.calc(\"used_clean_vehicle_credit\")[0],\n", " adults=adults,\n", " children=children,\n", @@ -170734,7 +170734,7 @@ "wide = df.pivot(\n", " index=[\"employment_income\", \"adults\", \"children\"],\n", " columns=\"purchased_qualifying_used_clean_vehicle\",\n", - " values=\"spm_unit_net_income\",\n", + " values=\"spm_resources\",\n", ").reset_index()\n", "\n", "wide[\"benefit\"] = wide[True] - wide[False]\n", diff --git a/docs/gov/states/de/tax-benefit.ipynb b/docs/gov/states/de/tax-benefit.ipynb index 8232db7c9a2..16340869b70 100644 --- a/docs/gov/states/de/tax-benefit.ipynb +++ b/docs/gov/states/de/tax-benefit.ipynb @@ -25334,14 +25334,14 @@ " sim.add_household(name=\"household\", members=members, state_code=\"DE\")\n", " sim.vary(\"employment_income\", max=100_000, step=100)\n", " employment_income = sim.calc(\"employment_income\")[0]\n", - " spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + " spm_resources = sim.calc(\"spm_resources\")[0].round()\n", " mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", " )\n", " return pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " adults=adults,\n", " children=str(children),\n", @@ -25359,7 +25359,7 @@ "\n", "LABELS = dict(\n", " employment_income=\"Employment income\",\n", - " spm_unit_net_income=\"Net income\",\n", + " spm_resources=\"Net income\",\n", " mtr=\"Marginal tax rate\",\n", " adults=\"Adults\",\n", " children=\"Children\",\n", @@ -25370,7 +25370,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " color=\"children\",\n", " animation_frame=\"adults\",\n", " labels=LABELS,\n", @@ -53643,14 +53643,14 @@ "\n", "sim.vary(\"employment_income\", max=100_000, step=100)\n", "employment_income = sim.calc(\"employment_income\")[0]\n", - "spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + "spm_resources = sim.calc(\"spm_resources\")[0].round()\n", "mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", ")\n", "df = pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " )\n", ")\n", @@ -53658,7 +53658,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " labels=LABELS,\n", " title=\"Net income for a single person aged 65 in Delaware\",\n", ")\n", diff --git a/docs/gov/states/ma/tax-benefit.ipynb b/docs/gov/states/ma/tax-benefit.ipynb index da587c8266b..f41e6062a63 100644 --- a/docs/gov/states/ma/tax-benefit.ipynb +++ b/docs/gov/states/ma/tax-benefit.ipynb @@ -25349,14 +25349,14 @@ " sim.add_household(name=\"household\", members=members, state_code=\"MA\")\n", " sim.vary(\"employment_income\", max=100_000, step=100)\n", " employment_income = sim.calc(\"employment_income\")[0]\n", - " spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + " spm_resources = sim.calc(\"spm_resources\")[0].round()\n", " mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", " )\n", " return pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " adults=adults,\n", " children=str(children),\n", @@ -25374,7 +25374,7 @@ "\n", "LABELS = dict(\n", " employment_income=\"Employment income\",\n", - " spm_unit_net_income=\"Net income\",\n", + " spm_resources=\"Net income\",\n", " mtr=\"Marginal tax rate\",\n", " adults=\"Adults\",\n", " children=\"Children\",\n", @@ -25385,7 +25385,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " color=\"children\",\n", " animation_frame=\"adults\",\n", " labels=LABELS,\n", @@ -53658,14 +53658,14 @@ "\n", "sim.vary(\"employment_income\", max=100_000, step=100)\n", "employment_income = sim.calc(\"employment_income\")[0]\n", - "spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + "spm_resources = sim.calc(\"spm_resources\")[0].round()\n", "mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", ")\n", "df = pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " )\n", ")\n", @@ -53673,7 +53673,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " labels=LABELS,\n", " title=\"Net income for a single person aged 65 in Massachusetts\",\n", ")\n", diff --git a/docs/gov/states/mo/tax-benefit.ipynb b/docs/gov/states/mo/tax-benefit.ipynb index 0ff28e1e392..79d5c24dc3c 100644 --- a/docs/gov/states/mo/tax-benefit.ipynb +++ b/docs/gov/states/mo/tax-benefit.ipynb @@ -25332,14 +25332,14 @@ " sim.add_household(name=\"household\", members=members, state_code=\"MO\")\n", " sim.vary(\"employment_income\", max=100_000, step=100)\n", " employment_income = sim.calc(\"employment_income\")[0]\n", - " spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + " spm_resources = sim.calc(\"spm_resources\")[0].round()\n", " mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", " )\n", " return pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " adults=adults,\n", " children=str(children),\n", @@ -25357,7 +25357,7 @@ "\n", "LABELS = dict(\n", " employment_income=\"Employment income\",\n", - " spm_unit_net_income=\"Net income\",\n", + " spm_resources=\"Net income\",\n", " mtr=\"Marginal tax rate\",\n", " adults=\"Adults\",\n", " children=\"Children\",\n", @@ -25368,7 +25368,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " color=\"children\",\n", " animation_frame=\"adults\",\n", " labels=LABELS,\n", @@ -53620,14 +53620,14 @@ "\n", "sim.vary(\"employment_income\", max=100_000, step=100)\n", "employment_income = sim.calc(\"employment_income\")[0]\n", - "spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + "spm_resources = sim.calc(\"spm_resources\")[0].round()\n", "mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", ")\n", "df = pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " )\n", ")\n", @@ -53635,7 +53635,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " labels=LABELS,\n", " title=\"Net income for a single person aged 65 in Missouri\",\n", ")\n", diff --git a/docs/gov/states/ny/cdcc.ipynb b/docs/gov/states/ny/cdcc.ipynb index 27b200c22a8..6d12a930f84 100644 --- a/docs/gov/states/ny/cdcc.ipynb +++ b/docs/gov/states/ny/cdcc.ipynb @@ -9962,7 +9962,7 @@ "\n", " class ignore_reported(Reform):\n", " def apply(self):\n", - " self.neutralize_variable(\"spm_unit_net_income_reported\")\n", + " self.neutralize_variable(\"spm_resources_reported\")\n", "\n", " class neutralize(Reform):\n", " def apply(self):\n", @@ -9974,10 +9974,10 @@ " )\n", " program_value = sim.calc(variable, period=policy_year).sum()\n", " baseline_net_income = sim.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " neutralized_net_income = sim_neutralized.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " budgetary_impact = neutralized_net_income - baseline_net_income\n", " return round(program_value / 1e6), round(budgetary_impact / 1e6)\n", diff --git a/docs/gov/states/ny/ctc.ipynb b/docs/gov/states/ny/ctc.ipynb index d3f4a75804e..038917f759c 100644 --- a/docs/gov/states/ny/ctc.ipynb +++ b/docs/gov/states/ny/ctc.ipynb @@ -49446,7 +49446,7 @@ "\n", " class ignore_reported(Reform):\n", " def apply(self):\n", - " self.neutralize_variable(\"spm_unit_net_income_reported\")\n", + " self.neutralize_variable(\"spm_resources_reported\")\n", "\n", " class neutralize(Reform):\n", " def apply(self):\n", @@ -49458,10 +49458,10 @@ " )\n", " program_value = sim.calc(variable, period=policy_year).sum()\n", " baseline_net_income = sim.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " neutralized_net_income = sim_neutralized.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " budgetary_impact = neutralized_net_income - baseline_net_income\n", " return round(program_value / 1e6), round(budgetary_impact / 1e6)\n", diff --git a/docs/gov/states/ny/eitc.ipynb b/docs/gov/states/ny/eitc.ipynb index f2bc0a26c05..4ead2f1f65d 100644 --- a/docs/gov/states/ny/eitc.ipynb +++ b/docs/gov/states/ny/eitc.ipynb @@ -31519,11 +31519,11 @@ "text": [ "/Users/maxghenis/opt/anaconda3/envs/py37/lib/python3.7/site-packages/policyengine_core/holders/holder.py:169: Warning:\n", "\n", - "You cannot set a value for the variable spm_unit_net_income_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n", + "You cannot set a value for the variable spm_resources_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n", "\n", "/Users/maxghenis/opt/anaconda3/envs/py37/lib/python3.7/site-packages/policyengine_core/holders/holder.py:169: Warning:\n", "\n", - "You cannot set a value for the variable spm_unit_net_income_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n", + "You cannot set a value for the variable spm_resources_reported, as it has been neutralized. The value you provided ([28327. 76811. 15350. ... 17282. 78821. 53152.]) will be ignored.\n", "\n" ] }, @@ -31559,7 +31559,7 @@ "\n", " class ignore_reported(Reform):\n", " def apply(self):\n", - " self.neutralize_variable(\"spm_unit_net_income_reported\")\n", + " self.neutralize_variable(\"spm_resources_reported\")\n", "\n", " class neutralize(Reform):\n", " def apply(self):\n", @@ -31571,10 +31571,10 @@ " )\n", " program_value = sim.calc(variable, period=policy_year).sum()\n", " baseline_net_income = sim.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " neutralized_net_income = sim_neutralized.calc(\n", - " \"spm_unit_net_income\", period=policy_year\n", + " \"spm_resources\", period=policy_year\n", " ).sum()\n", " budgetary_impact = neutralized_net_income - baseline_net_income\n", " return round(program_value / 1e6), round(budgetary_impact / 1e6)\n", diff --git a/docs/gov/states/ny/tax-benefit.ipynb b/docs/gov/states/ny/tax-benefit.ipynb index 14c5e6b9e82..78c5135d6bb 100644 --- a/docs/gov/states/ny/tax-benefit.ipynb +++ b/docs/gov/states/ny/tax-benefit.ipynb @@ -25466,14 +25466,14 @@ " sim.add_household(name=\"household\", members=members, state_code=\"NY\")\n", " sim.vary(\"employment_income\", max=100_000, step=100)\n", " employment_income = sim.calc(\"employment_income\")[0]\n", - " spm_unit_net_income = sim.calc(\"spm_unit_net_income\")[0].round()\n", + " spm_resources = sim.calc(\"spm_resources\")[0].round()\n", " mtr = 1 - sim.deriv(\n", - " \"spm_unit_net_income\", \"employment_income\", wrt_target=\"head\"\n", + " \"spm_resources\", \"employment_income\", wrt_target=\"head\"\n", " )\n", " return pd.DataFrame(\n", " dict(\n", " employment_income=employment_income,\n", - " spm_unit_net_income=spm_unit_net_income,\n", + " spm_resources=spm_resources,\n", " mtr=mtr,\n", " adults=adults,\n", " children=str(children),\n", @@ -25491,7 +25491,7 @@ "\n", "LABELS = dict(\n", " employment_income=\"Employment income\",\n", - " spm_unit_net_income=\"Net income\",\n", + " spm_resources=\"Net income\",\n", " mtr=\"Marginal tax rate\",\n", " adults=\"Adults\",\n", " children=\"Children\",\n", @@ -25502,7 +25502,7 @@ "fig = px.line(\n", " df,\n", " \"employment_income\",\n", - " \"spm_unit_net_income\",\n", + " \"spm_resources\",\n", " color=\"children\",\n", " animation_frame=\"adults\",\n", " labels=LABELS,\n", diff --git a/policyengine_us/data/datasets/acs/acs.py b/policyengine_us/data/datasets/acs/acs.py index e5b1646bee8..0c7f43d3aa8 100644 --- a/policyengine_us/data/datasets/acs/acs.py +++ b/policyengine_us/data/datasets/acs/acs.py @@ -109,7 +109,7 @@ def add_person_variables(acs: h5py.File, person: DataFrame) -> None: def add_spm_variables(acs: h5py.File, spm_unit: DataFrame) -> None: - acs["spm_unit_net_income_reported"] = spm_unit.SPM_RESOURCES + acs["spm_resources_reported"] = spm_unit.SPM_RESOURCES acs["spm_unit_spm_threshold"] = spm_unit.SPM_POVTHRESHOLD diff --git a/policyengine_us/tests/policy/baseline/household/cliff_gap.yaml b/policyengine_us/tests/policy/baseline/household/cliff_gap.yaml index b224e7fbf75..212cd9dce7e 100644 --- a/policyengine_us/tests/policy/baseline/household/cliff_gap.yaml +++ b/policyengine_us/tests/policy/baseline/household/cliff_gap.yaml @@ -7,7 +7,7 @@ taxable_interest_income: 100_000 state_fips: 48 # TX output: - spm_unit_net_income: 151_539.00 + spm_resources: 151_539.00 household_net_income: 151_539.00 - name: household_net_income test TX-netinc-alt @@ -19,7 +19,7 @@ taxable_interest_income: 100_000 state_fips: 48 # TX output: - spm_unit_net_income: 152_670.00 + spm_resources: 152_670.00 household_net_income: 152_670.00 - name: cliff_gap test TX-cliff_gap diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/deep_poverty_gap.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/deep_poverty_gap.yaml new file mode 100644 index 00000000000..b67b0f96615 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/deep_poverty_gap.yaml @@ -0,0 +1,18 @@ +- name: Income > Deep Poverty Line + absolute_error_margin: 0.01 + period: 2021 + input: + spm_resources: 100_000 + deep_poverty_line: 20_000 + output: + deep_poverty_gap: 0 + +- name: Deep Poverty Line > Income + absolute_error_margin: 0.01 + period: 2021 + input: + spm_resources: 20_000 + deep_poverty_line: 100_000 + output: + deep_poverty_gap: 80_000 + diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/poverty_gap.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/poverty_gap.yaml new file mode 100644 index 00000000000..5bb29a2f9bf --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/poverty_gap.yaml @@ -0,0 +1,18 @@ +- name: Income > Poverty Line + absolute_error_margin: 0.01 + period: 2021 + input: + spm_resources: 100_000 + spm_unit_spm_threshold: 20_000 + output: + poverty_gap: 0 + +- name: Poverty Line > Income + absolute_error_margin: 0.01 + period: 2021 + input: + spm_resources: 20_000 + spm_unit_spm_threshold: 100_000 + output: + poverty_gap: 80_000 + diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.yaml new file mode 100644 index 00000000000..6cf473d812b --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.yaml @@ -0,0 +1,15 @@ +- name: Income less than poverty divided by 2 means in deep poverty. + period: 2021 + input: + spm_resources: 10_000 + spm_unit_spm_threshold: 20_001 + output: + spm_unit_is_in_deep_spm_poverty: true + +- name: Income equal to poverty threshold divded by 2 means not in deep poverty. + period: 2021 + input: + spm_resources: 10_000 + spm_unit_spm_threshold: 20_000 + output: + spm_unit_is_in_deep_spm_poverty: false diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_spm_poverty.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_spm_poverty.yaml index e64373026b4..e8ec1c92044 100644 --- a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_spm_poverty.yaml +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_is_in_spm_poverty.yaml @@ -1,7 +1,7 @@ - name: Income less than poverty means in poverty. period: 2021 input: - spm_unit_net_income: 10_000 + spm_resources: 10_000 spm_unit_spm_threshold: 10_001 output: spm_unit_is_in_spm_poverty: true @@ -9,7 +9,7 @@ - name: Income equal to poverty threshold means not in poverty. period: 2021 input: - spm_unit_net_income: 10_001 + spm_resources: 10_001 spm_unit_spm_threshold: 10_001 output: spm_unit_is_in_spm_poverty: false diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_net_income.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_net_income.yaml index 8fa0fa15040..25edfec7d53 100644 --- a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_net_income.yaml +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_net_income.yaml @@ -5,4 +5,4 @@ spm_unit_benefits: 2 spm_unit_taxes: 1 output: - spm_unit_net_income: 3 + 2 - 1 + spm_resources: 3 + 2 - 1 diff --git a/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_oecd_equiv_net_income.yaml b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_oecd_equiv_net_income.yaml new file mode 100644 index 00000000000..d95f8ab3ed5 --- /dev/null +++ b/policyengine_us/tests/policy/baseline/household/income/spm_unit/spm_unit_oecd_equiv_net_income.yaml @@ -0,0 +1,35 @@ +- name: Net income for family of 4. + period: 2021 + input: + people: + person1: {} + person2: {} + person3: {} + person4: {} + spm_units: + spm_unit: + members: [person1, person2, person3, person4] + spm_resources: 2_000 + output: + spm_unit_oecd_equiv_net_income: 1_000 + +- name: Net income for family of 9. + period: 2021 + input: + people: + person1: {} + person2: {} + person3: {} + person4: {} + person5: {} + person6: {} + person7: {} + person8: {} + person9: {} + spm_units: + spm_unit: + members: [person1, person2, person3, person4, person5, person6, person7, person8, person9] + spm_resources: 3_000 + output: + spm_unit_oecd_equiv_net_income: 1_000 + diff --git a/policyengine_us/variables/household/income/spm_unit/deep_poverty_gap.py b/policyengine_us/variables/household/income/spm_unit/deep_poverty_gap.py index 9bf994669a9..a87bd770a77 100644 --- a/policyengine_us/variables/household/income/spm_unit/deep_poverty_gap.py +++ b/policyengine_us/variables/household/income/spm_unit/deep_poverty_gap.py @@ -12,6 +12,6 @@ class deep_poverty_gap(Variable): definition_period = YEAR def formula(spm_unit, period, parameters): - income = spm_unit("spm_unit_net_income", period) + resources = spm_unit("spm_resources", period) deep_poverty_threshold = spm_unit("deep_poverty_line", period) - return max_(deep_poverty_threshold - income, 0) + return max_(deep_poverty_threshold - resources, 0) diff --git a/policyengine_us/variables/household/income/spm_unit/poverty_gap.py b/policyengine_us/variables/household/income/spm_unit/poverty_gap.py index 4c172bc077a..9baa2a8dd7e 100644 --- a/policyengine_us/variables/household/income/spm_unit/poverty_gap.py +++ b/policyengine_us/variables/household/income/spm_unit/poverty_gap.py @@ -10,6 +10,6 @@ class poverty_gap(Variable): definition_period = YEAR def formula(spm_unit, period, parameters): - income = spm_unit("spm_unit_net_income", period) + resources = spm_unit("spm_resources", period) poverty_threshold = spm_unit("spm_unit_spm_threshold", period) - return max_(poverty_threshold - income, 0) + return max_(poverty_threshold - resources, 0) diff --git a/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.py b/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.py index cdba4149ca5..53ca9390fb1 100644 --- a/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.py +++ b/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_deep_spm_poverty.py @@ -8,6 +8,6 @@ class spm_unit_is_in_deep_spm_poverty(Variable): definition_period = YEAR def formula(spm_unit, period, parameters): - income = spm_unit("spm_unit_net_income", period) + resources = spm_unit("spm_resources", period) poverty_threshold = spm_unit("spm_unit_spm_threshold", period) / 2 - return income < poverty_threshold + return resources < poverty_threshold diff --git a/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_spm_poverty.py b/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_spm_poverty.py index c0cc3a3ef68..3e4b1d56b4c 100644 --- a/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_spm_poverty.py +++ b/policyengine_us/variables/household/income/spm_unit/spm_unit_is_in_spm_poverty.py @@ -8,6 +8,6 @@ class spm_unit_is_in_spm_poverty(Variable): definition_period = YEAR def formula(spm_unit, period, parameters): - income = spm_unit("spm_unit_net_income", period) + resources = spm_unit("spm_resources", period) poverty_threshold = spm_unit("spm_unit_spm_threshold", period) - return income < poverty_threshold + return resources < poverty_threshold diff --git a/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income.py b/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income.py index 02b725a935d..1bb13a84aaa 100644 --- a/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income.py +++ b/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income.py @@ -1,7 +1,7 @@ from policyengine_us.model_api import * -class spm_unit_net_income(Variable): +class spm_resources(Variable): value_type = float entity = SPMUnit label = "Net income" diff --git a/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income_reported.py b/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income_reported.py index 4cc249fdb7b..1d867c0c37e 100644 --- a/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income_reported.py +++ b/policyengine_us/variables/household/income/spm_unit/spm_unit_net_income_reported.py @@ -1,7 +1,7 @@ from policyengine_us.model_api import * -class spm_unit_net_income_reported(Variable): +class spm_resources_reported(Variable): value_type = float entity = SPMUnit label = "Reported net income" diff --git a/policyengine_us/variables/household/income/spm_unit/spm_unit_oecd_equivalised_net_income.py b/policyengine_us/variables/household/income/spm_unit/spm_unit_oecd_equivalised_net_income.py index dee6936b90e..e0096fdadc9 100644 --- a/policyengine_us/variables/household/income/spm_unit/spm_unit_oecd_equivalised_net_income.py +++ b/policyengine_us/variables/household/income/spm_unit/spm_unit_oecd_equivalised_net_income.py @@ -13,6 +13,6 @@ class spm_unit_oecd_equiv_net_income(Variable): ) def formula(spm_unit, period, parameters): - number_of_people = spm_unit.nb_persons() - net_income = spm_unit("spm_unit_net_income", period) + number_of_people = spm_unit("spm_unit_size", period) + resources = spm_unit("spm_resources", period) return net_income / (number_of_people**0.5)