-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Add MTR Plotting #948
Add MTR Plotting #948
Conversation
@talumbau, do you have any feedback on this PR? I'll be interested to hear from @martinholmer once he is back in town next week as well. Is there anything @GoFroggyRun could add to help you assess this? The goal is to start adding some out-of-the-box plotting capabilities to TC. I expect we'll have several other default plots we'll want to add as well. |
@GoFroggyRun, do you know what's going on w the test failures? |
@MattHJensen , it seems that the test failures are coming from the fact that Bokeh is not installed on TravisCI (and I am not so sure how to install). There's no test error on my local machine. |
Sorry for the delay in reply. This is an interesting PR and definitely adds new capabilities to Tax-Calculator. With this PR as-is, it would mean that |
To answer @GoFroggyRun's question about how to install https://github.com/open-source-economics/Tax-Calculator/blob/master/.travis.yml#L16 you should change it to include
|
@talumbau suggested:
I like this suggestion, but if this suggestion is followed how do the unit tests work? Can |
@GoFroggyRun, I don't understand your proposed new file called |
Thanks for your comments. I added the
I agreed as well. But I'm having similar concerns, which is how do the unit tests work if we were not forcing After adding
I have no idea why I'm having such error message, as this |
Current coverage is 98.02% (diff: 93.39%)@@ master #948 diff @@
==========================================
Files 35 35
Lines 2089 2181 +92
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 2053 2138 +85
- Misses 36 43 +7
Partials 0 0
|
@GoFroggyRun, You need to add more tests of your new code in pull request #948. |
@martinholmer: |
@GoFroggyRun said:
Good. I'll try to do some plotting with this pull request soon and give you some feedback. But meanwhile, what is the answer to my question about what is going to happen on computers where bokeh is not installed. What is going to happen with the unit tests? It is not acceptable that they fail given all the reasons advanced by @talumbau. |
Sorry for the delay in reply. If this PR is functionally complete, I would like to suggest some additional commits, which I can do as a pull request to Sean's branch. The commits that I will add will make the following changes:
|
@talumbau said:
@talumbau, These contributions would be very much appreciated, especially the last one. |
@martinholmer sorry about the delay. Just addressed all your comments in the latest commit, please take a look. |
@GoFroggyRun said:
This is much better documentation of the If my interpretation is correct, I have two questions (one minor and one major) about the effect of changing complex_weight from False to True. (1) Why do the percentile bins run from 0 to 99 when complex_weight=False, but run from 1 to 100 when complex_weight=True? This anomaly does nothing but create doubts in the minds of users. (2) Why are the graphs so different? [At this stage I should be able to show you the two very different looking graphs, but I don't know how to do that and there isn't any explanation about how to do that in the documentation of the
I ran it twice: once the way it is above and once with the two changes described in the comments. [I will send you a private email with the two HTML plots attached.] The plot of data generated with complex_weight=False, shows that the top 10% of (unweighted) filing units would have higher taxes. But the plot of data generated with complex_weight=True, shows that the top 45% of (weighted) filing units would have higher taxes. I simply do not believe that nearly half of the population will have higher taxes when the Social Security maximum taxable earnings is raised to infinity. Have I done something wrong? |
@martinholmer, regarding your concerns:
I changed the option name to
Fixed. Thanks for noticing this.
I just realized my wording wasn't quite right. The option actually allows |
@GoFroggyRun said in response to this question:
No, this does not make any sense to me. All I know is that the graph with the weight_by_income_measure=True does not make any sense. And, by the way, what's the answer to my question about how to embed these graphs in our conversation? |
@martinholmer said:
So the second plot doesn't any longer, after setting
Not sure what do you mean by embedding these graphs. Are you suggesting a different way of presenting the plots? |
@GoFroggyRun said:
The above explanation make sense (except for the confusing use of "activity". But the explanation above is not what is in the documentation of the @GoFroggyRun also said:
Here is a concrete example: how do I put a generated graph into a LaTeX document? I know how to display an EPS graph as a LaTeX figure, but how do I include your graphs in my document? Here is a second example: how do I show a generated graph in a GitHub (issue or pull request) conversation? |
@GoFroggyRun, I was using the MTR plotting capability as currently structured in pending pull request #948 and got a result that was puzzling to me. Here is the script I ran:
Here is a screenshot of what the I expected the red reform line to rise above the blue base line at high percentiles of filing unit earnings (e00200), but I did not expect to see any visible reform effect (that is, red higher than blue) at lower percentiles, certainly not between the 10th and 20th earnings percentile. When I uncommented the
I expect the reform MTR to be higher than the base MTR at the high earnings percentiles, but I can't think of a reason why there should be a reform effect at the three percentiles below the 20th percentile. Perhaps these results are showing me something about this tax reform that I don't understand and need to learn about. Can you think of what that might be? If not, is there some chance that your new |
@GoFroggyRun, This comment follows up my prior comment on puzzling MTR-plotting results for a "pop-the-cap" reform. The plot below is generated using exactly the same script as used in the prior comment except for one change, the Why is there no noticeable reform effect except in the 0-10th and 30-40th percentile ranges? This graph seems to be suggesting that nobody affected by the reform (which affects only those individuals with earnings above $113,700 in 2013) is in the top half of the AGI distribution. Can that really be true? |
@martinholmer: Regarding your following concerns, I believe they have gone beyond the scope of this PR for the following reasons:
That said, if there are records with odd MTRs and you'd like me to investigate, I'd be more than happy to take a look at them in a separate issue. Or, if there are cases where |
@GoFroggyRun, could you run @martinholmer's plot and see if you get the same thing. Once you have, could you try to identify whether the problem is with |
@GoFroggyRun, I have learned something on my own from the plot of average combined MTR by wage-and-salary (e00200) percentile for a pop-the-cap reform, which is shown again here: The increase in MTR for those just below the 20th wage-and-salary percentile is caused most likely by filing units with little or no wages-and-salaries, but considerable self-employment income. So that graph is no longer puzzling to me. However, I'm still puzzled by the plot of average combined MTR by AGI (c00100) percentile for a pop-the-cap reform, which is shown again here: My expectation is that AGI is unchanged by a pop-the-cap reform, whose reform dictionary is as follows:
So, your argument that "AGI (c00100) is a calculated value and thus would be variant under reforms" is true in general, but not in this case, unless I'm missing something. Am I missing something about the effects of this particular reform? |
All right. I have some very mysterious findings. First of all, @martinholmer is absolutely right about the plot. This is not how the plot should be looking like. The correct plot should be the following: I was able to generate the same plot in two, somewhat independent, ways. The first method is based on @martinholmer's script, but with modifications:
I'll prepare the other method in another post. |
Here's the other script that yields the same plot:
|
I'm very confused by the situation for the first script. The commands here
seem to be duplicated. It will, however, generate different result if either line got removed. Having no idea what's going on. cc @MattHJensen |
@GoFroggyRun, Let me be very clear about what I did. This is the script I executed by entering
Note that I have never called the As I said before, here is the plot this script shows in my browser: Why can't I produce what you say is the "correct" graph? |
@martinholmer I didn't say that you called the |
Ahh, looks like we forgot to call The following code generates the correct plot.
|
On Fri, 21 Oct 2016, Sean.Wang wrote:
Another way to understand s006*e00200 is that it will give us the effect BTW, is there a link to the page that this is about? dan
|
@GoFroggyRun, Thank your for your substantial contribution in pull request #948 that adds a marginal tax rate graphing capability. I'm merging this pull request into the master branch. |
This PR (mainly) adds two functions to
utils.py
file, namely theget_mtr_data()
function and themtr_plot
function. Some tiny modifications have been applied to certain current functions. (mostly generalizations, and their tests have been updated accordingly)Instructions, descriptions as well as test suites are available for the two aded functions. Also, the added
styles.py
file defines a few layout formats for the plot, which can be used for all further plotting.Comments, concerns or remarks on these functions are more than welcomed.
@MattHJensen @martinholmer
It seems that the Travis CI have failed since we don't really have Bokeh package installed. T.J. @talumbau, I was wondering would it be sufficient if I just add Bokeh to the
environment.yml
file? Please advice, thanks!