Giter Site home page Giter Site logo

pslmodels / behavioral-responses Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 14.0 190 KB

PSL module that estimates partial-equilibrium behavioral responses to tax changes simulated by Tax-Calculator

License: Other

Makefile 6.92% Batchfile 12.77% Shell 2.73% Python 77.57%
psl-cataloged

behavioral-responses's People

Contributors

jdebacker avatar martinholmer avatar matthjensen avatar maxghenis avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

behavioral-responses's Issues

Add defaults to quantity_response

The quantity_response function currently requires all inputs, which are required if simulating both substitution and income effects. Some defaults can help simplify its usage if just simulating one or the other.

Other than quantity, I think all the inputs can default to either 0 or None and then set to something zero-like in the function.

Suggestion regarding python versions

I ran into an issue when installing behresp to my personal computer. Specifically, it is incompatible with Python 3.8. Ultimately, I got everything to work by setting the python version in taxcalc virtual environment to 3.7.

I don't know what the best practices are with respect to python versions, but it might be worth while to either 1) update behresp to work with the newest version or 2) instruct users in how to set their python version so that everything works.

Need for more variables returned from response function

In the original design of the Behavioral-Responses response function, it returned two DataFrame objects: the 22 DISTRIBUTION_VARIABLES from the pre-reform Calculator object passed to the function and the 22 DISTRIBUTION_VARIABLES from the post-reform Calculator object passed to the function including the effects of the behavioral responses. This design returned all the variables needed to construct diagnostic, distribution, and difference tables, and hence, met all the high-level data demands of the TaxBrain webapp and Python users constructing the standard tables.

But it has recently come to light that some users have an interest in seeing additional variables that are currently internal to the response function. This is a legitimate enhancement request but nobody had raised an issue describing their extra-data needs and asking for those needs to be met. Because nobody else has done that, I'm doing that here. This is the place to describe your extra-response-data needs. When we have a clear description of the needs, we can discuss how to meet these needs in a safe and efficient manner.

The first evidence of an extra-response-data need was in this PR #37 comment by @MattHJensen:

  • In order to conduct the original exploratory analysis to determine that [issue] #36 was a problem, I needed to look at how behresp was acting on individual records, and so I was working with a modified fork of Behavioral-Responses that returned the calculator.

  • It was taking me a long time to figure out how to write a failing test for this problem w/o being able to look at the microdata, but it is easy with the microdata and I was able to do so quickly.

  • We have seen many users take advantage of the tc --dump capabilities. Without returning the calculator, I don't know how users could do similar work with Behavioral-Responses.

  • I have seen another user modify a fork of Behavioral-Responses to return the Calculator object in order to try to figure out what is going on in the microdata.

And then @andersonfrailey said he was the user referred to in the fourth bullet:

I was working with Behavioral-Response a few weeks ago and I wanted to look at some of the data that isn't included in the distribution table DataFrame that gets returned by the response function.

In order to figure out how to meet these extra-response-data needs in a safe and efficient manner, I need a description of the problems users are experiencing. It is not appropriate to discuss solution options until we have a description of the problem. Which extra response variables (other the the 22 variables already returned) were needed ?

Pytest not installed with behresp-dev env

The pytest package is not installed as part of the behresp-dev environment. This was surprising, given that pytest is a dependency of taxcalc, which is a dependency of behresp, but maybe there's been a change in how conda handles such dependencies.

Should pytest be added as a dependency? Are any other packages being missed?

(base) jason.debacker@x86_64-apple-darwin13 Behavioral-Responses % conda env create
Collecting package metadata (repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 4.8.3
  latest version: 4.8.4

Please update conda by running

    $ conda update -n base -c defaults conda



Downloading and Extracting Packages
bokeh-2.2.0          | 5.4 MB    | ##################################### | 100%
wheel-0.35.1         | 37 KB     | ##################################### | 100%
setuptools-49.6.0    | 747 KB    | ##################################### | 100%
sqlite-3.33.0        | 1.3 MB    | ##################################### | 100%
typing_extensions-3. | 28 KB     | ##################################### | 100%
olefile-0.46         | 33 KB     | ##################################### | 100%
pip-20.2.2           | 1.7 MB    | ##################################### | 100%
cryptography-3.0     | 565 KB    | ##################################### | 100%
fsspec-0.8.0         | 70 KB     | ##################################### | 100%
taxcalc-3.0.0        | 30.3 MB   | ##################################### | 100%
pandas-1.1.1         | 8.0 MB    | ##################################### | 100%
tbb-2020.2           | 155 KB    | ##################################### | 100%
ca-certificates-2020 | 124 KB    | ##################################### | 100%
cffi-1.14.2          | 220 KB    | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate behresp-dev
#
# To deactivate an active environment, use
#
#     $ conda deactivate

(base) jason.debacker@x86_64-apple-darwin13 Behavioral-Responses % conda activate behresp-dev
(behresp-dev) jason.debacker@x86_64-apple-darwin13 Behavioral-Responses % ls
LICENSE.md		behresp			gitpr.bat
Makefile		behresp.egg-info	gitsync
PSL_catalog.json	conda.recipe		gitsync.bat
README.md		continuous_integration	pytest.ini
RELEASES.md		docs			setup.py
RELEASING.md		environment.yml
appveyor.yml		gitpr
(behresp-dev) jason.debacker@x86_64-apple-darwin13 Behavioral-Responses % cd behresp
(behresp-dev) jason.debacker@x86_64-apple-darwin13 behresp % pytest
zsh: command not found: pytest
(behresp-dev) jason.debacker@x86_64-apple-darwin13 behresp % conda list
# packages in environment at /Users/jason.debacker/anaconda3/envs/behresp-dev:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl
bokeh                     2.2.0                    py38_0
brotlipy                  0.7.0           py38haf1e3a3_1000
ca-certificates           2020.7.22                     0
certifi                   2020.6.20                py38_0
cffi                      1.14.2           py38hed5b41f_0
chardet                   3.0.4                 py38_1003
cryptography              3.0              py38hddc9c9b_0
freetype                  2.10.2               ha233b18_0
fsspec                    0.8.0                      py_0
idna                      2.10                       py_0
intel-openmp              2019.4                      233
jinja2                    2.11.2                     py_0
jpeg                      9b                   he5867d9_2
lcms2                     2.11                 h92f6f08_0
libcxx                    10.0.0                        1
libedit                   3.1.20191231         h1de35cc_1
libffi                    3.3                  hb1e8313_2
libllvm9                  9.0.1                h21ff451_1
libpng                    1.6.37               ha441bb4_0
libtiff                   4.1.0                hcb84e12_1
llvm-openmp               10.0.0               h28b9765_0
llvmlite                  0.33.0           py38ha11be7d_1
lz4-c                     1.9.2                hb1e8313_1
markupsafe                1.1.1            py38h1de35cc_1
marshmallow               3.7.1                      py_0
mkl                       2019.4                      233
mkl-service               2.3.0            py38hfbe908c_0
mkl_fft                   1.1.0            py38hc64f4ea_0
mkl_random                1.1.1            py38h959d312_0
ncurses                   6.2                  h0a44026_1
numba                     0.50.1           py38h959d312_1
numpy                     1.19.1           py38h3b9f5b6_0
numpy-base                1.19.1           py38hcfb5961_0
olefile                   0.46                       py_0
openssl                   1.1.1g               h1de35cc_0
packaging                 20.4                       py_0
pandas                    1.1.1            py38hb1e8313_0
paramtools                0.15.0             pyh9f0ad1d_0    conda-forge
pillow                    7.2.0            py38ha54b6ba_0
pip                       20.2.2                   py38_0
pycparser                 2.20                       py_2
pyopenssl                 19.1.0                     py_1
pyparsing                 2.4.7                      py_0
pysocks                   1.7.1                    py38_1
python                    3.8.5                h26836e1_0
python-dateutil           2.8.1                      py_0
pytz                      2020.1                     py_0
pyyaml                    5.3.1            py38haf1e3a3_1
readline                  8.0                  h1de35cc_0
requests                  2.24.0                     py_0
setuptools                49.6.0                   py38_0
six                       1.15.0                     py_0
sqlite                    3.33.0               hffcf06c_0
taxcalc                   3.0.0                    py38_0    PSLmodels
tbb                       2020.2               h879752b_0
tk                        8.6.10               hb0a8c7a_0
tornado                   6.0.4            py38h1de35cc_1
typing_extensions         3.7.4.3                    py_0
urllib3                   1.25.10                    py_0
wheel                     0.35.1                     py_0
xz                        5.2.5                h1de35cc_0
yaml                      0.2.5                haf1e3a3_0
zlib                      1.2.11               h1de35cc_3
zstd                      1.4.5                h41d2c2f_0

Simulate extensive margin

behresp currently simulates income changes on the intensive margin only,* i.e. changing the hours worked or wage to vary income conditional on employment.

Could it also model the extensive margin, i.e. decisions to enter or exit the labor force?

Chetty et al (2011) includes a meta-analysis of micro evidence estimating that steady-state substitution elasticities are roughly split between intensive and extensive. The extensive margin is particularly important for women.

Exit would be simpler to model than entry, since the latter involves imputing a new income level for people currently. This could be done by modeling the conditional distribution of people with income, or alternatively by shuffling weights between filing units with income vs. those without.

* The response function documentation cites two papers: Gruber and Saez (2002) does not mention intensive/extensive margins, and a scan of Feldstein and Feenberg (1995) discusses participation but I'm not sure if it models it specifically.

Should CG income be included in the base for calculating ETI substitution effect?

Currently the substitution effect is calculated using taxable income (c04800) as the base. See https://github.com/PSLmodels/Behavioral-Responses/blob/master/behresp/behavior.py#L199.

If one were to apply both a non-zero substitution elasticity and a non-zero long-term capital gains elasticity, does it mean that we are double counting some behavior?

And if so, would a reasonable solution be to remove LTCG from the substitution effect by subtracting it from c04800 prior to the calculation of the substitution effect?

If one were to model short-term capital gains separately, would STCG also need to be subtracted from c04800 prior to the calculation of the substitution effect?

--

This is related to PSLmodels/Tax-Calculator#2189, so cc @andersonfrailey @codykallen @MaxGhenis.

This is related to PSLmodels/Tax-Calculator#2180, so cc @evtedeschi3 @martinholmer.

Given Dan's familiarity with the ETI literature, cc @feenberg.

Allow array of elasticities in quantity_response

Currently the quantity_response function requires the elasticity inputs to be constants, as enforced by its checks for whether each equals zero, e.g.

if price_elasticity == 0.:
pch_price = np.zeros(quantity.shape)

Allowing for these to be arrays with the same length as other arrays would enable users to use different elasticities for different groups, e.g. by income, as has been reported in various studies.

This should be as simple as replacing the code above and that below it with

atp1 = np.where(aftertax_price1 < 0.01, 0.01, aftertax_price1)
atp2 = np.where(aftertax_price2 < 0.01, 0.01, aftertax_price2)
pch_price = np.where(price_elasticity == 0., 0., atp2 / atp1 - 1.)

Though I'm also wondering if the if price_elasticity == 0.: pieces are necessary. If an elasticity is zero, it'll get assigned to zero in this line at the end:

pch_q = price_elasticity * pch_price + income_elasticity * pch_income

Can these if statements be removed?

Trouble installing version 0.11.0

I'm trying to install the latest version and running into some trouble. It seems like conda thinks this version can't be installed with python versions above 3.5. I've attached a screen shot with the error message I get.
Screen Shot 2020-10-05 at 5 04 11 PM

Version 0.10.0 works as expected for up to python 3.7.

I was looking through the latest PRs and the various set up files and I have no idea what could be causing the issues here. I'll keep trying and see if I can find anything.

cc @MattHJensen @jdebacker

"No module named 'behresp'" in Colab

After installing behresp in Colab using the below commands (notebook), import behresp fails:

!wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh && bash Miniconda3-latest-Linux-x86_64.sh -bfp /usr/local
# Append path to be able to run packages installed with conda
import sys
# This must correspond to the conda Python version, which may differ from
# the base Colab Python installation.
sys.path.append('/usr/local/lib/python3.8/site-packages')
# Install PSL packages from Anaconda
!yes | conda install -c conda-forge paramtools
!yes | conda install -c PSLmodels taxcalc behresp

...
The following NEW packages will be INSTALLED:
...
behresp PSLmodels/linux-64::behresp-0.11.0-py38_0
...

import taxcalc  # No error.
import behresp

ModuleNotFoundError: No module named 'behresp'

This works fine when I run in a new conda environment locally.

Create a `behresp` package on PyPI

Installing from Conda takes a long time, requires a cumbersome release process, and requires one install Anaconda (or mini conda) making it difficult to install packages on Google Colab.

Because of this, it would be useful to create a release of the Behavioral Responses package on PyPI so the package can be installed with pip.

Make Copies of Calculators Optional

Currently, Behavioral-Responses makes three copies of the calculator objects passed as arguments to the response function. The first two are made right when the function starts running, and the third occurs further along when adding the behavioral-response changes to income.

It's clear why we would want to make a copy before changing income, and I can see an argument for why we would want to make copies of the original copies from the beginning. However, could we add an argument to the responses function that makes creating these copies optional? From what I can see, there are no modifications being made to the calc1 and calc2 variables, only the copy of calc2. Of course I could be missing something obvious.

Making the copies optional would significantly reduce the amount of memory needed for partial equilibrium simulations, which would be especially helpful in Tax-Brain.

cc @hdoupe

Revise environment.yml file to remove taxcalc pinning

Now the environment.yml file has these contents:

name: behresp-dev
channels:
- PSLmodels
dependencies:
- python
- "taxcalc>=1.0"

After a period of time (and everybody is using taxcalc 1.0+), the last line above should be changed to:

- taxcalc

This change will make it easier to create for testing a local behresp package that uses a local taxcalc package, which is version 0.0.0.

Update recommendation of CBO-equivalent CG semi-elasticity

We should update our recommendation of a CBO equivalent capital gains semi-elasticity as the passage of TCJA and other modest factors will have changed the EMTR for long term capital gains, which is relevant to the conversion CBO/JCT research to our calculator. I doubt this will make a big difference, but it is worth doing for peace of mind.

See relevant thread:
PSLmodels/Tax-Calculator#1065

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.