Skip to content

Commit

Permalink
Merge pull request #1193 from andersonfrailey/Adjustment
Browse files Browse the repository at this point in the history
Add stage 3 adjustment ratios
  • Loading branch information
martinholmer authored Feb 14, 2017
2 parents cc40a1e + 2832d85 commit bbf7b6e
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 78 deletions.
8 changes: 8 additions & 0 deletions inctax.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ def main():
'adjusted in any way.'),
default=False,
action="store_true")
parser.add_argument('--adjust',
help=('optional flag that triggers the default '
'adjustment logic built into the Tax-Calculator '
'that will adjust the distribution of income.'),
default=False,
action="store_true")

parser.add_argument('--weights',
help=('optional flag that causes OUTPUT to have an '
'additional variable [29] containing the s006 '
Expand Down Expand Up @@ -176,6 +183,7 @@ def main():
assump=args.assump,
exact_calculations=args.exact,
blowup_input_data=args.blowup,
adjust_input_data=args.adjust,
output_weights=args.weights,
output_records=args.records,
csv_dump=args.csvdump)
Expand Down
44 changes: 22 additions & 22 deletions taxcalc/comparison/reform_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Tax-Calculator,0.8,0.9,1.0,1.1
SOCIAL SECURITY TAXABILITY
""
Exclusion of untaxed social security and railroad retirement
Tax-Calculator,39.1,40.3,42.0,44.2
Tax-Calculator,38.4,39.6,41.3,43.4
Tax Expenditure,39,42,44,47
Budget Options,35,37,38,40
""
Expand All @@ -39,7 +39,7 @@ Eliminate adjustment for self-employment tax
Tax-Calculator,4.1,4.3,4.7,5.0
""
Eliminate adjustment for self-employed health insurance
Tax-Calculator,5.8,5.9,6.2,6.4
Tax-Calculator,5.7,5.9,6.1,6.4
""
Eliminate adjustment for alimony payments
Tax-Calculator,2.1,2.2,2.3,2.4
Expand All @@ -50,7 +50,7 @@ Tax-Calculator,0.1,0.1,0.1,0.1
EXEMPTION
""
Increase personal and dependent exemption amount by 1000
Tax-Calculator,-32.4,-34.6,-39.4,-40.8
Tax-Calculator,-32.3,-34.5,-39.2,-40.7
""
Increase personal exemption phaseout starting AGI by 10,000
Tax-Calculator,-0.1,-0.1,-0.1,-0.2
Expand All @@ -61,43 +61,43 @@ Tax-Calculator,0.2,0.2,0.2,0.2
STANDARD DEDUCTION
""
Increase standard deduction by 100
Tax-Calculator,-1.0,-2.5,-4.1,-4.3
Tax-Calculator,-1.0,-2.5,-4.1,-4.2
""
Increase additional standard deduction for aged and blind by 100
Tax-Calculator,-0.3,-0.3,-0.4,-0.5
Tax-Calculator,-0.2,-0.3,-0.4,-0.5
""
ITEMIZED DEDUCTION
""
Real Estate
Tax-Calculator,36.1,38.2,40.2,42.1
Tax-Calculator,36.0,38.1,40.1,42.1
Tax Expenditure,34,36,39,41
""
Home Mortgage
Tax-Calculator,69.4,74.7,79.8,84.6
Tax Expenditure,75,82,88,93
""
Both real estate and state and local
Tax-Calculator,101.7,107.7,113.3,118.6
Tax-Calculator,101.6,107.6,113.2,118.6
Tax Expenditure,75,82,88,93
""
State & Local
Tax-Calculator,67.3,70.9,74.3,77.4
Tax Expenditure,59,63,67,71
""
Medical
Tax-Calculator,8.1,8.6,7.9,8.1
Tax-Calculator,8.0,8.4,7.8,8.0
Tax Expenditure,11,12,13,14
""
Casualty
Tax-Calculator,0.5,0.5,0.5,0.6
Tax Expenditure,0,0,0,0
""
Charitable
Tax-Calculator,46.7,49.3,51.7,53.9
Tax-Calculator,46.7,49.3,51.8,54.1
Tax Expenditure,46,47,48,50
""
Decrease AGI floor for miscellaneous expenses by 1 pts
Tax-Calculator,-2.8,-2.9,-3.1,-3.2
Tax-Calculator,-2.8,-3.0,-3.1,-3.2
""
Increase Itemized deduction maximum phaseout by 10%
Tax-Calculator,0.2,0.2,0.2,0.2
Expand All @@ -106,10 +106,10 @@ Increase Itemized Deduction phaseout starting AGI by 10,000
Tax-Calculator,0.1,0.1,0.0,0.0
""
Increase Itemized Deduction phaseout rate by 1 pts
Tax-Calculator,4.4,4.5,4.7,4.8
Tax-Calculator,4.4,4.6,4.8,4.9
""
limit the tax value of ID to 6% of AGI
Tax-Calculator,19.9,20.9,21.9,23.0
Tax-Calculator,19.9,20.8,21.9,22.9
Budget Options,11,9,8,7
""
CAPITAL GAIN
Expand All @@ -118,21 +118,21 @@ Increase long term cap gain and dividends tax rates by 2 percentage, no behavior
Tax-Calculator,18.5,19.9,20.2,20.4
""
Increase long term cap gain and dividends tax rates by 2 percentage, BE_cg elasticity assumed to be -3.67
Tax-Calculator,4.3,4.5,4.6,4.7
Tax-Calculator,4.3,4.4,4.6,4.7
Budget Options,5,5,5,6
""
REGULAR TAXES
""
Increase each bracket rate by 1%
Tax-Calculator,58.8,61.3,64.0,66.5
Tax-Calculator,58.8,61.3,64.1,66.6
Budget Options,56,60,65,69
""
Increase top 4 rates by 1%
Tax-Calculator,14.1,14.7,15.2,15.5
Tax-Calculator,14.3,14.9,15.4,15.7
Budget Options,11,12,14,15
""
Increase top 2 rates by 1%
Tax-Calculator,9.3,9.5,9.7,9.8
Tax-Calculator,9.4,9.7,9.9,10.0
Budget Options,7,8,9,10
""
Alternative Minimum Tax
Expand All @@ -153,12 +153,12 @@ Tax-Calculator,2.7,2.9,3.1,3.2
Alternative Minimum Tax
""
Increase AMT rate under the surtax threshold by 2 pts
Tax-Calculator,27.9,29.8,31.4,32.9
Tax-Calculator,27.9,29.8,31.4,33.0
""
Alternative Minimum Tax
""
Increase AMT rate above the surtax threshold by 2 pts
Tax-Calculator,9.0,9.6,10.2,10.7
Tax-Calculator,9.1,9.6,10.2,10.7
""
Increase AMT surtax threshold by 10,000
Tax-Calculator,-0.5,-0.7,-0.9,-0.9
Expand All @@ -178,7 +178,7 @@ Tax-Calculator,-0.2,-0.2,-0.2,-0.2
REFUNDABLE CREDIT
""
Earned income tax credit, total
Tax-Calculator,65.4,64.8,64.6,66.2
Tax-Calculator,65.5,64.8,64.7,66.3
Tax Expenditure,70,71,72,70
""
Increase EITC phaseout rate by 1 pts
Expand All @@ -199,7 +199,7 @@ Tax-Calculator,0.0,0.0,0.0,0.0
OTHER TAXES
""
Eliminate Net Investment Income Tax
Tax-Calculator,-36.3,-39.3,-39.7,-40.0
Tax-Calculator,-37.1,-40.1,-40.6,-40.9
Tax Expenditure,-33,-35,-37,-39
""
Increase Net Investment Income Tax threshold by 10,000
Expand All @@ -211,10 +211,10 @@ Increase Personal Refundable credit amount to 1000
Tax-Calculator,-164.9,-170.6,-177.5,-184.4
""
Increase Personal Refundable credit amount to 1000 with phaseout starting at AGI 10,000 and phaseout rate at 0.01
Tax-Calculator,-109.1,-112.4,-116.6,-120.9
Tax-Calculator,-109.3,-112.6,-116.8,-121.2
""
FAIR SHARE TAX
""
Increase FST rate from zero to 0.30 beginning in 2017
Tax-Calculator,42.3,42.2,42.1,42.6
Tax-Calculator,41.7,41.6,41.5,41.9
Tax Foundation: 321 ten-year(2016-25) static estimate
56 changes: 41 additions & 15 deletions taxcalc/incometaxio.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class instance: IncomeTaxIO

def __init__(self, input_data, tax_year, reform, assump,
exact_calculations,
blowup_input_data, output_weights,
blowup_input_data, adjust_input_data, output_weights,
output_records, csv_dump):
"""
IncomeTaxIO class constructor.
Expand Down Expand Up @@ -164,24 +164,50 @@ def __init__(self, input_data, tax_year, reform, assump,
# read input file contents into Records object
if blowup_input_data:
if output_weights:
recs = Records(data=input_data,
exact_calculations=exact_calculations)
if adjust_input_data:
recs = Records(data=input_data,
exact_calculations=exact_calculations)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
adjust_ratios=None)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
weights=None)
if adjust_input_data:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
weights=None)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
adjust_ratios=None,
weights=None)
else:
if output_weights:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
start_year=tax_year)
if adjust_input_data:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
start_year=tax_year)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
adjust_ratios=None,
start_year=tax_year)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
weights=None,
start_year=tax_year)
if adjust_input_data:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
weights=None,
start_year=tax_year)
else:
recs = Records(data=input_data,
exact_calculations=exact_calculations,
blowup_factors=None,
adjust_ratios=None,
weights=None,
start_year=tax_year)
# create Calculator object
con = Consumption()
con.update_consumption(con_d)
Expand Down
18 changes: 18 additions & 0 deletions taxcalc/puf_ratios.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
,BIN_0,BIN_1,BIN_2,BIN_3,BIN_4,BIN_5,BIN_6,BIN_7,BIN_8,BIN_9,BIN_10,BIN_11,BIN_12,BIN_13,BIN_14,BIN_15,BIN_16,BIN_17,BIN_18
INT2010,0.894570657511,0.277936915309,0.905851867059,0.865550027979,0.862370124368,0.939010546172,0.854594552658,0.841921125239,0.801319283113,0.832911751911,0.920278986285,0.932635890516,1.02741582794,1.0364097442,1.06437329288,1.0367531046,1.06848339321,1.0185821615,2.84172042524
INT2011,1.10672363651,0.889333330304,0.744717716945,0.822829719314,0.888355355771,0.800847021222,0.888039758719,0.9235984934,0.980486770542,0.904283950902,1.02959505892,1.00779637961,1.06734222294,1.04626981483,1.04299793962,1.10077470334,1.09006709516,1.15686454569,1.02765479069
INT2012,0.828155525174,0.914660166907,0.853336496358,0.860587814233,0.737688316334,0.827657759705,0.819199293758,0.79655237166,0.832759302563,0.873719451169,0.888181974719,1.00023811743,1.05528059309,1.02483064366,0.915856372804,1.00296501146,0.966196397791,1.16743843535,1.38060882956
INT2013,1.13897644483,0.784182359895,0.754171760532,0.76018499586,0.885769589089,0.856216681324,0.926420260632,0.893968942552,0.833220635914,0.876497424882,0.997938730096,0.983074986778,1.00508265524,1.03613142335,1.18838687541,1.11871454573,1.18281801887,1.02526237543,1.17732163416
INT2014,0.925133833279,0.921968806824,0.853323973582,0.766595101667,0.834162259466,0.866174994362,0.984158261912,0.858449655851,0.828309014512,1.02501023984,0.847681686262,1.07633139864,1.03664003313,0.951169538521,1.03164883753,1.06051639002,1.01735202653,1.06416167641,1.04248041776
INT2015,1.00974066398,1.00422248817,0.97310803284,0.96721560407,0.976221484037,0.962705727651,0.985406121339,1.00619878485,1.00685432684,1.03338627906,1.03780482171,1.01453670092,1.02772001432,1.01317874185,0.959524456305,0.93761270802,0.970836935276,0.965537518163,0.899348501668
INT2016,0.997233067712,0.991679928803,0.968920774411,0.964638004354,0.972178922261,0.967356703977,0.983979905487,0.991287990837,0.995553529264,1.00451070918,1.00946305895,0.994072263012,1.00161104447,1.00988364386,1.00528874276,1.00809737128,1.0114498475,1.03687421759,1.04540950687
INT2017,1.00020025711,0.997368680599,0.963548507444,0.955590516209,0.962158997023,0.973242287677,0.975108780722,0.995907303522,1.00527108467,1.00430214894,0.994569189736,0.99550614219,1.00388325279,1.01042676914,1.00857972272,1.01907257264,1.03491043712,1.04278549179,1.01616895332
INT2018,0.993180991967,0.981250571127,0.964583038123,0.963459458638,0.970806796955,0.974760715767,0.979385506194,0.980894657558,0.990647008563,0.991040898293,1.00030055116,0.993261483622,0.996850161176,0.996984974053,1.02909632393,1.03056596077,1.06167542629,1.09482859975,1.04890455969
INT2019,0.978129160696,0.984092169449,0.976217494533,0.986961985687,0.990935243425,0.985401142393,0.986022836117,0.976652536361,0.984818779403,0.993313181425,1.011212485,1.00770209347,0.999772872887,0.986755418934,1.00901288536,1.03235035292,1.01400575457,1.06921417865,1.06092766188
INT2020,1.03494427851,0.990237894643,0.962030413092,0.951965021376,0.962385099605,0.981347554774,0.99508948464,1.02778910538,1.03939770396,1.02465416707,0.983812168605,0.978543989005,1.01073687533,1.02335732647,1.01904956792,1.02611452117,1.01270962371,0.977565695758,0.948792988014
INT2021,0.996653685345,0.984089065364,0.978113383754,0.980210026159,0.983013505354,0.990676796501,0.989696689744,0.991723304633,1.00295505973,1.00374286944,1.00147372804,0.999407064025,0.9988951009,0.992160703194,1.00518671827,1.01031097612,1.01875183058,1.07745190473,1.01592134238
INT2022,0.984010833382,0.984480850273,0.986114958659,0.999678273231,0.99712739969,0.990910462587,0.986460422566,0.999346974682,0.977917503104,1.00775386156,1.01052235142,1.01088837326,0.999379082098,0.984445713327,0.998857529857,1.00255607971,0.99836032652,1.01400379613,1.04031483574
INT2023,1.01502858594,0.985335460664,0.968950764435,0.967568205456,0.97957997814,0.991273191883,0.99713019261,1.00248630218,1.03292190103,1.0153760181,0.98372023439,0.986951696507,1.00600980075,1.01439592485,1.02526770226,1.03185365897,1.02207422903,0.993720787965,0.975648620522
INT2024,1.00912206668,0.986413028265,0.978708191657,0.979529491113,0.984344140113,0.990170214158,1.00254157769,1.0005675355,1.01183092771,1.00181765029,0.998010404057,0.996580369769,1.00316090496,1.01025943385,1.01237259591,1.01038355305,1.01136054379,1.00141632202,1.0018815789
INT2025,1.00057050568,0.985726747261,0.973218969426,0.977867562495,0.986102444116,0.990957746618,0.993195231355,1.0044852269,1.0089063489,1.00212945398,0.995701385524,0.99296627178,1.00433728051,1.01289298367,1.02204281459,1.01296657159,1.02212901854,1.00528003009,1.01325579112
INT2026,1.00755127661,0.987704766664,0.975313011801,0.981617237919,0.987866706414,1.00540188392,1.00222567621,0.999078532844,1.00390542243,0.993520621968,0.99333281483,0.998577424229,1.00249225677,1.01064361289,1.01358549246,1.00895519969,1.01404750649,1.00628883564,1.02196559012
52 changes: 49 additions & 3 deletions taxcalc/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class Records(object):
None creates empty blowup-factors DataFrame;
default value is filename of the default blowup factors.
adjust_ratios: string or Pandas DataFrame or None
string describes CSV file in which adjustment ratios reside;
DataFrame already contains adjustment ratios;
None creates empty adjustment-ratios DataFrame;
default value is filename of the default adjustment ratios.
weights: string or Pandas DataFrame or None
string describes CSV file in which weights reside;
DataFrame already contains weights;
Expand Down Expand Up @@ -91,6 +97,8 @@ class instance: Records
WEIGHTS_PATH = os.path.join(CUR_PATH, WEIGHTS_FILENAME)
BLOWUP_FACTORS_FILENAME = 'growfactors.csv'
BLOWUP_FACTORS_PATH = os.path.join(CUR_PATH, BLOWUP_FACTORS_FILENAME)
ADJUST_RATIOS_FILENAME = 'puf_ratios.csv'
ADJUST_RATIOS_PATH = os.path.join(CUR_PATH, ADJUST_RATIOS_FILENAME)

# specify set of input variables used in Tax-Calculator calculations:
USABLE_READ_VARS = set([
Expand Down Expand Up @@ -121,7 +129,7 @@ class instance: Records
'MARS', 'MIDR', 'RECID', 'filer', 'cmbtp',
'age_head', 'age_spouse', 'blind_head', 'blind_spouse',
'nu13', 'elderly_dependent',
's006', 'nu05'])
's006', 'nu05', 'agi_bin'])

# specify set of input variables that MUST be read by Tax-Calculator:
MUST_READ_VARS = set(['RECID', 'MARS'])
Expand All @@ -133,7 +141,7 @@ class instance: Records
'n24', 'XTOT',
'MARS', 'MIDR', 'RECID', 'filer',
'age_head', 'age_spouse', 'blind_head', 'blind_spouse',
'nu13', 'elderly_dependent'])
'nu13', 'elderly_dependent', 'agi_bin'])

# specify set of Record variables that are calculated by Tax-Calculator:
CALCULATED_VARS = set([
Expand Down Expand Up @@ -176,6 +184,7 @@ def __init__(self,
data='puf.csv',
exact_calculations=False,
blowup_factors=BLOWUP_FACTORS_PATH,
adjust_ratios=ADJUST_RATIOS_PATH,
weights=WEIGHTS_PATH,
start_year=PUFCSV_YEAR):
"""
Expand All @@ -201,11 +210,14 @@ def __init__(self,
rtol=0.0, atol=0.001):
msg = 'expression "e00600 >= e00650" is not true for every record'
raise ValueError(msg)
# read extrapolation blowup factors and sample weights
# read extrapolation blowup factors, adjustment ratios, and
# sample weights
self.BF = None
self._read_blowup(blowup_factors)
self.WT = None
self._read_weights(weights)
self.ADJ = None
self._read_adjust(adjust_ratios)
# weights must be same size as tax record data
if not self.WT.empty and self.dim != len(self.WT):
frac = float(self.dim) / len(self.WT)
Expand Down Expand Up @@ -241,6 +253,8 @@ def increment_year(self):
self._current_year += 1
# apply Stage 1 Extrapolation blowup factors
self._blowup(self.current_year)
# apply Stage 3 adjustment ratios
self._adjust(self.current_year)
# specify Stage 2 Extrapolation sample weights
wt_colname = 'WT{}'.format(self.current_year)
if wt_colname in self.WT.columns:
Expand Down Expand Up @@ -355,6 +369,14 @@ def _blowup(self, year):
self.p87521 *= ATXPY
self.cmbtp *= ATXPY

def _adjust(self, year):
"""
Adjust value of income variables to match SOI distributions
"""
if len(self.ADJ) != 0:
# Interest income
self.e00300 *= self.ADJ['INT{}'.format(year)][self.agi_bin]

def _read_data(self, data, exact_calcs):
"""
Read Records data from file or use specified DataFrame as data.
Expand Down Expand Up @@ -485,3 +507,27 @@ def _read_blowup(self, blowup_factors):
'or a Pandas DataFrame')
raise ValueError(msg)
setattr(self, 'BF', BF)

def _read_adjust(self, adjust_ratios):
"""
Read Records adjustment ratios from file or uses specified DataFrame
as data or creates empty DataFrame if None
"""
if adjust_ratios is None:
ADJ = pd.DataFrame({'nothing': []})
setattr(self, 'ADJ', ADJ)
return
if isinstance(adjust_ratios, pd.DataFrame):
ADJ = adjust_ratios
elif isinstance(adjust_ratios, six.string_types):
if os.path.isfile(adjust_ratios):
ADJ = pd.read_csv(adjust_ratios, index_col=0)
else:
ADJ = Records._read_egg_csv('adjust_ratios',
Records.ADJUST_RATIOS_FILENAME)
ADJ = ADJ.transpose()
else:
msg = ('adjust_ratios is not None or a string'
'or a Pandas DataFrame')
raise ValueError(msg)
setattr(self, 'ADJ', ADJ)
Loading

0 comments on commit bbf7b6e

Please sign in to comment.