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

Can't find the steady-state with DEP tax function #26

Open
nikhilwoodruff opened this issue Jul 4, 2021 · 17 comments
Open

Can't find the steady-state with DEP tax function #26

nikhilwoodruff opened this issue Jul 4, 2021 · 17 comments

Comments

@nikhilwoodruff
Copy link
Collaborator

@jdebacker @jpycroft @rickecon @MaxGhenis

Hi all,

So far I can run the entire model on a reform, but the default tax function estimation is linear. I'm guessing this is probably not ideal, but when I've changed it to DEP, the solver can't find the steady-state, even varying the initial guess for r (I've tried 0.02, 0.04, 0.05, and 0.09). Is wondered whether this is just inevitable with the inclusion of benefit MTRs, or if there was any way around it?

@jdebacker
Copy link
Member

@nikhilwoodruff I had the same issue. I think what one needs to do is estimate the tax functions and plot them to see how they look. I would be best to start simple - e.g., with GS functions before DEP functions, with non-age-specific before age-specific. I have not done this yet.

@MaxGhenis
Copy link
Contributor

@jdebacker @rickecon could you share code for plotting tax functions? e.g. from pslmodels.github.io/OG-USA/content/calibration/tax_functions:
image

@jdebacker
Copy link
Member

@nikhilwoodruff I like the 2D plots are you reference. I'd recommend using the ogusa.parameter_plots.plot_2D_taxfunc() function to help with this. There's the option to plot with or without the micro data.

Here's an example plotting non-age-specific DEP functions:

# imports
from ogusa.utils import safe_read_pickle
from ogusa.parameter_plots import plot2D_taxfunc

# read in tax function parameters from pickle
tax_funcs_base = safe_read_pickle('./PATH/TxFuncEst_baseline.pkl')
tax_funcs_reform = safe_read_pickle('./PATH/TxFuncEst_TPC_biden.pkl')

# read in micro data from pickle
micro_data = safe_read_pickle('.PATH/micro_data_baseline.pkl')

# create plot
fig = plot_2D_taxfunc(
    2021, 2021, [tax_funcs_base, tax_funcs_reform], age=None,
    tax_func_type='DEP', rate_type='etr', over_labinc=True, other_inc_val=10000,
    max_inc_amt=10000, data_list=[micro_data], labels=['Baseline', 'Reform'],
    title=r'Comparing Baseline and Reform ETR functions at Capital Income = $10,000',
    path=None)

3D plots are also available in ogusa.parameter_plots.

@jdebacker
Copy link
Member

Here's updated code that I ran from my OG-UK directory (had a typo above):

# imports
from ogusa.utils import safe_read_pickle
from ogusa.parameter_plots import plot_2D_taxfunc

# read in tax function parameters from pickle
tax_funcs_base = safe_read_pickle('./examples/OG-UK-Example/OUTPUT_BASELINE/TxFuncEst_baseline.pkl')
tax_funcs_reform = safe_read_pickle('./examples/OG-UK-Example/OUTPUT_REFORM/TxFuncEst_policy.pkl')

# read in micro data from pickle
micro_data = safe_read_pickle('./examples/OG-UK-Example/OUTPUT_BASELINE/micro_data_baseline.pkl')

# create plot
fig = plot_2D_taxfunc(
    2020, 2020, [tax_funcs_base, tax_funcs_reform], age=None,
    tax_func_type=['linear', 'linear'], rate_type='etr', over_labinc=True, other_inc_val=1000,
    max_inc_amt=1000000, data_list=[micro_data], labels=['Baseline', 'Reform'],
    title=r'Comparing Baseline and Reform ETR functions at Capital Income = $1,000',
    path=None)

And the resulting plot:
plot

Kind of an odd pattern in the raw data (the blue dots), but this was with the toy dataset. Haven't run with the full FRS yet. If you have, I'd love to see what it looks like.

cc @nikhilwoodruff @rickecon @MaxGhenis @jpycroft

@nikhilwoodruff
Copy link
Collaborator Author

nikhilwoodruff commented Jul 16, 2021

Thanks for this @jdebacker - I'm running into some difficulties getting the plot to work, but in the meantime in case it's useful, here's what the ETR by market income scatter plot looks like (which should form the backdrop to that first chart type for the UK, and I used the outputs of get_calculator_output):
image

@nikhilwoodruff
Copy link
Collaborator Author

Also tried to reproduce the microdata side of that 3d plot:
image
image
image
image

@jdebacker
Copy link
Member

@nikhilwoodruff Those ETRs look a lot better!

Let me know if I can help with your issues getting the tax functions to plot. Can get on a Zoom if helpful.

