Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Apr 18, 2024
1 parent 83ae3f9 commit 063fd8d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
9 changes: 6 additions & 3 deletions tax_microdata_benchmarking/adjust_qbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def add_pt_w2_wages(df, time_period: int, verbose: bool = True):
2027: 0,
}

QBID_TOTAL_21 = 205.8 # From SOI 2021
QBID_TOTAL_21 = 205.8 # From SOI 2021

target = (
QBID_TOTAL_21
Expand Down Expand Up @@ -77,9 +77,12 @@ def expenditure_loss(scale):

return df


if __name__ == "__main__":
from tax_microdata_benchmarking.create_flat_file import create_stacked_flat_file
from tax_microdata_benchmarking.create_flat_file import (
create_stacked_flat_file,
)

df = create_stacked_flat_file(2021)

df = add_pt_w2_wages(df, 2021)
df = add_pt_w2_wages(df, 2021)
16 changes: 11 additions & 5 deletions tax_microdata_benchmarking/create_flat_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,16 @@ def create_stacked_flat_file(
print(
f"Adding pass-through W2 wages to the flat file for {target_year}"
)
qbi = np.maximum(0, combined_file.e00900 + combined_file.e26270 + combined_file.e02100 + combined_file.e27200)
combined_file["PT_binc_w2_wages"] = qbi * 0.357 # Solved in 2021 using adjust_qbi.py
qbi = np.maximum(
0,
combined_file.e00900
+ combined_file.e26270
+ combined_file.e02100
+ combined_file.e27200,
)
combined_file["PT_binc_w2_wages"] = (
qbi * 0.357
) # Solved in 2021 using adjust_qbi.py
return combined_file

return stacked_file
Expand Down Expand Up @@ -807,9 +815,7 @@ def summary_analytics(df):
]
latest_weights = None
for target_year in PRIORITY_YEARS[2:] + REMAINING_YEARS:
stacked_file = create_stacked_flat_file(
target_year=target_year
)
stacked_file = create_stacked_flat_file(target_year=target_year)
if target_year == 2021:
latest_weights = stacked_file.s006
elif target_year > 2021:
Expand Down
6 changes: 5 additions & 1 deletion tax_microdata_benchmarking/reweight.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def build_loss_matrix(df):
from tqdm import tqdm
from datetime import datetime

writer = SummaryWriter(log_dir=FOLDER / "calibration" / f"{time_period}_{datetime.now().isoformat()}")
writer = SummaryWriter(
log_dir=FOLDER
/ "calibration"
/ f"{time_period}_{datetime.now().isoformat()}"
)

for i in tqdm(range(10_000)):
optimizer.zero_grad()
Expand Down

0 comments on commit 063fd8d

Please sign in to comment.