-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
[WIP] Distributing the Corporate Income Tax #286
Closed
Closed
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
d9f3dfd
starting on documentation
mmessick 7afe995
added variables to allow the calculation of the distribution of the c…
mmessick 6f7c3d3
removed unnecessary files
mmessick dc4a957
work in progress of implementing corporate income tax
mmessick 5a81635
updated records file
mmessick cf261a0
updated model to include passthrough income
mmessick 4e19d7b
updated to fix passthrough value
mmessick 30cdfa3
updates to the corp income tax, runs and gets values now
mmessick d65022f
update to tests
mmessick 79375cf
merge conflicts resolved
mmessick 374dbac
fixing error for travis build
mmessick ff0477c
added xml file for paper on the model
mmessick dd4768e
changed how I calculate percent to normal and supernomal by dividing …
mmessick f3bc51f
reStructuredText file of the paper explaining how to distribute
mmessick 44f4f0c
fixing merge conflicts
mmessick 446747c
fixing layout for reStructuredText
mmessick 0d06e45
figuring out format
mmessick c4e1151
formatting
mmessick 95bf395
new functionality for a table showing distribution by decile for the …
mmessick 1c4cfb4
fixing test suite to match
mmessick ad30a1c
minor changes
mmessick b6070c9
modified descrip of implementation
mmessick a9c1d07
changed doc location
mmessick 46d2b86
updated docs for this proposal
mmessick 992b44e
fixed typo
mmessick 166be4f
added bibliography to proposal
mmessick beac958
Merge branch 'master' of https://github.com/mmessick/Tax-Calculator i…
mmessick 1398cb0
merging
mmessick 40204a1
changed calculation of shares to normal and supernormal
mmessick bd66811
changed proposal to reflect changes in calculation
mmessick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
""" | ||
Testing file for calculate.py | ||
""" | ||
|
||
from pandas import DataFrame, concat | ||
from taxcalc.calculate import * | ||
from taxcalc.functions import * | ||
from taxcalc.records import * | ||
from taxcalc.parameters import * | ||
import taxcalc.parameters as parameters | ||
import numpy as np | ||
#from timer.timed_calculate import * | ||
|
||
|
||
def to_csv(fname, df): | ||
""" | ||
Save this dataframe to a CSV file with name 'fname' and containing | ||
a header with the column names of the dataframe. | ||
""" | ||
df.to_csv(fname, float_format= '%1.3f', sep=',', header=True, index=False) | ||
|
||
|
||
|
||
def run(puf=True): | ||
""" | ||
Run each function defined in calculate.py, saving the ouput to a CSV file. | ||
'puf' set to True by default, to use the 'puf2.csv' as an input | ||
|
||
For functions returning an additional non-global variable in addition | ||
to the DataFrame to be printed, one line saves the dataFrame to be printed | ||
first, and then saves the variable to be used by a following function second. | ||
""" | ||
|
||
# Create a Parameters object | ||
params = Parameters() | ||
|
||
# Create a Public Use File object | ||
|
||
tax_dta = pd.read_csv("puf.csv") | ||
|
||
blowup_factors = "./taxcalc/StageIFactors.csv" | ||
weights = "./taxcalc/WEIGHTS.csv" | ||
|
||
puf = Records(tax_dta, blowup_factors, weights) | ||
|
||
# Create a Calculator | ||
calc = Calculator(parameters=params, records=puf) | ||
# Dist_Corp_Inc_Tax(calc.params, calc.records) | ||
|
||
calc.corp_inc_tax() | ||
|
||
create_corpinctax_table(calc, "weighted_deciles", "weighted_sum") | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,8 @@ def __init__(self, params=None, records=None, sync_years=True, **kwargs): | |
print("Your data have beeen extrapolated to " | ||
+ str(self._records.current_year) + ".") | ||
|
||
self.corp_inc_tax() | ||
|
||
assert self._params.current_year == self._records.current_year | ||
|
||
@property | ||
|
@@ -142,6 +144,7 @@ def calc_all(self): | |
C1040(self.params, self.records) | ||
DEITC(self.params, self.records) | ||
OSPC_TAX(self.params, self.records) | ||
self.corp_inc_tax() | ||
ExpandIncome(self.params, self.records) | ||
|
||
def calc_all_test(self): | ||
|
@@ -175,6 +178,7 @@ def calc_all_test(self): | |
add_df(all_dfs, C1040(self.params, self.records)) | ||
add_df(all_dfs, DEITC(self.params, self.records)) | ||
add_df(all_dfs, OSPC_TAX(self.params, self.records)) | ||
self.corp_inc_tax() | ||
add_df(all_dfs, ExpandIncome(self.params, self.records)) | ||
totaldf = pd.concat(all_dfs, axis=1) | ||
return totaldf | ||
|
@@ -183,10 +187,65 @@ def increment_year(self): | |
self.records.increment_year() | ||
self.params.increment_year() | ||
|
||
""" | ||
TODO: Corporate Income Tax | ||
|
||
Change the json parameters for percent_labor, etc. | ||
For example, percent_labor is given to be 25%, but it is a long | ||
term affect for labor to bear the buren of this tax, so year 1 | ||
it should be 0 percent and then smoothly transition to 25 percent | ||
over the 10-year budget window | ||
""" | ||
|
||
@property | ||
def current_year(self): | ||
return self.params.current_year | ||
|
||
def corp_inc_tax(self): | ||
""" | ||
Calculates the aggregate dividends, capital gains, bonds, self-employed | ||
income, and compensation for this calculator's Records attribute | ||
Once calculated, uses these values to determine this caclulator's | ||
Records's shares of the corporate income tax burden | ||
""" | ||
|
||
self.records.agg_self_employed_and_pt = (self.records.e_and_p * self.records.s006).sum() | ||
|
||
self.records.agg_bonds = (self.records.bonds * self.records.s006).sum() | ||
|
||
self.records.agg_comp = (self.records.compensation * self.records.s006).sum() | ||
|
||
self.records.agg_capgains = (self.records.netcapgains * self.records.s006).sum() | ||
|
||
self.records.agg_dividends = (self.records.dividends * self.records.s006).sum() | ||
|
||
self.records.agg_normal = ((self.records.dividends * self.records.s006).sum() * .4 | ||
+ (self.records.netcapgains * self.records.s006).sum() * .4 | ||
+ (self.records.e_and_p * self.records.s006).sum() * .4 | ||
+ (self.records.bonds * self.records.s006).sum()) | ||
|
||
self.records.agg_supernormal = ((self.records.netcapgains * self.records.s006).sum() * .6 | ||
+ (self.records.dividends * self.records.s006).sum() * .6) | ||
|
||
myfunc = np.vectorize(Dist_Corp_Inc_Tax) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just apply the @vectorize decorator to |
||
|
||
revenue_collected = 1000000000000. | ||
percent_labor = .2 | ||
percent_supernormal = .6 | ||
percent_normal = .2 | ||
|
||
self.records.share_corptax_burden = myfunc(revenue_collected, | ||
percent_labor, percent_supernormal, | ||
percent_normal, self.records.agg_comp, self.records.agg_dividends, | ||
self.records.agg_capgains, self.records.agg_bonds, | ||
self.records.agg_self_employed_and_pt, self.records.agg_normal, | ||
self.records.normal, self.records.agg_supernormal, | ||
self.records.share_corptax_burden, self.records.supernormal, | ||
self.records.dividends, self.records.e_and_p, | ||
self.records.netcapgains, self.records.bonds, | ||
self.records.compensation) | ||
|
||
|
||
def mtr(self, income_type_string, diff=100): | ||
""" | ||
This method calculates the marginal tax rate for every record. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something left to do here still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we haven't decided on how we are going to impute it for future years