Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ clean:
rm -f tmd/storage/output/preimpute_tmd.csv.gz
rm -f tmd/storage/output/make_data_*.log

# Each of the five build stages below tees its stdout+stderr to a
# Each of the six build stages below tees its stdout+stderr to a
# per-stage log file in tmd/storage/output/. On-screen output during
# `make data` is unchanged; the log files are a byproduct so that any
# warnings emitted during the run (pandas, numpy, taxcalc, scipy,
Expand All @@ -31,20 +31,26 @@ clean:
# appear silent on the terminal until the buffer flushes. The `-u`
# flag preserves the pre-tee behavior of seeing progress in real time.

tmd/storage/output/tmd.csv.gz:
python -u tmd/create_taxcalc_input_variables.py 2>&1 \
| tee tmd/storage/output/make_data_tmd.log
# The two growth-factors files are built first because subsequent
# stages use growfactors.csv as the Policy-parameter indexing file and
# tmd_growfactors.csv as the Records-variable extrapolation file.

tmd/storage/output/tmd_weights.csv.gz:
python -u tmd/create_taxcalc_sampling_weights.py 2>&1 \
| tee tmd/storage/output/make_data_weights.log

tmd/storage/output/tmd_growfactors.csv:
tmd/storage/output/growfactors.csv:
python -u tmd/create_raw_growth_factors.py 2>&1 \
| tee tmd/storage/output/make_data_raw_growfactors.log

tmd/storage/output/tmd_growfactors.csv: tmd/storage/output/growfactors.csv
python -u tmd/create_taxcalc_growth_factors.py 2>&1 \
| tee tmd/storage/output/make_data_tmd_growfactors.log

tmd/storage/output/tmd.csv.gz: tmd/storage/output/tmd_growfactors.csv
python -u tmd/create_taxcalc_input_variables.py 2>&1 \
| tee tmd/storage/output/make_data_tmd.log

tmd/storage/output/tmd_weights.csv.gz: tmd/storage/output/tmd.csv.gz
python -u tmd/create_taxcalc_sampling_weights.py 2>&1 \
| tee tmd/storage/output/make_data_weights.log

tmd/storage/output/cached_files:
python -u tmd/create_taxcalc_cached_files.py 2>&1 \
| tee tmd/storage/output/make_data_cached.log
Expand All @@ -54,9 +60,10 @@ tmd/storage/output/preimpute_tmd.csv.gz:
| tee tmd/storage/output/make_data_preimpute.log

.PHONY=tmd_files
tmd_files: tmd/storage/output/tmd.csv.gz \
tmd/storage/output/tmd_weights.csv.gz \
tmd_files: tmd/storage/output/growfactors.csv \
tmd/storage/output/tmd_growfactors.csv \
tmd/storage/output/tmd.csv.gz \
tmd/storage/output/tmd_weights.csv.gz \
tmd/storage/output/cached_files \
tmd/storage/output/preimpute_tmd.csv.gz

