{smcl}
{hline}
help for {it:{hi:taxcost      }}                                         
{hline}

{title:taxcost: Program to calculate the utility cost of ignoring changes in the tax code}

{title:Description}

{p 8 18 2}
{cmdab:taxcost} [{cmdab:g:rid}][, {cmdab:r:eplace_ext} {cmdab:r:eplace_int}]

{p 4 4 2}Calculates the cost of not reoptimizing with respect to 
changes in the tax code. Stated very shortly it helps 
you apply the tax-calculator TAXSIM and do some calculations using the results. 
It takes the same input as taxsim9 does, but you need to specify two 
extra variables (these are marked with a * in the list below; all other variable names are as in taxsim9). 
The output will give you the tax rates before and after the tax-change, 
and the utility cost of not reoptimizing, both nominally and as a percentage. 
This will be done for both the intensive and the extensive margin, and you'll get 
two output files: taxcost_out_XX, where XX is either "int" or "ext".

{p 4 4 2} In theory, you only need to specify
the variables postyear and pwages to make the code work. All other variables have a default
value in case it is not given. In particular, the variable year will be set to (postyear-3) if not given. See below
for more details on default values.

{p 4 4 2} The section "Details on the method" explains the procedure in more detail.

{p 4 4 2} Since the program taxsim9 is used, you need to have this program available for the code to work.

{title:Input Variables (description of most variables is copied from the taxsim-help):}

{p 4 4 2} {hi:year:} 4-digit year between 1960 and 2013 for federal tax and 1977 and
2002 if state tax is requested. This will be the base year, where the observations are 
assumed to have optimized.

{p 4 4 2}
{hi:postyear*:} 4-digit year between 1960 and 2013 for federal tax and 1977 and
2002 if state tax is requested. This will be the after-change year, where we evaluate
the gains from reoptimizing, given that the observations were optimizing in the 
base-year. 

{p 4 4 2} {hi:e*:} Elasticity of labor supply (default is 1).

{p 4 4 2} {hi:state:} State identifier. These are numeric codes from 1 to
51 (Alaska to Wyoming in alphabetical order) with zero indicating "no
state tax".

{p 4 4 2} {hi:mstat:} Marital status 1 for single, 2 for joint, 7 for head
of household.

{p 4 4 2} {hi:depx:} Number of dependent children

{p 4 4 2} {hi:agex:} Number of age 65+ taxpayers

{p 4 4 2} {hi:pwages:} Wage income of primary earner in the BASE-YEAR

{p 4 4 2} {hi:swages:} Wage income of secondary earner (kept constant for both years)

{p 4 4 2} {hi:dividends:} Dividend income (kept constant for both years)

{p 4 4 2} {hi:otherprop:} Interest and other property income (kept constant for both years)

{p 4 4 2} {hi:pensions:} Taxable pension income (kept constant for both years)

{p 4 4 2} {hi:gssi:} Gross social security benefits (kept constant for both years)

{p 4 4 2} {hi:transfers:} Non-taxable transfer income, used for
calculating low income credits and property tax credits on state taxes  (kept constant for both years)

{p 4 4 2} {hi:rentpaid:} Rent paid is used in some state property tax
credits  (kept constant for both years)

{p 4 4 2} {hi:proptax:} Property tax paid is an itemized deduction  (kept constant for both years)

{p 4 4 2} {hi:otheritem:} Other itemized deductions include everything
except property tax paid and state income tax (which is calculated by
taxsim) (kept constant for both years)

{p 4 4 2} {hi:childcare:} Child care expenses are a credit in the federal
tax (kept constant for both years)

{p 4 4 2} {hi:ui:} Unemployment compensation benefits are partially
included in AGI (kept constant for both years)

{p 4 4 2} {hi:stcg:} Short term capital gain or loss (+/-) (kept constant for both years)

{p 4 4 2} {hi:ltcg:} Long term capital gain or loss (+/-) (kept constant for both years)

{title:Output Variables:}

{p 4 4 2} The following variables will be in the output files:

{p 4 4 2} Note on the syntax (1): There will be 3 sets of the same output variables. 
Variable X will be the variable in the pre-period ("year").
Variable X_noopt will be the value of X in the postyear, given that the agent
didn't reoptimize. The variable X_reopt is the variable X in the postyear, 
given that he reoptimized. The variables covered by this "syntax" are:

{p 4 4 2} {hi:fiitax:} Federal tax liability, after regular, minimum, and
maximum tax, and after refundable credits.

{p 4 4 2} {hi:siitax:} State tax liability after refundable credits.

