PSLmodels / Tax-Calculator

USA Federal Individual Income and Payroll Tax Microsimulation Model
https://taxcalc.pslmodels.org
Other
263 stars 157 forks source link

Changing values of variables in calculator object #1965

Closed jdebacker closed 6 years ago

jdebacker commented 6 years ago

I'd like to adjust the value of a variable in a calculator object, but am unsure how to do it. What I've started with is:

# impute short and long term capital gains if using CPS data
    if data == 'cps':
        # in 2012 SOI data 6.587% of CG as short-term gains
        calc1.array('p22250') = 0.06587 * calc1.array('e01100')
        calc1.array('p23250') = (1 - 0.06587) * calc1.array('e01100')

Any advice on how I should go about doing this? Thanks!

martinholmer commented 6 years ago

@jdebacker asked:

I'd like to adjust the value of a variable in a calculator object, but am unsure how to do it. What I've started with is:

# impute short and long term capital gains if using CPS data
   if data == 'cps':
       # in 2012 SOI data 6.587% of CG as short-term gains
       calc1.array('p22250') = 0.06587 * calc1.array('e01100')
       calc1.array('p23250') = (1 - 0.06587) * calc1.array('e01100')

Any advice on how I should go about doing this? Thanks!

I see from taxdata issue 179 that @andersonfrailey has scheduled a better imputation (presumably one that takes into account any variation in the fraction of capital gains that are short-term across AGI classes) as part of a forthcoming improved cps.csv.gz file.

So, your question is how to do something makeshift while @andersonfrailey works on the taxdata imputation, right?

My suggestion is to make these adjustments to the Records object returned from the CPS constructor call Records.cps_constructor() (not to the Calculator object). That way you'll have to do the temporary imputation only once (because you can use the modified Records object twice: once in the baseline Calculator object and again in the reform Calculator object. When you split e01100 into the p22250 and p23250 variables, don't forget to zero out e01100, otherwise you'll be double counting capital gains.

jdebacker commented 6 years ago

@martinholmer Thanks for interpreting my question correctly and for suggesting the modification to the Records object. I've done that as a temporary patch so B-Tax can be used with the CPS file. Thanks for your help @martinholmer and @andersonfrailey !