PolicyEngine / policyengine-us

The PolicyEngine US Python package contains a rules engine of the US tax-benefit system, and microdata generation for microsimulation analysis.
https://policyengine.org/us
GNU Affero General Public License v3.0
103 stars 176 forks source link

MO itemized deduction logic #1617

Closed martinholmer closed 1 year ago

martinholmer commented 1 year ago

After the merge of PR #1609, I have found many 2021 MO income tax differences between PolicyEngineUS and TAXSIM35 in the $1000 to $1100 range. Below I present a test case that is an example of these differences. Then, after some explanation, I pose a question about how the PolicyEngineUS deductions are computed. It appears as if @nmrodelo and @MaxGhenis developed the original MO income tax code, so I'm hoping they can answer my question.

Here is the test case:

- name: Tax unit with taxsimid 1615 in q21.its.csv and q21.ots.csv
  absolute_error_margin: 0.01
  period: 2021
  input:
    people:
      person1:
        is_tax_unit_head: true
        age: 51
        employment_income: 159_010
        social_security: 21_000
        real_estate_taxes: 16_000
        interest_expense: 26_000
        ssi: 0  # not in TAXSIM35
        state_supplement: 0  # not in TAXSIM35
        wic: 0  # not in TAXSIM35
      person2:
        is_tax_unit_spouse: true
        age: 51
        employment_income: 151_010
        ssi: 0  # not in TAXSIM35
        state_supplement: 0  # not in TAXSIM35
        wic: 0  # not in TAXSIM35
    spm_units:
      spm_unit:
        members: [person1, person2]
        snap: 0  # not in TAXSIM35
        tanf: 0  # not in TAXSIM35
    tax_units:
      tax_unit:
        members: [person1, person2]
        premium_tax_credit: 0  # not in TAXSIM35
    households:
      household:
        members: [person1, person2]
        state_code: MO
  output:  # expected results from TAXSIM35 12/08/22 version
    mo_income_tax: 15_279.20

=============================== FAILURES ===================================
_____________________________ test session _________________________________
/Users/mrh/work/Policy-Engine-US/MO/q21-id1615.yaml:
  Test 'Tax unit with taxsimid 1615 in q21.its.csv and q21.ots.csv':
    mo_income_tax@2021: [14187.773] differs from 15279.2001953125
                        with an absolute margin [1091.4268] > 0.01
======================= short test summary info ============================
FAILED q21-id1615.yaml::
========================== 1 failed in 1.55s ===============================

Here is a side-by-side comparison of TAXSIM35 and PolicyEngineUS output for this case:

taxsimid 1615
state_code 26 Missouri

TAXSIM35 FITax Summary:      PolicyEngineUS
tfica             22742.67   
AGI              327870.00   327870.00
SSinAGI           17850.00
Deductions        36000.00
QBID                  0.00
TaxInc           291870.00   291870.00
AMT                   0.00
itax_pre_credits  58090.80    58090.80
itax              58090.80    58090.80

TAXSIM35 SITax Summary:
HHinc 331020.00              PolicyEngineUS  
AGI               327870.00 [176860.00 151010.00]  mo_adjusted_gross_income OK
itmded             37990.96
                                  0.00  mo_federal_income_tax_deduction(default)
                                  0.00  mo_pension_and_ss_or_ssd_deduction
                              58202.49  mo_itemized_deductions(default)
taxinc            289879.04  269667.50 [145464.34 124203.16]  mo_taxable_income
                                       DIFF=20211.54
itax_pre_credits   15279.20   14187.78 [  7667.94   6519.84]  mo_it_pre_credits
                                       DIFF= 1091.42
credits                0.00       0.00
itax               15279.20   14187.77 DIFF= 1091.43

Notice that the two models are in exact agreement on US income taxes (and all subtotals).

Also, note that the two models are in exact agreement on MO adjusted gross income.

The difference between the two models is in the MO deductions with TAXSIM35 generating $37,990.96 and PolicyEngineUS generating $58,202.49, a difference of $20,211.54.

After reviewing the PolicyEngineUS code, I have not been able to figure out where the $58,202.49 is coming from. My question is this: can someone walk me through the calculations for this test case showing how the test case inputs produce the MO deduction amount of $58,202.49?

Thanks in advance for your explanation.

nmrodelo commented 1 year ago

Hi @martinholmer -

taking a look right now and pulled out the relevant part of the computation tree here:

mo_itemized_deductions<2021, (default)> = [48202.49]
          MO<2021, (default)> = [ True]
          itemized_taxable_income_deductions<2021, (default)> = [26000.]
            charitable_deduction<2021, (default)> = [0.]
            interest_deduction<2021, (default)> = [26000.]
            salt_deduction<2021, (default)> = [0.]
            medical_expense_deduction<2021, (default)> = [0.]
            casualty_loss_deduction<2021, (default)> = [0.]
          misc_deduction<2021, (default)> = [0.]
          employee_social_security_tax<2021, (default)> = [8853.6 8853.6]  ***
            taxable_earnings_for_social_security<2021, (default)> = [142800. 142800.]
          employee_medicare_tax<2021, (default)> = [2305.645 2189.645]  ***
            payroll_tax_gross_wages<2021, (default)> = [159010. 151010.]
          self_employment_tax<2021, (default)> = [0. 0.]

these numbers will be slightly different from what you are seeing because I have not pulled all the way up-to-date, but it seems that social security and medicare would be the culprits (marked with ***). There may be an error with how social security taxes are computed, as both individuals have social security tax liability, but only one is receiving it.

martinholmer commented 1 year ago

@nmrodelo, Thanks for the trace output. But I'm confused about why you are not getting the same amount for MO deductions as I am getting. What version of PolicyEngineUS are you using?