{p 4 4 2} {hi:fica:} FICA tax liability

{p 4 4 2} {hi:frate:} Marginal federal tax rate wrt a weighted average of
the rates on the primary and secondary earners, or equal weights if both
are non-workers.  

{p 4 4 2} {hi:srate:} Marginal state tax rate. 

{p 4 4 2} {hi:ficar:} Marginal FICA rate. The estimate of FICA tax
includes both employer and employee portions, and ignores the favorable
treatment of self-employment income.

{p 4 4 2} {hi:MTR:} Marginal Tax Rate = frate + srate + ficar

{p 4 4 2} {hi:ATR:} Average Tax Rate = (fiitax + siitax + fica)/(Taxable Income)

{p 4 4 2} Note on the syntax (2): In addition, there will be variables with names
specific to whether they are in the output data for the intensive- or extensive margin 
calculations. Variable X will be named X_int or X_ext. The variables covered by this syntax are:

{p 4 4 2} {hi:dollargain}: Dollar cost of not reoptimizing, corresponding to the
difference in utility between "reopt" and "noopt". For the extensive margin calculations, we'll assume that
the agent chose NOT to work in the "noopt" situation if the ATR increases from year to postyear, 
and assume that he would have been working if the ATR decreases.

{p 4 4 2} {hi:percentgain}: Percentage cost of not reoptimizing. For most calculations, it equals
the dollargain divided by: inflation*(post-tax earnings in the base-year). 
For the "zero-calculations" (see below for description), the denominator is (post-tax earnings that prevail when you're ignoring the 
tax schedule).

{p 4 4 2} {hi:delta_TI}: the change in taxable income (TI) required to reoptimize (compared to the situation of not reoptimizing
in the post-period).

{p 4 4 2} Finally, there will be some other variables:

{p 4 4 2} {hi: pwages_round:} The rounded off "pwages" that are used in the program (just so you don't forget that these might
differ from those in your input data).

{p 4 4 2} {hi: m:} The productivity parameter for year (see below for description).

{p 4 4 2} {hi: m_post:} The productivity parameter for postyear (see below for description).

{p 4 4 2} {hi:taxcostid:} ID-number identifying each observation uniquely.

{p 4 4 2} {hi:inputchange:} Change in pwages_round made by the "non-convex fix" (see below for details)

{p 4 4 2} {hi:kink:} Dummy variable which equals 1 if the TI used after the "non-convex fix" lies at a kink in the tax schedule.

{p 4 4 2} {hi:kink_reopt:} Dummy variable which equals 1 if the reoptimized TI lies at a kink in the tax schedule.

{title:Missing Variables:} 
{p 4 4 2} In theory, you only need to specify
the postyear and pwages to make the code work. All other variables have a default
value in case the variable is not given. The program will print a message if
you haven't specified a variable and tell you that it is generated. 
The default value is 0 for all variables,
except for mstat, e and year. The two first have a default value of 1. year will have a 
default of (postyear-3), i.e., it will assume that the agent optimized 3 years before the
postyear.

{title:Options}
{p 4 4 2}{cmd:grid}: You are allowed to change the "grid" used, which 
determines the accuracy of your results. See description below to see
the effect of changing the grid. The default is $10.

{p 4 4 2}{cmd:replace_int}: Merge the key variables for the intensive margin into the workspace, 
possibly overwriting existing variables. The variables are:
MTR_pre, 
MTR_post_noopt, 
dollargaing_int, 
percentgain_int and  
delta_TI_int. The full output (including these variables) is saved to taxcost_out_int.dta in the 
current directory.

{p 4 4 2}{cmd:replace_ext}: Merge the key variables for the extensive margin into the workspace, 
possibly overwriting existing variables. The variables are:
ATR_pre, 
ATR_post_noopt, 
dollargaing_ext, 
percentgain_ext and  
delta_TI_ext. The full output (including these variables) is saved to taxcost_out_ext.dta in the 
current directory.

{title:Zero calculations:} 
{p 4 4 2} If you set year to be zero the code will
perform "zero-calculations". These assume that the agent has optimized under
the impression that there are no taxes at all, and then reoptimizes with respect to the tax system
of the postyear.

{title:Details on the method}
{p 4 4 2} 
We use a simple and general utility function (this is the one used for 
intensive margin calculations): {break}
utility = (1-t)w - m*(w/m)^(1+(1/e))/(1+(1/e)){break}
where:{break}
t = average tax rate, ATR (which equals marginal tax rate, MTR, if tax system is linear){break}
w = taxable income (TI){break}
m = productivity parameter{break}
e = elasticity of labor supply

