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

Add utility functions that generate a change-in-aftertax-income-by-decile graph #1606

Merged
merged 9 commits into from
Nov 4, 2017
Merged

Add utility functions that generate a change-in-aftertax-income-by-decile graph #1606

merged 9 commits into from
Nov 4, 2017

Conversation

martinholmer
Copy link
Collaborator

@martinholmer martinholmer commented Oct 26, 2017

This pull request, which is built on pull request #1605, adds two new functions to the utils.py file: dec_graph_data and dec_graph_plot. Working together, these two functions generate a horizontal bar chart showing the percent change in after-tax expanded income induced by a tax reform for each of twelve expanded-income groups: the lower nine deciles plus the bottom half of the top decile, the next four percentiles, and the top percentile. The generated graph looks similar to the New York Times graph shown in issue #1592 except that only the total reform effect is shown (that is, there is no detail for any of the reform's component provisions). In other words, I don't get any "bonus points".

Here is example that shows what the generated graph looks like. This example analyzes a revenue-neutral reform that broadens the OASDI FICA tax base and reduces the OASDI FICA tax rate beginning in 2020.

    reform = {
        2020: {
            '_SS_Earnings_c': [9e99],  # OASDI FICA tax on all earnings
            '_FICA_ss_trt': [0.107484]  # lower 0.124 rate to keep revenue unchanged
        }
    }

The functions can be used to generate a graph without labels on the axes (like in the New York Times) or with labels on the axes (which might be useful detail for a more technical audience). The no-axis-labels code and graph are shown first, then the other version after that.

No Axis Labels

    pol = Policy()
    rec = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=rec)
    year = 2020
    reform = {
        year: {
            '_SS_Earnings_c': [9e99],  # OASDI FICA tax on all earnings
            '_FICA_ss_trt': [0.107484]  # lower 0.124 rate to keep revenue unchanged

        }
    }
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc1.advance_to_year(year)
    calc2.advance_to_year(year)
    gdata = dec_graph_data(calc1, calc2)
    gplot = dec_graph_plot(gdata, xlabel=' ', ylabel=' ')
    write_graph_file(gplot, 'example1.html', 'Example1 Plot')

screen shot 2017-10-26 at 2 08 50 pm

With Axis Labels

    pol = Policy()
    rec = Records.cps_constructor(data=cps_subsample)
    calc1 = Calculator(policy=pol, records=rec)
    year = 2020
    reform = {
        year: {
            '_SS_Earnings_c': [9e99],  # OASDI FICA tax on all earnings
            '_FICA_ss_trt': [0.107484]  # lower 0.124 rate to keep revenue unchanged

        }
    }
    pol.implement_reform(reform)
    calc2 = Calculator(policy=pol, records=rec)
    calc1.advance_to_year(year)
    calc2.advance_to_year(year)
    gdata = dec_graph_data(calc1, calc2)
    gplot = dec_graph_plot(gdata, xlabel='', ylabel='')
    write_graph_file(gplot, 'example1.html', 'Example1 Plot')

screen shot 2017-10-26 at 2 09 18 pm

Any comments or suggestions are welcome.

After an extended review period (and possible revisions to this graph), this graph will be added to the output generated by the --graphs option of the Tax-Calculator CLI, tc, in another pull request.

@codecov-io
Copy link

codecov-io commented Oct 26, 2017

Codecov Report

Merging #1606 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1606   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          37      37           
  Lines        2786    2852   +66     
======================================
+ Hits         2786    2852   +66
Impacted Files Coverage Δ
taxcalc/utils.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a2cd056...e2d724c. Read the comment docs.

@MattHJensen
Copy link
Contributor

This is fantastic. Thanks @martinholmer!

What do you think about calling it "income" instead of "expanded income" and then add an optional note(s) on the bottom that defines what "income" is? Could also have an optional source label that gives tax-calculator version. I don't see either of these possible enhancements as necessary for merging this PR, though.

@martinholmer
Copy link
Collaborator Author

As part of an extensive discussion in issue #1592, @MattHJensen made an excellent suggestion about how to improve the proposed graph:

Another approach would be to include the top 10% decile and then create some subtle visual separation between the bars for the 10 deciles and the bars for 90-95, 90-99, and top 1. They could be separated by a dotted line, say, or could be a different color, or both.

Pull request #1606 has been updated to change the graph along these lines. Here is the graph (without any axis labels) for the reform described here:

screen shot 2017-10-28 at 12 03 33 pm

Any suggestions about how to further improve the graph are welcome.

@evtedeschi3 @feenberg @Amy-Xu @andersonfrailey @hdoupe @GoFroggyRun @codykallen @hayleefay

@martinholmer
Copy link
Collaborator Author

@MattHJensen asked:

What do you think about calling it "income" instead of "expanded income" and then add an optional note(s) on the bottom that defines what "income" is? Could also have an optional source label that gives tax-calculator version. I don't see either of these possible enhancements as necessary for merging this PR, though.

The default axis labels are meant for a technical audience, so I think it is appropriate to use the term "expanded income", which clarifies what income concept is being used. However, the proposed dec_graph_plot utility function allows users to specify their own x-axis label and their own y-axis label (including having no label), so users can easily generate graphs with axis labels customized to their audience.

I don't know how to use bokeh to generate "note(s) on the bottom" or an "optional source label".

@MattHJensen
Copy link
Contributor

This looks great.

@martinholmer martinholmer merged commit a3614a1 into PSLmodels:master Nov 4, 2017
@martinholmer martinholmer deleted the decile-change-graph branch November 10, 2017 02:38
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.

4 participants