PSLmodels / OG-Core

An overlapping generations model framework for evaluating fiscal policies.
https://pslmodels.github.io/OG-Core/
Creative Commons Zero v1.0 Universal
65 stars 111 forks source link

Updates to `txfunc.py` #932

Closed jdebacker closed 3 months ago

jdebacker commented 3 months ago

This PR will make the following changes:

  1. Add another form for individual income tax functions from Heathcote, Storesletten, and Violante (QJE, 2017). It's helpful to add these because they are simple to estimate (one can use OLS), allow for progressive taxes, and are widely used in the macroeconomics literature.
  2. Improve the choice of starting values when minimizing tax functions via weighted, non-linear least squares.
jdebacker commented 3 months ago

HSV function estimates (age specific, each line representing a different age)

ETRs

HSV_PUF_etr

MTR, labor income

HSV_PUF_mtrx

MTR, capital income

HSV_PUF_mtry

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 30.76923% with 54 lines in your changes missing coverage. Please review.

Project coverage is 72.44%. Comparing base (0261fbf) to head (3da5b4a).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932/graphs/tree.svg?width=650&height=150&src=pr&token=98mQCVhspd&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels)](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) ```diff @@ Coverage Diff @@ ## master #932 +/- ## ========================================== - Coverage 72.76% 72.44% -0.32% ========================================== Files 19 19 Lines 4644 4696 +52 ========================================== + Hits 3379 3402 +23 - Misses 1265 1294 +29 ``` | [Flag](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | `72.44% <30.76%> (-0.32%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | Coverage Δ | | |---|---|---| | [ogcore/\_\_init\_\_.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932?src=pr&el=tree&filepath=ogcore%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [ogcore/txfunc.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932?src=pr&el=tree&filepath=ogcore%2Ftxfunc.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL3R4ZnVuYy5weQ==) | `30.58% <29.87%> (+1.05%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/932/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels)
jdebacker commented 3 months ago

Currently tests pass on Mac OS, fail on Linux (not yet run on Windows). Test failure is with the SSE from the regressions for the HSV functions. These are computed via simple matrix operations and thus I'm surprised there is any difference across platforms. @rickecon Any ideas why dot products would not be identical across platforms?

jdebacker commented 3 months ago

@rickecon This PR is ready for your review.

The changes to starting values (which apply to the GS and DEP functions only) are to estimate the specified tax functions for all ages via a global optimizer (in this case, scipy.optimize.differential_evolution), then use these parameter estimates for the initial guess for the first age group. Following that, the parameter estimates for each age are used as starting values for the next age.

rickecon commented 3 months ago

@jdebacker. The Linux/Python 3.10 test seems to be stalled out. I wonder what is going on with the tests. I am just waiting for these all to pass. I approved all the code changes.

rickecon commented 3 months ago

@jdebacker. This looks great and all checks have passed. Merging.