{p 4 4 2} For the extensive margin calculations, we'll use {break}
utility = (1-t)w - m*(w/m)^(1+(1/e))/(1+(1/e)) - fixedcost*(l>0){break}
where "fixedcost" is the cost making the agent indifferent between working and not working (and getting utility=0) in the postyear, 
if there are no changes in the taxes.

{p 4 4 2}
The code will go through the following steps:

{p 4 4 2}
Calculations for the first period (year):{break}
(i) Find the values of the productivity parameters. This is done by finding the m's that will 
rationalize the TIs in the intput, given the tax schedule for "year" we create using TAXSIM. 
We take each TI and it's corresponding MTR, and find the value of m necessary to make this TI solve the FOC. 
Note that you are specifying the labor supply elasticity yourself (e). {break}
(ii) Since some incomes are impossible optimums due to the non-convexity of the tax schedule a 
"non-convex fix" will double-check that each wage is actually the optimal, given the m
necessary to rationalize it. If it's not, we use the actual optimal wage instead. If the inputwage is changed,
this is indicated by the variable "inputchange".

{p 4 4 2}
Calculations for the second period (postyear):{break}
(iii) First consider the situation where the agent doesn't reoptimize (referred to as "noopt"), 
but just receives a wage equal to the one optimal one in "year", inflated to stay constant in real terms. 
This means that the agent ignores any changes in the tax code. {break}
(iv) Then consider the situation where he reoptimizes ("reopt"). 
Here we find the optimal wage, given the productivity parameter and the new tax schedule.{break}
{break} 
Note that the productivity parameter for the postyear will be inflated, such that, 
if there are no changes in the tax schedule, there are no gains from reoptimizing.


{title:Rounding off}
{p 4 4 2} We have to emphasize that the code will round off the taxable income at several points to match the grid you've specified. 
Already before the calculations are done, the TI's you've given (pwages) will be rounded off, in order to match an income to its corresponding taxes
in the tax schedule created (with a step-size equal to the grid). If any wages are lower than grid/2, they will be dropped from the input data.
Then, in the postyear calculations, the inflated income will be rounded off too.
In addition, when looking for the optimum, we'll round off the optimal wage to match the tax schedule.

{p 4 4 2} The variable "pwages" in the dataset you are using will not be changed, but the variable "pwages_round" in the output-files will be the
rounded off pwages.

{title:Tips for efficiency:}
{p 4 4 2}
The code will group together observations with equal tax characteristics for use in TAXSIM (except for pwages), and use TAXSIM only
once for this group. It does so by creating one large tax schedule that covers both "year" and "postyear" for various wages
with the characteristics of this group. The tax schedule will span wages from the grid you specify, up to TWO times the maximal input wage 
in this group, with steps equal to the grid. The time-consuming bit is creating the tax schedules, and for every variation in taxpayer 
characteristics (beside pwages), there will be created a new tax schedule! Some tips are good to bear in mind:

{p 4 4 2} - If you have a diversity of taxpayer characteristics and many observations (and the small differences are of little importance), 
consider rounding them off so that taxsim runs fewer times.  Or consider eliminating some characteristics.

{p 4 4 2} - If you want to look at the same tax payer, but with different wage levels, put it all in one dta-file and use the code once.

{p 4 4 2} - If there's a large variation in the income levels within a "group", you might want to run the code twice, once for those with 
low incomes (and then use a small grid), and once for those with large incomes (with a larger grid). 

{title:CPI-data:} 
{p 4 4 2} The program uses CPI-data from {break}
ftp://ftp.bls.gov/pub/special.requests/cpi/cpiai.txt {break}
If the years you are using are outside the range of the CPI-data covered by the program, a default inflation of 2%
will be used, and a message will be printed (which is a sign that the program should be updated).

{title:Support:}
{p 4 4 2} For questions regarding the TAXSIM-calculator, please
see the helpfile for taxsim9 or go online: {break}
http://www.nber.org/~taxsim/

{p 4 4 2} This program was written by Tord Krogh (tskrogh@gmail.com) and Zach Liscow (liscow@econ.berkeley.edu).  
For technical support, contact Tord Krogh.

{p 4 4 2} The method in this program is based on Chetty (2009)
"Bounds on Elasticities with Optimization Frictions: A Synthesis of Micro and Macro Evidence on Labor Supply," NBER Working Paper # 15616, December 2009.  For questions on the methodology, contact Raj Chetty (chetty@fas.harvard.edu).