Expand Down
36 changes: 10 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,16 @@ For Tax-Calculator results generated when using these TMD input files,
see [this
folder](https://github.com/PSLmodels/Tax-Calculator/tree/master/taxcalc/cli/input_data_tests).

The **current TMD version is 2.1.4**, which was released on July 13,
2026, and is the same as TMD version 2.1.3 except that a new version
of `scikit-learn` (1.9.0), which fixed a bug in its weighted imputation
algorithm, is used (see #534 for details). Tax-Calculator version 6.8.1
or higher is required to generate the TMD files.

When using version 2.1.4 to generate **sub-national weights**, there
will be (presumably small) differences from the sub-national weights
generated using earlier versions. Note that the 118th Congressional
district weight fingerprints have not yet been updated.

The earlier TMD 2.0.0 version introduced the following significant
improvements:
- generate national, state, and Congressional district, input files
for **2022**:
[#470](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/470)
[#471](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/471)
[#472](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/472)
[#473](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/473)
[#474](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/474)
- improve the selection of CPS tax units to represent nonfilers:
[#438](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/438)
- vastly improve the reweighting algorithm:
[#416](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/416)
- impute values for three variables used in new OBBBA deductions:
[#397](https://github.com/PSLmodels/tax-microdata-benchmarking/pull/397)
The **current TMD version is 2.2.0**, which was released on September
9, 2026, and is the same as TMD version 2.1.4 except that post-2022
weights are grown using a CBO returns projection (rather than using a
CBO population projection as in prior versions). See PR #546 for details.

When using version 2.2.0 to generate national or sub-national weights,
the 2022 weights (and hence, the fingerprints) are the same as for
version 2.1.4. However, all the post-2022 weights are larger. Note
that the 118th Congressional district weight fingerprints have not
been updated.

## Usage instructions

Expand Down
24 changes: 2 additions & 22 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import pandas as pd
import taxcalc
from tmd.storage import STORAGE_FOLDER
from tmd.storage import TMD_VARIABLES_PATH
from tmd.imputation_assumptions import TAXYEAR

# convert all numpy floating-point execeptions into errors
Expand Down Expand Up @@ -50,24 +50,4 @@ def tests_folder():

@pytest.fixture(scope="session")
def tmd_variables():
return pd.read_csv(STORAGE_FOLDER / "output" / "tmd.csv.gz")


@pytest.fixture(scope="session")
def tmd_variables_path():
return STORAGE_FOLDER / "output" / "tmd.csv.gz"


@pytest.fixture(scope="session")
def tmd_weights_path():
return STORAGE_FOLDER / "output" / "tmd_weights.csv.gz"


@pytest.fixture(scope="session")
def tmd_growfactors_path():
return STORAGE_FOLDER / "output" / "tmd_growfactors.csv"


@pytest.fixture(scope="session")
def policy_growfactors_path():
return STORAGE_FOLDER / "output" / "growfactors.csv"
return pd.read_csv(TMD_VARIABLES_PATH)
28 changes: 14 additions & 14 deletions tests/expect_tmd_revenues
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ TMD vs CBO aggregate individual income tax revenue

YEAR ACTUAL EXPECT PCTDIFF
2022 2149.4 2149.6 -0.01
2023 2218.1 2171.9 +2.13
2024 2407.9 2408.4 -0.02
2025 2491.9 2493.7 -0.07
2026 2637.4 2665.0 -1.04
2027 2697.5 2776.8 -2.85
2028 2757.4 2860.0 -3.59
2029 2898.3 3039.1 -4.63
2030 3049.1 3196.7 -4.62
2031 3171.2 3310.2 -4.20
2032 3302.1 3452.3 -4.35
2033 3438.6 3599.4 -4.47
2034 3581.8 3760.4 -4.75
2035 3730.6 3929.3 -5.06
2023 2241.8 2171.9 +3.22
2024 2441.3 2408.4 +1.36
2025 2520.3 2493.7 +1.07
2026 2685.1 2665.0 +0.75
2027 2760.4 2776.8 -0.59
2028 2835.8 2860.0 -0.85
2029 2991.6 3039.1 -1.56
2030 3158.0 3196.7 -1.21
2031 3302.8 3310.2 -0.22
2032 3451.1 3452.3 -0.03
2033 3604.9 3599.4 +0.15
2034 3765.1 3760.4 +0.12
2035 3932.5 3929.3 +0.08

sum over 2022-2035 of squared PCTDIFF: iitax = 174.05
sum over 2022-2035 of squared PCTDIFF: iitax = 19.00
18 changes: 9 additions & 9 deletions tests/expected_tax_exp_2022_data
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
YR,KIND,EST= 2023 paytax 1431.0
YR,KIND,EST= 2023 iitax 2332.3
YR,KIND,EST= 2023 ctc 129.6
YR,KIND,EST= 2023 eitc 66.9
YR,KIND,EST= 2023 social_security_partial_taxability 47.3
YR,KIND,EST= 2023 niit -47.4
YR,KIND,EST= 2023 cgqd_tax_preference 179.6
YR,KIND,EST= 2023 qbid 55.0
YR,KIND,EST= 2023 salt 23.8
YR,KIND,EST= 2023 paytax 1446.3
YR,KIND,EST= 2023 iitax 2357.2
YR,KIND,EST= 2023 ctc 130.9
YR,KIND,EST= 2023 eitc 67.7
YR,KIND,EST= 2023 social_security_partial_taxability 47.8
YR,KIND,EST= 2023 niit -47.8
YR,KIND,EST= 2023 cgqd_tax_preference 181.6
YR,KIND,EST= 2023 qbid 55.6
YR,KIND,EST= 2023 salt 24.0
29 changes: 15 additions & 14 deletions tests/test_imputed_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import numpy as np
import pytest
import taxcalc
from tmd.storage import (
POLICY_GROWFACTORS_PATH,
TMD_GROWFACTORS_PATH,
TMD_VARIABLES_PATH,
TMD_WEIGHTS_PATH,
)
from tmd.imputation_assumptions import TAXYEAR, SOI_IITAX_SPEC
from tests.conftest import create_tmd_records


@pytest.mark.obbba_deduction
def test_obbba_deduction_tax_benefits(
tmd_variables_path,
tmd_weights_path,
tmd_growfactors_path,
policy_growfactors_path,
):
def test_obbba_deduction_tax_benefits():
"""
Estimate percent of tax-units affected by each new tax deduction and
average size of the 2026 dollar effect among those affected.
Expand Down Expand Up @@ -56,7 +57,7 @@ def actual_results(rdf, bdf):
# https://taxpolicycenter.org/taxvox/
# budget-laws-tax-cuts-overtime-and-
# tips-are-popular-few-will-benefit
"exp_totben_2022": 24.42,
"exp_totben_2022": 24.86,
"exp_affpct_2022": 8.78,
"exp_affben_2022": 1423,
},
Expand All @@ -73,7 +74,7 @@ def actual_results(rdf, bdf):
# https://taxpolicycenter.org/taxvox/
# budget-laws-tax-cuts-overtime-and-
# tips-are-popular-few-will-benefit
"exp_totben_2022": 7.19,
"exp_totben_2022": 7.32,
"exp_affpct_2022": 2.64,
"exp_affben_2022": 1397,
},
Expand All @@ -88,7 +89,7 @@ def actual_results(rdf, bdf):
# because the Tax Policy Center did not provide any
# statistics for this new deduction. However, see the
# following reform analysis for FOUR reforms.
"exp_totben_2022": 8.14,
"exp_totben_2022": 8.28,
"exp_affpct_2022": 12.84,
"exp_affben_2022": 324,
},
Expand All @@ -108,7 +109,7 @@ def actual_results(rdf, bdf):
# https://taxpolicycenter.org/model-estimates/T25-0257
# Note that the $1081 TPC estimate is derived by dividing
# the all-unit average of $320 by the 0.296 affpct.
"exp_totben_2022": 60.07,
"exp_totben_2022": 61.15,
"exp_affpct_2022": 28.97,
"exp_affben_2022": 1061,
},
Expand All @@ -119,13 +120,13 @@ def actual_results(rdf, bdf):
]
# create Tax-Calculator Records object
recs = create_tmd_records(
data_path=tmd_variables_path,
weights_path=tmd_weights_path,
growfactors_path=tmd_growfactors_path,
data_path=TMD_VARIABLES_PATH,
weights_path=TMD_WEIGHTS_PATH,
growfactors_path=TMD_GROWFACTORS_PATH,
)
# create baseline_sim Calculator object for simyear and get its output
policy_gf = taxcalc.GrowFactors(
growfactors_filename=str(policy_growfactors_path)
growfactors_filename=str(POLICY_GROWFACTORS_PATH)
)
pol = taxcalc.Policy(gfactor=policy_gf)
pol.implement_reform(SOI_IITAX_SPEC)
Expand Down
25 changes: 12 additions & 13 deletions tests/test_revenue_levels_cbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@
import pytest
import taxcalc

from tmd.storage import (
POLICY_GROWFACTORS_PATH,
TMD_GROWFACTORS_PATH,
TMD_WEIGHTS_PATH,
)
from tmd.imputation_assumptions import TAXYEAR, SOI_IITAX_SPEC

# Per-year relative tolerance for all three aggregates.
RELTOL = {
2022: 0.01,
2026: 0.02,
2031: 0.05,
2036: 0.06,
2026: 0.01,
2031: 0.01,
2036: 0.01,
}

VARIABLES = ("n_returns_mil", "agi_bil", "iitax_bil")
Expand All @@ -37,29 +42,23 @@
TAXYEAR != 2022,
reason="expected values are calibrated to TAXYEAR=2022",
)
def test_revenue_levels_cbo(
tests_folder,
tmd_variables,
tmd_weights_path,
tmd_growfactors_path,
policy_growfactors_path,
):
def test_revenue_levels_cbo(tests_folder, tmd_variables):
epath = tests_folder / "expected_cbo_levels_2022_data.yaml"
with open(epath, "r", encoding="utf-8") as f:
exp = yaml.safe_load(f)

policy_gf = taxcalc.GrowFactors(
growfactors_filename=str(policy_growfactors_path)
growfactors_filename=str(POLICY_GROWFACTORS_PATH)
)
pol = taxcalc.Policy(gfactor=policy_gf)
pol.implement_reform(SOI_IITAX_SPEC)
rec = taxcalc.Records(
data=tmd_variables,
start_year=TAXYEAR,
gfactors=taxcalc.GrowFactors(
growfactors_filename=str(tmd_growfactors_path)
growfactors_filename=str(TMD_GROWFACTORS_PATH)
),
weights=str(tmd_weights_path),
weights=str(TMD_WEIGHTS_PATH),
adjust_ratios=None,
exact_calculations=True,
weights_scale=1.0,
Expand Down
20 changes: 10 additions & 10 deletions tests/test_soi_sanity_2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@
import pandas as pd
import taxcalc

from tmd.storage import STORAGE_FOLDER
from tmd.storage import (
STORAGE_FOLDER,
POLICY_GROWFACTORS_PATH,
TMD_GROWFACTORS_PATH,
TMD_WEIGHTS_PATH,
)
from tmd.imputation_assumptions import TAXYEAR, SOI_IITAX_SPEC

SOI_YEAR = 2022
Expand Down Expand Up @@ -81,28 +86,23 @@ def _soi_target(soi_df, variable, count):
return float(rows["Value"].iloc[0])


def test_soi_sanity_2022(
tmd_variables,
tmd_weights_path,
tmd_growfactors_path,
policy_growfactors_path,
):
def test_soi_sanity_2022(tmd_variables):
"""Five weighted 2022 totals from TMD within 1% of SOI targets."""
# Run TaxCalc at TAXYEAR to obtain c00100 (AGI) and iitax. e00200,
# e26270, and s006 are available directly on the input frame but
# using the post-calc_all arrays keeps one consistent source for
# all five aggregates.
policy_gf = taxcalc.GrowFactors(
growfactors_filename=str(policy_growfactors_path)
growfactors_filename=str(POLICY_GROWFACTORS_PATH)
)
pol = taxcalc.Policy(gfactor=policy_gf)
pol.implement_reform(SOI_IITAX_SPEC)
recs = taxcalc.Records(
data=tmd_variables,
start_year=TAXYEAR,
weights=str(tmd_weights_path),
weights=str(TMD_WEIGHTS_PATH),
gfactors=taxcalc.GrowFactors(
growfactors_filename=str(tmd_growfactors_path)
growfactors_filename=str(TMD_GROWFACTORS_PATH)
),
adjust_ratios=None,
exact_calculations=True,
Expand Down
Loading
Loading