@nikhilwoodruff
Copy link
Collaborator Author

nikhilwoodruff commented Jul 19, 2021

Sorry I've just seen this @jdebacker - here's my recent progress ahead of our meeting later:

  • I got your plot function to work with the microdata:
    • Labour income:

image
Again, seems like it's not a great fit, will try with the DEP function

  • Capital income

image
Can't quite figure out the negative ETR points here, will have a closer look

I've also now finished a PR to openfisca-uk which cuts down the simulation time by about 70% so on my end it's a lot faster to debug the OG-USA runs now

@nikhilwoodruff
Copy link
Collaborator Author

nikhilwoodruff commented Jul 19, 2021

This one is the Labour MTR - looks about right? (to clarify, the microdata points rather than the linear tax function)

image

@nikhilwoodruff
Copy link
Collaborator Author

And the capital MTR one:
image

@jdebacker
Copy link
Member

@nikhilwoodruff The micro data is looking excellent. It looks like you are plotting linear tax functions. It seems like DEP should be able to fit these data reasonably well, but wow, those negative ETRs are huge, so that could be tricky (if not to fit the functions, then to solve the model -- will want to set alpha_T to the appropriate value given the amount of total transfer payments that are included in these tax and benefit functions).

@nikhilwoodruff
Copy link
Collaborator Author

@jdebacker thanks for the ideas from our meeting yesterday- I just tried removing the guess overrides and also the OG-UK default parameters from the parametrization, and the steady-state solved. Will update when the TPI finishes to see what it looks like.

@nikhilwoodruff
Copy link
Collaborator Author

OK, so here's the results of OG-UK without default_og_uk_parameters.json but with the tax estimation (DEP), on a reform that increases the basic rate of income tax from 20% to 30%:

Variable 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2018-2027 SS
0 GDP ($Y_t$) -1.2610463111470689 -1.002877625702909 -0.8300364847666247 -0.8017357093074637 -0.6944600877170604 -0.7065336525169894 -0.5784762898726554 -0.43174267868293803 -0.26232033498917223 -0.06492741831851656 -0.6765809278554461 -1.9156177286659155
1 Consumption ($C_t$) -2.5913907166356878 -2.9495489694916617 -2.943305897470042 -3.0387966282061916 -3.1408709866978706 -3.2430632709993343 -3.331877548350575 -3.412708584372748 -3.4899556010827135 -3.5686989536638327 -3.1673065105065614 -4.156028969707017
2 Capital Stock ($K_t$) -0.17956575065149605 -0.19225658578124338 -0.0872033526908301 0.03568661204566117 0.1844145742630808 0.3573148630760374 0.5863413057423296 0.8707794684225322 1.2161441867194984 1.6312284009170932 0.3826747724343973 -3.494347255846133
3 Labor ($L_t$) -1.8384761187379128 -1.4366018933616194 -1.2276908774737991 -1.249708530913773 -1.1644699439073052 -1.2746732466968929 -1.2000768931932102 -1.1261217821124572 -1.0494677160310633 -0.9665195895227239 -1.2541700546191277 -1.054863732058984
4 Real interest rate ($r_t$) -2.458042987757101 -1.7845631745561092 -1.5828312184264388 -1.738946019888312 -1.780411489908421 -2.1051682328752452 -2.2523730828850628 -2.461138857103756 -2.729262080482354 -3.0572885116501456 -2.2364010451752177 3.3411139087742527
5 Wage rate 0.5882742128716952 0.4400682200537196 0.40262511642829263 0.4536681299804066 0.4755689629459182 0.5754903414024529 0.6291586786222989 0.7022867555790749 0.795485013028978 0.910369514018574 0.5928377557164907 -0.8699316645808188

@nikhilwoodruff
Copy link
Collaborator Author

Here are the plots (some look a bit weird to me, but I don't fully understand everything here):
plots.zip

@nikhilwoodruff
Copy link
Collaborator Author

nikhilwoodruff commented Dec 21, 2021

And finally, here's the full output

@jdebacker
Copy link
Member

@nikhilwoodruff That's great - thanks for testing this and sharing the update.

@jdebacker
Copy link
Member

@nikhilwoodruff I was trying to replicate what you did and was having some issue. I removed and reinstalled the environment. Now I'm getting the following error (which I noticed on a recent PR by @MaxGhenis):

distributed.worker - WARNING -  Compute Failed
Function:  get_calculator_output
args:      (True, 2021, None, 'frs')
kwargs:    {}
Exception: KeyError("Unable to open object (object 'state_id' doesn't exist)")

This looks related to the OpenFisca-UK data -- can you advise on the work around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants