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

Revise Calculator decile_graph method to use new distribution table #1918

Merged
merged 11 commits into from
Mar 16, 2018
Merged

Revise Calculator decile_graph method to use new distribution table #1918

merged 11 commits into from
Mar 16, 2018

Conversation

martinholmer
Copy link
Collaborator

@martinholmer martinholmer commented Mar 12, 2018

This pull request revises the Calculator.decile_graph method to allow graphing of the bottom decile to include or not those filing units with zero expanded_income and to include or not those filing units with negative expanded_income. This approach leaves it up to the Tax-Calculator user how to display the percentage change in after-tax expanded income for the bottom decile in the graph.

Given the new method, the following script (which uses the same reform as in #1917) produces the following four graphs:

from __future__ import print_function  # necessary only if using Python 2.7
from taxcalc import *

# select either CPS data or PUF data
recs = Records.cps_constructor()
# recs = Records()

# specify Calculator object for static analysis of current-law policy
pol = Policy()
calc1 = Calculator(policy=pol, records=recs)

cyr = 2020

# specify Calculator object for static analysis of adding a tax-exempt UBI
reform = {cyr: {'_UBI_u18': [1e4], '_UBI_1820': [1e4], '_UBI_21': [1e4],
                '_UBI_ecrt': [1.0]}}
pol.implement_reform(reform)
if pol.reform_errors:  # check for reform error messages
    print(pol.reform_errors)
    exit(1)
calc2 = Calculator(policy=pol, records=recs)

# calculate baseline and reform Calculator objects
calc1.advance_to_year(cyr)
calc1.calc_all()
calc2.advance_to_year(cyr)
calc2.calc_all()

# generate decile graph for cyr
fig = calc1.decile_graph(calc2,
                         include_zero_incomes=True,
                         include_negative_incomes=True)
write_graph_file(fig, 'graph.html', 'DECILE GRAPH')

Here is the graph when using CPS input data and including all the zeros and negatives in the bottom decile:

cps-tt

Here is the graph when using CPS input data and excluding all the zeros and negatives in the bottom decile:

cps-ff

Here is the graph when using PUF input data and including all the zeros and negatives in the bottom decile:

puf-tt

And here is the graph when using PUF input data and excluding all the zeros and negatives in the bottom decile:

puf-ff

@codecov-io
Copy link

codecov-io commented Mar 12, 2018

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1918   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          38      38           
  Lines        3605    3625   +20     
======================================
+ Hits         3605    3625   +20
Impacted Files Coverage Δ
taxcalc/utils.py 100% <100%> (ø) ⬆️
taxcalc/calculate.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 a92f8aa...28867f0. Read the comment docs.

@MattHJensen
Copy link
Contributor

LGTM. Thanks very much @martinholmer and everyone who participated in the discussion that led here!

@MattHJensen MattHJensen merged commit 0f3cf9f into PSLmodels:master Mar 16, 2018
@martinholmer martinholmer deleted the revise-dec-graph branch March 16, 2018 20:12
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.

3 participants