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

[WIP]Adjust economic growth rates #368

Closed
wants to merge 6 commits into from
Closed
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
9 changes: 9 additions & 0 deletions taxcalc/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ def __init__(self, params=None, records=None, sync_years=True, **kwargs):
if self._records.current_year == 2009:
self.records.extrapolate_2009_puf()

inflation = self.params.default_inflation_rates()
while self._records.current_year < self._params.current_year:
self._records.factor_target(self.params._factor_target,
inflation,
self.records.current_year + 1)
self._records.increment_year()

print("Your data have been extrapolated to " +
Expand Down Expand Up @@ -131,6 +135,11 @@ def calc_all_test(self):
return totaldf

def increment_year(self):
self.records.factor_adjustment(self.params.factor_adjustment,
self.records.current_year + 1)
self.records.factor_target(self.params._factor_target,
self.params.default_inflation_rates(),
self.records.current_year + 1)
self.records.increment_year()
self.params.set_year(self.params.current_year + 1)

Expand Down
24 changes: 24 additions & 0 deletions taxcalc/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -1265,5 +1265,29 @@
"value": [ [400000, 450000, 225000, 425000, 450000, 225000],
[406750, 457600, 228800, 432200, 457600, 228800],
[413200, 464850, 223425, 439000, 464850, 223425]]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have some param validation that guarantees the user doesn't change both of these at the same time.

"_factor_adjustment":{
"long_name": "",
"description": "",
"irs_ref": "",
"start_year": 2013,
"col_var": "",
"row_var": "",
"row_label": ["2013"],
"cpi_inflated": false,
"col_label": "",
"value": [[0.0]]
},
"_factor_target":{
"long_name": "",
"description": "",
"irs_ref": "",
"start_year": 2013,
"col_var": "",
"row_var": "",
"row_label": ["2013"],
"cpi_inflated": false,
"col_label": "",
"value": [[0.0]]
}
}
46 changes: 46 additions & 0 deletions taxcalc/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,52 @@ def __init__(self,
def current_year(self):
return self._current_year

def factor_adjustment(self, percentage, year):
self.BF.AGDPN[year] += percentage * abs(self.BF.AGDPN[year] - 1)
self.BF.ATXPY[year] += percentage * abs(self.BF.ATXPY[year] - 1)
self.BF.AWAGE[year] += percentage * abs(self.BF.AWAGE[year] - 1)
self.BF.ASCHCI[year] += percentage * abs(self.BF.ASCHCI[year] - 1)
self.BF.ASCHCL[year] += percentage * abs(self.BF.ASCHCL[year] - 1)
self.BF.ASCHF[year] += percentage * abs(self.BF.ASCHF[year] - 1)
self.BF.AINTS[year] += percentage * abs(self.BF.AINTS[year] - 1)
self.BF.ADIVS[year] += percentage * abs(self.BF.ADIVS[year] - 1)
self.BF.ACGNS[year] += percentage * abs(self.BF.ACGNS[year] - 1)
self.BF.ASCHEI[year] += percentage * abs(self.BF.ASCHEI[year] - 1)
self.BF.ASCHEL[year] += percentage * abs(self.BF.ASCHEL[year] - 1)
self.BF.ABOOK[year] += percentage * abs(self.BF.ABOOK[year] - 1)
self.BF.ACPIU[year] += percentage * abs(self.BF.ACPIU[year] - 1)
self.BF.ACPIM[year] += percentage * abs(self.BF.ACPIM[year] - 1)
self.BF.ASOCSEC[year] += percentage * abs(self.BF.ASOCSEC[year] - 1)
self.BF.AUCOMP[year] += percentage * abs(self.BF.AUCOMP[year] - 1)
self.BF.AIPD[year] += percentage * abs(self.BF.AIPD[year] - 1)

def factor_target(self, target, inflation, year):
# 2013 is the start year of all parameter arrays. Hard coded for now.
# Need to be fixed later
if year >= 2013 and target[year - 2013] != 0:
# user inputs theoretically should be based on GDP
g = abs(self.BF.AGDPN[year] - 1)
ratio = (target[year - 2013] + inflation[year]) / g

# apply this ratio to all the dollar amount factors
self.BF.AGDPN[year] = ratio * abs(self.BF.AGDPN[year] - 1) + 1
self.BF.ATXPY[year] = ratio * abs(self.BF.ATXPY[year] - 1) + 1
self.BF.AWAGE[year] = ratio * abs(self.BF.AWAGE[year] - 1) + 1
self.BF.ASCHCI[year] = ratio * abs(self.BF.ASCHCI[year] - 1) + 1
self.BF.ASCHCL[year] = ratio * abs(self.BF.ASCHCL[year] - 1) + 1
self.BF.ASCHF[year] = ratio * abs(self.BF.ASCHF[year] - 1) + 1
self.BF.AINTS[year] = ratio * abs(self.BF.AINTS[year] - 1) + 1
self.BF.ADIVS[year] = ratio * abs(self.BF.ADIVS[year] - 1) + 1
self.BF.ACGNS[year] = ratio * abs(self.BF.ACGNS[year] - 1) + 1
self.BF.ASCHEI[year] = ratio * abs(self.BF.ASCHEI[year] - 1) + 1
self.BF.ASCHEL[year] = ratio * abs(self.BF.ASCHEL[year] - 1) + 1
self.BF.ABOOK[year] = ratio * abs(self.BF.ABOOK[year] - 1) + 1
self.BF.ACPIU[year] = ratio * abs(self.BF.ACPIU[year] - 1) + 1
self.BF.ACPIM[year] = ratio * abs(self.BF.ACPIM[year] - 1) + 1
self.BF.ASOCSEC[year] = ratio * abs(self.BF.ASOCSEC[year] - 1) + 1
self.BF.AUCOMP[year] = ratio * abs(self.BF.AUCOMP[year] - 1) + 1
self.BF.AIPD[year] = ratio * abs(self.BF.AIPD[year] - 1) + 1

def increment_year(self):
self._current_year += 1
self.FLPDYR += 1
Expand Down