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
100 stars 174 forks source link

Fix erroneous federal AMT calculation #4775

Closed martinholmer closed 1 month ago

martinholmer commented 1 month ago

The following simple 2022 test case illustrates a major flaw in the federal AMT calculations that can cause PolicyEngine-US to generate federal income tax amounts that are many thousands of dollars larger than the correct amounts. This flaw causes errors as far back at 2018 (see #4769).

The characterization of this situation as a bug seems sensible because online TAXSIM-35 and Tax-Calculator 4.2.0 and 2022 Turbo Tax are all in agreement that this test case has a zero AMT. PolicyEngine-US 1.28.0, however, generates a federal AMT amount equal to $7,538.50.

That this bug exists is not particularly surprising because the developers of the alternative_minimum_tax formula did not specify any unit tests for it. (At least, I can't find any tests when doing a recursive grep operation over the source code tree.). Also, the 2022 federal income testing done in issue #1773 never considered test cases with more than $10K in qualified dividends or more than $10K in long-term capital gains.

First, I show the YAML file containing the test case. Then I show several screenshots from Turbo Tax processing a make-believe person like the test case.

The YAML test case:

- name: Single Texan with no children, $150K wages, $50K QDIV, $50K LTCG
  absolute_error_margin: 0.01
  period: 2022
  input:
    people:
      person1:
        age: 50
        employment_income: 150_000
        qualified_dividend_income: 50_000
        long_term_capital_gains: 50_000
    spm_units:
      spm_unit:
        members: [person1]
    tax_units:
      tax_unit:
        members: [person1]
    households:
      household:
        members: [person1]
        state_code: TX
  output:
    # expected output from online TAXSIM-35
    # which is at: https://taxsim.nber.org/taxsim35/
    #
    adjusted_gross_income: 250_000
    taxable_income: 237_050
    net_investment_income_tax: 1_900
    income_tax: 43_627.50

##############################################################################
# ABOVE TEST IS IN A FILE NAMED case22.yaml
# TEST ENVIRONMENT:
#   % pip list | grep policyengine
#   policyengine-core             2.21.8
#   policyengine-us               1.28.0
# RESULTS FROM RUNNING THIS TEST ARE AS FOLLOWS:
#
#=============================== FAILURES ===================================
#_____________________________ test session _________________________________
#/Users/mrh/work/.../case22.yaml:
#  Test 'Single Texan with no children, $150K wages, $50K QDIV, $50K LTCG':
#    income_tax@2022: [51166.] differs from 43627.5
#                     with an absolute margin [7538.5] > 0.01
#======================= short test summary info ============================
#FAILED case22.yaml::
#========================== 1 failed in 3.19s ===============================
#Trace output is in file: case22.trace
#% grep alternative_minimum_tax case22.trace
#         alternative_minimum_tax<2022, (default)> = [7538.5]
# So, the income tax difference is caused solely by the AMT difference.

2022 Turbo Tax screenshots:

Screenshot 2024-07-23 at 11 38 10 AM

.

Screenshot 2024-07-23 at 11 46 40 AM

.

And finally, federal Form 6251:

Screenshot 2024-07-23 at 11 52 24 AM Screenshot 2024-07-23 at 11 52 45 AM Screenshot 2024-07-23 at 11 53 23 AM Screenshot 2024-07-23 at 11 54 18 AM
MaxGhenis commented 1 month ago

Does this relate to https://github.com/PSLmodels/Tax-Calculator/pull/2785?

martinholmer commented 1 month ago

@MaxGhenis asked in PR #4775:

Does this relate to https://github.com/PSLmodels/Tax-Calculator/pull/2785?

No.

PavelMakarchuk commented 1 month ago

Thank you @martinholmer for filing -

The issue here is that we do not consider capital gains taxes when computing the final AMT amount in Part II Line 10 - will fix now

martinholmer commented 1 month ago

@PavelMakarchuk said in issue #4775:

The issue here is that we do not consider capital gains taxes when computing the final AMT amount in Part II Line 10 - will fix now.

Good that you've identified the problem in the code.

MaxGhenis commented 1 month ago

This reform simulates repealing AMT by raising the exemption to $1T: https://policyengine.org/us/policy?focus=policyOutput.policyBreakdown&reform=62899&region=enhanced_us&timePeriod=2024&baseline=2

Before merging #4815, this produced a $153 billion cost in 2024; now it's $0.8 billion.

Do we now need to adjust other parameters to simulate AMT repeal? We could also try neutralizing from a notebook.

Other reforms still work correctly, e.g. TRAFWA.

PavelMakarchuk commented 1 month ago

I wonder if the previous effect was correct - the easiest way it to set the rate to 0 (both brackets). This would produce an impact of $1.4 billion - which is what we get if we repeal the AMT as a structural reform

MaxGhenis commented 1 month ago

TPC projects that AMT raises $6.3 billion in 2023

I would expect our projection to be lower as we haven't fully incorporated important deductions like the property tax component of SALT and charitable deductions. So $1.4 billion seems OK.

Do you know why an infinite exemption differs from zeroing out the rates though?

PavelMakarchuk commented 1 month ago

TPC projects that AMT raises $6.3 billion in 2023

I would expect our projection to be lower as we haven't fully incorporated important deductions like the property tax component of SALT and charitable deductions. So $1.4 billion seems OK.

Do you know why an infinite exemption differs from zeroing out the rates though?

There is a cap on the exemption amounts for filers who are below 18