Skip to content

Commit

Permalink
Merge branch 'master' into fix-response
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholmer committed Feb 13, 2018
2 parents cd48845 + 0f718eb commit f682979
Show file tree
Hide file tree
Showing 39 changed files with 250,261 additions and 216,104 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ include taxcalc/consumption.json
include taxcalc/records_variables.json
include taxcalc/cps.csv.gz
include taxcalc/cps_weights.csv.gz
include taxcalc/cps_benefits.csv.gz
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ for a complete commit history.
- Improve data quality of several existing CPS variables, which causes changes in CPS tax results
[[#1853](https://github.com/open-source-economics/Tax-Calculator/pull/1853)
by Anderson Frailey with assistance from Martin Holmer]
- Use 2011 PUF data (rather than the older 2009 PUF data), which causes changes in PUF tax results
[[#1871](https://github.com/open-source-economics/Tax-Calculator/pull/1871)
by Anderson Frailey and Martin Holmer], which requires new `puf.csv` input file with this information:
* Byte size: 54714632
* MD5 checksum: de4a59c9bce0a7d5e6c3110172237c9b

**New Features**
- Add ability to extrapolate imputed benefits and benefit-related policy parameters
[[#1719](https://github.com/open-source-economics/Tax-Calculator/pull/1719)
by Anderson Frailey]
- Add ability to specify the consumption value of in-kind benefits to be less than the government cost of providing in-kind benefits
[[#1863](https://github.com/open-source-economics/Tax-Calculator/pull/1863)
by Anderson Frailey]

**Bug Fixes**
- Improve handling of very high marginal tax rates in the `Behavior.response` method
Expand Down
4 changes: 2 additions & 2 deletions docs/cookbook.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ <h2 id="recipe00">Basic Recipe: Static Analysis of a Simple Reform</h2>
of the same <b>ignored</b> error message from deep inside the Pandas
library that is being used by Tax-Calculator. After conferring with
the Pandas developers, our expectation is these error messages will go
away when we upgrade to Pandas version 0.23.0, which is scheduled to
be released in February 2018, and which fixes a bug in the Pandas
away when we upgrade to Pandas version 0.23.0, which is now scheduled to
be released in April 2018, and which fixes a bug in the Pandas
library. Meanwhile, the error messages are annoying but harmless.
</em></p>

Expand Down
8 changes: 8 additions & 0 deletions docs/index.htmx
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,7 @@ section.</p>
<p><a href="#pol-refundable-credits">Refundable Credits</a></p>
<p><a href="#pol-surtaxes">Surtaxes</a></p>
<p><a href="#pol-ubi">Universal Basic Income</a></p>
<p><a href="#pol-benefits">Benefits</a></p>
<p><a href="#pol-other-parameters">Other Parameters</a></p>


Expand Down Expand Up @@ -1138,6 +1139,13 @@ section.</p>
<p><a href="#pol">Back to Section Contents</a></p>


<h3 id="pol-benefits">Benefits</h3>

<!-- Benefits @ Benefit Repeal -->

<p><a href="#pol">Back to Section Contents</a></p>


<h3 id="pol-other-parameters">Other Parameters</h3>

<!-- @ -->
Expand Down
16 changes: 13 additions & 3 deletions taxcalc/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
AmOppCreditParts, EducationTaxCredit,
NonrefundableCredits, C1040, IITAX,
BenefitSurtax, BenefitLimitation,
FairShareTax, LumpSumTax, ExpandIncome,
AfterTaxIncome)
FairShareTax, LumpSumTax, BenefitPrograms,
ExpandIncome, AfterTaxIncome)
from taxcalc.policy import Policy
from taxcalc.records import Records
from taxcalc.consumption import Consumption
Expand Down Expand Up @@ -65,7 +65,10 @@ class Calculator(object):
specifies consumption response assumptions used to calculate
"effective" marginal tax rates; default is None, which implies
no consumption responses assumed in marginal tax rate calculations;
when argument is an object it is copied for internal use
when argument is an object it is copied for internal use;
also specifies consumption value of in-kind benefis with no in-kind
consumption values specified implying consumption value is equal to
government cost of providing the in-kind benefits
behavior: Behavior class object
specifies behavioral responses used by Calculator; default is None,
Expand Down Expand Up @@ -177,6 +180,7 @@ def calc_all(self, zero_out_calc_vars=False):
"""
# conducts static analysis of Calculator object for current_year
assert self.__records.current_year == self.__policy.current_year
BenefitPrograms(self)
self._calc_one_year(zero_out_calc_vars)
BenefitSurtax(self)
BenefitLimitation(self)
Expand Down Expand Up @@ -282,6 +286,12 @@ def param(self, param_name, param_value=None):
else:
setattr(self.__policy, param_name, param_value)

def consump_param(self, param_name):
"""
Return value of named parameter in embedded Consumption object.
"""
return getattr(self.__consumption, param_name)

def behavior_has_response(self):
"""
Return True if embedded Behavior object has response;
Expand Down
32 changes: 22 additions & 10 deletions taxcalc/cli/tc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import sys
import argparse
import difflib
from taxcalc import TaxCalcIO
import taxcalc as tc


TEST_INPUT_FILENAME = 'test.csv'
Expand All @@ -23,12 +23,14 @@ def cli_tc_main():
"""
# pylint: disable=too-many-statements
# parse command-line arguments:
usage_str = 'tc INPUT TAXYEAR {}{}{}{}{}'.format(
'[--baseline BASELINE] [--reform REFORM] [--assump ASSUMP]\n',
usage_str = 'tc INPUT TAXYEAR {}{}{}{}{}{}{}'.format(
'[--baseline BASELINE]\n',
' ',
'[--reform REFORM] [--assump ASSUMP]\n',
' ',
'[--exact] [--tables] [--graphs] [--ceeu] [--dump] [--sqldb]\n',
' ',
'[--outdir] [--test]')
'[--outdir] [--test] [--version] [--help]')
parser = argparse.ArgumentParser(
prog='',
usage=usage_str,
Expand Down Expand Up @@ -89,7 +91,7 @@ def cli_tc_main():
'expected-utility (ceeu) of after-tax income '
'values for different '
'constant-relative-risk-aversion parameter '
'values, to be written to screen.'),
'values, to be written to stdout.'),
default=False,
action="store_true")
parser.add_argument('--dump',
Expand Down Expand Up @@ -125,10 +127,20 @@ def cli_tc_main():
default=None)
parser.add_argument('--test',
help=('optional flag that conducts installation '
'test.'),
'test, writes test result to stdout, '
'and quits.'),
default=False,
action="store_true")
parser.add_argument('--version',
help=('optional flag that writes Tax-Calculator '
'release version to stdout and quits.'),
default=False,
action="store_true")
args = parser.parse_args()
# show Tsx-Calculator version and quit if --version option specified
if args.version:
sys.stdout.write('Tax-Calculator {}\n'.format(tc.__version__))
return 0
# write test input and expected output files if --test option specified
if args.test:
_write_expected_test_output()
Expand All @@ -138,10 +150,10 @@ def cli_tc_main():
inputfn = args.INPUT
taxyear = args.TAXYEAR
# instantiate taxcalcio object and do tax analysis
tcio = TaxCalcIO(input_data=inputfn, tax_year=taxyear,
baseline=args.baseline,
reform=args.reform, assump=args.assump,
outdir=args.outdir)
tcio = tc.TaxCalcIO(input_data=inputfn, tax_year=taxyear,
baseline=args.baseline,
reform=args.reform, assump=args.assump,
outdir=args.outdir)
if tcio.errmsg:
sys.stderr.write(tcio.errmsg)
sys.stderr.write('USAGE: tc --help\n')
Expand Down
90 changes: 90 additions & 0 deletions taxcalc/consumption.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,95 @@
"boolean_value": false,
"integer_value": false,
"value": [0.0]
},

"_BEN_snap_value": {
"long_name": "Consumption value of SNAP benefits",
"description": "Consumption value per dollar of SNAP benefits, all of which are in-kind benefits.",
"section_1": "",
"section_2": "",
"notes": "",
"row_var": "FLPDYR",
"row_label": ["2013"],
"start_year": 2013,
"cpi_inflatable": false,
"cpi_inflated": false,
"col_var": "",
"col_label": "",
"boolean_value": false,
"integer_value": false,
"value": [1.0]
},

"_BEN_vet_value": {
"long_name": "Consumption value of veterans benefits",
"description": "Consumption value per dollar of veterans benefits, some of which are in-kind benefits (about 40% are in-kind medical benefits).",
"section_1": "",
"section_2": "",
"notes": "",
"row_var": "FLPDYR",
"row_label": ["2013"],
"start_year": 2013,
"cpi_inflatable": false,
"cpi_inflated": false,
"col_var": "",
"col_label": "",
"boolean_value": false,
"integer_value": false,
"value": [1.0]
},

"_BEN_mcare_value": {
"long_name": "Consumption value of Medicare benefits",
"description": "Consumption value per dollar of Medicare benefits, all of which are in-kind benefits.",
"section_1": "",
"section_2": "",
"notes": "",
"row_var": "FLPDYR",
"row_label": ["2013"],
"start_year": 2013,
"cpi_inflatable": false,
"cpi_inflated": false,
"col_var": "",
"col_label": "",
"boolean_value": false,
"integer_value": false,
"value": [1.0]
},

"_BEN_mcaid_value": {
"long_name": "Consumption value of Medicaid benefits",
"description": "Consumption value per dollar of Medicaid benefits, all of which are in-kind benefits.",
"section_1": "",
"section_2": "",
"notes": "",
"row_var": "FLPDYR",
"row_label": ["2013"],
"start_year": 2013,
"cpi_inflatable": false,
"cpi_inflated": false,
"col_var": "",
"col_label": "",
"boolean_value": false,
"integer_value": false,
"value": [1.0]
},

"_BEN_other_value": {
"long_name": "Consumption value of other benefits",
"description": "Consumption value per dollar of other benefits, some of which are in-kind benefits (somewhere between 52% and 76% are in-kind benefits).",
"section_1": "",
"section_2": "",
"notes": "",
"row_var": "FLPDYR",
"row_label": ["2013"],
"start_year": 2013,
"cpi_inflatable": false,
"cpi_inflated": false,
"col_var": "",
"col_label": "",
"boolean_value": false,
"integer_value": false,
"value": [1.0]
}
}
32 changes: 20 additions & 12 deletions taxcalc/consumption.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Tax-Calculator marginal Consumption class.
Tax-Calculator Consumption class.
"""
# CODING-STYLE CHECKS:
# pep8 --ignore=E402 consumption.py
Expand All @@ -15,19 +15,20 @@ class Consumption(ParametersBase):
Consumption is a subclass of the abstract ParametersBase class, and
therefore, inherits its methods (none of which are shown here).
Constructor for marginal Consumption class.
Constructor for Consumption class.
Parameters
----------
consumption_dict: dictionary of PARAM:DESCRIPTION pairs
dictionary of marginal propensity to consume (MPC) parameters;
if None, all MPC parameters are read from DEFAULTS_FILENAME file.
dictionary of marginal propensity to consume (MPC) parameters and
benefit (BEN) value-of-in-kind-benefit parameters;
if None, all parameters are read from DEFAULTS_FILENAME file.
start_year: integer
first calendar year for MPC parameters.
first calendar year for consumption parameters.
num_years: integer
number of calendar years for which to specify MPC parameter
number of calendar years for which to specify parameter
values beginning with start_year.
Raises
Expand Down Expand Up @@ -66,9 +67,9 @@ def update_consumption(self, revisions):
For example: {2014: {'_MPC_xxx': [0.2, 0.1]}}
Note that this method uses the specified revisions to update the
default MPC parameter values, so use this method just once
rather than calling it sequentially in an attempt to update
MPC parameters in several steps.
default MPC parameter values and the default BEN parameter values,
so use this method just once rather than calling it sequentially
in an attempt to update the parameters in several steps.
"""
precall_current_year = self.current_year
self.set_default_vals()
Expand All @@ -80,20 +81,27 @@ def update_consumption(self, revisions):
self.set_year(precall_current_year)

RESPONSE_VARS = set(['e17500', 'e18400', 'e19800', 'e20400'])
BENEFIT_VARS = set(['snap', 'vet', 'mcare', 'mcaid', 'other'])

def has_response(self):
"""
Return true if any MPC parameters are positive for current_year;
return false if all MPC parameters are zero.
Return true if any MPC parameters are positive for current_year or
if any BEN value parameters are less than one for current_year;
return false if all MPC parameters are zero and all BEN value
parameters are one
"""
for var in Consumption.RESPONSE_VARS:
if getattr(self, 'MPC_{}'.format(var)) > 0.0:
return True
for var in Consumption.BENEFIT_VARS:
if getattr(self, 'BEN_{}_value'.format(var)) < 1.0:
return True
return False

def response(self, records, income_change):
"""
Changes consumption-related records variables given income_change.
Changes consumption-related records variables given income_change
and the current values of the MPC consumption parameters
"""
if not isinstance(records, Records):
raise ValueError('records is not a Records object')
Expand Down
Binary file added taxcalc/cps_benefits.csv.gz
Binary file not shown.
Loading

0 comments on commit f682979

Please sign in to comment.