Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add (Tax change)/(Pre-reform after-tax income) to distributional tables #1375

Merged
merged 2 commits into from
May 24, 2017
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
4 changes: 3 additions & 1 deletion taxcalc/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
AmOppCreditParts, EducationTaxCredit,
NonrefundableCredits, C1040, IITAX,
BenefitSurtax, BenefitLimitation,
FairShareTax, LumpSumTax, ExpandIncome)
FairShareTax, LumpSumTax, ExpandIncome,
AfterTaxIncome)
from taxcalc.policy import Policy
from taxcalc.records import Records
from taxcalc.behavior import Behavior
Expand Down Expand Up @@ -217,6 +218,7 @@ def calc_all(self, zero_out_calc_vars=False):
FairShareTax(self.policy, self.records)
LumpSumTax(self.policy, self.records)
ExpandIncome(self.policy, self.records)
AfterTaxIncome(self.policy, self.records)

def increment_year(self):
"""
Expand Down
18 changes: 18 additions & 0 deletions taxcalc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,3 +1554,21 @@ def ExpandIncome(c00100, ptax_was, e02400, c02500,
employer_fica_share +
nontaxable_ubi) # universal basic income
return expanded_income


@iterate_jit(nopython=True)
def AfterTaxIncome(combined, expanded_income, aftertax_income):
"""
Calculate after tax income

Parameters
----------
combined: combined tax liability
expanded_income: expanded income

Returns
-------
aftertax_income: expanded_income - combined
"""
aftertax_income = expanded_income - combined
return aftertax_income
7 changes: 6 additions & 1 deletion taxcalc/records_variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,11 @@
"type": "float",
"desc": "Marginal income tax rate (in percentage terms) on extra taxpayer earnings (e00200p)",
"form": {}
}
},
"aftertax_income": {
"type": "float",
"desc": "After tax income. Equal to expanded_income - combined",
"form": {}
}
}
}
3 changes: 2 additions & 1 deletion taxcalc/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ def test_diff_table_sum_row(puf_1991, weights_1991):
groupby='small_income_bins')
tdiff2 = create_difference_table(calc1.records, calc2.records,
groupby='large_income_bins')
non_digit_cols = ['mean', 'perc_inc', 'perc_cut', 'share_of_change']
non_digit_cols = ['mean', 'perc_inc', 'perc_cut', 'share_of_change',
'aftertax_perc']
digit_cols = [x for x in tdiff1.columns.tolist() if
x not in non_digit_cols]
assert np.allclose(tdiff1[digit_cols][-1:], tdiff2[digit_cols][-1:])
Expand Down
10 changes: 9 additions & 1 deletion taxcalc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
BOKEH_AVAILABLE = False


STATS_COLUMNS = ['expanded_income', 'c00100', 'standard',
STATS_COLUMNS = ['expanded_income', 'c00100', 'aftertax_income', 'standard',
'c04470', 'c04600', 'c04800', 'taxbc', 'c62100', 'c09600',
'c05800', 'othertaxes', 'refund', 'c07100', 'iitax',
'payrolltax', 'combined', 's006']
Expand Down Expand Up @@ -491,6 +491,7 @@ def create_difference_table(recs1, recs2, groupby,
res2 = results(recs2)
baseline_income_measure = income_measure + '_baseline'
res2[baseline_income_measure] = res1[income_measure]
res2['aftertax_baseline'] = res1['aftertax_income']
income_measure = baseline_income_measure
if groupby == 'weighted_deciles':
pdf = add_weighted_income_bins(res2, num_bins=10,
Expand All @@ -513,9 +514,13 @@ def create_difference_table(recs1, recs2, groupby,
# Positive values are the magnitude of the tax increase
# Negative values are the magnitude of the tax decrease
res2['tax_diff'] = res2[income_to_present] - res1[income_to_present]
res2['aftertax_perc'] = res2['tax_diff'] / res2['aftertax_baseline']
diffs = means_and_comparisons('tax_diff',
pdf.groupby('bins', as_index=False),
(res2['tax_diff'] * res2['s006']).sum())
aftertax_perc = pdf.groupby('bins', as_index=False).apply(weighted_mean,
'aftertax_perc')
diffs['aftertax_perc'] = aftertax_perc
sum_row = get_sums(diffs)[diffs.columns.values.tolist()]
diffs = diffs.append(sum_row) # pylint: disable=redefined-variable-type
pd.options.display.float_format = '{:8,.0f}'.format
Expand All @@ -527,6 +532,9 @@ def create_difference_table(recs1, recs2, groupby,
srs_change = ['{0:.2f}%'.format(val * 100)
for val in diffs['share_of_change']]
diffs['share_of_change'] = pd.Series(srs_change, index=diffs.index)
srs_aftertax_perc = ['{0:.2f}%'.format(val * 100)
for val in diffs['aftertax_perc']]
diffs['aftertax_perc'] = pd.Series(srs_aftertax_perc, index=diffs.index)
# columns containing weighted values relative to the binning mechanism
non_sum_cols = [col for col in diffs.columns
if 'mean' in col or 'perc' in col]
Expand Down