Open nikhilwoodruff opened 3 years ago
@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.
@jdebacker @rickecon could you share code for plotting tax functions? e.g. from pslmodels.github.io/OG-USA/content/calibration/tax_functions:
@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
.
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:
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
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
):
Also tried to reproduce the microdata side of that 3d plot:
@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.
Sorry I've just seen this @jdebacker - here's my recent progress ahead of our meeting later:
Again, seems like it's not a great fit, will try with the DEP function
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
This one is the Labour MTR - looks about right? (to clarify, the microdata points rather than the linear tax function)
And the capital MTR one:
@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).
@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.
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 |
Here are the plots (some look a bit weird to me, but I don't fully understand everything here): plots.zip
And finally, here's the full output
@nikhilwoodruff That's great - thanks for testing this and sharing the update.
@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?
@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 forr
(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?