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

Enhance MTR graphing utility functions #1020

Merged
merged 20 commits into from
Nov 1, 2016
Merged

Enhance MTR graphing utility functions #1020

merged 20 commits into from
Nov 1, 2016

Conversation

martinholmer
Copy link
Collaborator

@martinholmer martinholmer commented Oct 28, 2016

This pull request builds on from the substantial contribution made by @GoFroggyRun in merged pull request #948. Read the two mtr_graph_* function docstrings for details on how this plotting capability works now.

Most of the changes rationalize exiting features or add new capabilities. But the logic of MARS filtering option was changed so that the the income percentiles are constructed after the filtering (not before).

I'm interested in receiving comments and suggestions on how this can be further improved.

@MattHJensen @feenberg @Amy-Xu @GoFroggyRun @andersonfrailey @codykallen @zrisher

@codecov-io
Copy link

codecov-io commented Oct 28, 2016

Current coverage is 98.48% (diff: 100%)

Merging #1020 into master will increase coverage by 0.27%

@@             master      #1020   diff @@
==========================================
  Files            35         35          
  Lines          2180       2243    +63   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           2141       2209    +68   
+ Misses           39         34     -5   
  Partials          0          0          

Powered by Codecov. Last update c8ce60f...023eb74

@codykallen
Copy link
Contributor

mtr_plot uses two lines of deprecated code. Lines 984 and 985 have:
fig.legend.legend_spacing = 5
fig.legend.legend_padding = 5

However, the latest documentation indicates that this should be coded as:
fig.legend.spacing = 5
fig.legend.padding = 5

Source here, at the bottom of the page
: http://bokeh.pydata.org/en/latest/docs/user_guide/styling.html#legends

@martinholmer
Copy link
Collaborator Author

@codykallen said:

mtr_graph_plot uses two lines of deprecated code. Lines 984 and 985 have:
fig.legend.legend_spacing = 5
fig.legend.legend_padding = 5

However, the latest documentation indicates that this should be coded as:
fig.legend.spacing = 5
fig.legend.padding = 5

Thanks for pointing this out, @codykallen. I found I was using an older version of bokeh. Now that I've upgraded to version 0.12.3 (and added that requirement to the environment.yml file) and changed the mtr_graph_plot code, these warning messages no longer appear.

@martinholmer martinholmer changed the title Correct and enhance MTR graphing utility functions Enhance MTR graphing utility functions Oct 29, 2016
@martinholmer
Copy link
Collaborator Author

I've generated and looked at quite a few mtr graphs and now think the work on this pull request is complete. But I'm hoping others will use the pull request code and the puf.csv file to generate other graphs to see if they make sense.

In order to help in that effort, I'm posting here a script that generates 18 different versions of the e00200p MTR graph for a pop-the-cap social security payroll tax reform. I can't figure out how to convert the resulting HTML file (which contains all 18 graphs) into one PNG file that I can post here. So, I'll post after the script just two of the graphs that were puzzling to me. Do you think they make sense?

First, the following script is in the mtr-graphs.py file located in top directory of the Tax-Calculator code tree along with the puf.csv file and is invoked like this: python mtr-graphs.py.

from taxcalc import *
import bokeh.layouts as blayout
ref = {2013: {'_SS_Earnings_c': [1e99]}}  # "pop-the-cap" reform in 2013
bp.output_file('mtr-graphs.html', title='MTR by Income Percentile')
gplots = list()
for inc in ['wages', 'agi', 'expanded_income']:
    for mtr in ['ptax', 'itax', 'combined']:
        for dwt in [False, True]:
            calc1 = Calculator(policy=Policy(), records=Records())
            calc2 = Calculator(policy=Policy(), records=Records())
            calc2.policy.implement_reform(ref)
            gdata = mtr_graph_data(calc1, calc2,
                                   mars='ALL',
                                   mtr_measure=mtr,
                                   mtr_wrt_full_compen=False,
                                   income_measure=inc,
                                   dollar_weighting=dwt)
            gplot = mtr_graph_plot(gdata)
            gplots.append(gplot)
bp.show(blayout.column(gplots))

Second, here are two of the 18 graphs generated by the above script.

image

image

@MattHJensen @feenberg @Amy-Xu @GoFroggyRun @andersonfrailey @codykallen @zrisher

@martinholmer
Copy link
Collaborator Author

If there are no concerns about pull request #1020, it will be merged at end of the Nov 1st workday.

@MattHJensen @feenberg @Amy-Xu @GoFroggyRun @andersonfrailey @codykallen @talumbau

@martinholmer martinholmer merged commit a21bb94 into PSLmodels:master Nov 1, 2016
@martinholmer martinholmer deleted the mtr-graph0 branch November 1, 2016 22:32
@MattHJensen
Copy link
Contributor

MattHJensen commented Nov 2, 2016

Thanks a lot @martinholmer. I expect that #1021 means there is no longer a change in MTR for IIT when you pop the cap as is shown in the second graph above. Do you have any ideas at this point about what is causing the blips for payroll tax MTR for the 15-20 percentiles of AGI in the first chart?

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

Successfully merging this pull request may close these issues.

5 participants