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

Generalize spline tax functions to 2D #828

Closed
jdebacker opened this issue Nov 28, 2022 · 10 comments · Fixed by #839
Closed

Generalize spline tax functions to 2D #828

jdebacker opened this issue Nov 28, 2022 · 10 comments · Fixed by #839

Comments

@jdebacker
Copy link
Member

This issue is to discuss the extrapolation of the spline tax functions introduced in PR #819 to two dimensions, where those two dimensions are capital and labor income.

The key is to continue to implement the constraints that ensure the functions are monotonic.

cc @prrathi @rickecon

@prrathi
Copy link
Contributor

prrathi commented Dec 1, 2022

@jdebacker @rickecon Should 'mono' also be included in the choices for tax_func_type section of default_parameters.json, doesn't seem to be there currently.

@rickecon
Copy link
Member

rickecon commented Dec 8, 2022

The code for our one-dimensional monotone smoothing spline is in txfunc.py lines 669-690, 1635-1780 (mainly lines 1646-1694). This approach was taken from this site and these citations Eilers (2005, 2003) and Eilers and Marx (1996). This approach is a smoothing spline with a penalty on any nonmonotonicities (negative slope).

@jdebacker
Copy link
Member Author

the cm.spline function in R seems relevant here.

@rickecon
Copy link
Member

Some other references:

cc: @jdebacker @prrathi

@prrathi
Copy link
Contributor

prrathi commented Dec 20, 2022

@jdebacker @rickecon would you happen to have a pdf version of Unimodal smoothing by Eilers? I don't think I have institutional access to the paper

@prrathi
Copy link
Contributor

prrathi commented Dec 22, 2022

@jdebacker @rickecon is monotonicity the only requirement here or does smoothness/continuity of derivatives matter?

@rickecon
Copy link
Member

@prrathi monotonicity and C2 (continuity in the levels and in the first derivative) I don't think we need continuity in the second derivative, but I don't know. It probably depends on the optimizer. But I think a property of generalized additive models is that if the kernel is C2, then the final predictor is C2.

@prrathi
Copy link
Contributor

prrathi commented Dec 22, 2022

@rickecon making some progress here with pyGAM that allows monotonic constraints and smoothing up to the second derivative. I need to test it out with different data- would you have a good source for tax data like plotted here?

@jdebacker
Copy link
Member Author

@prrathi You could work with the micro data (produced from a Current Population Survey data file) that is in micro_data_for_tests.pkl

@prrathi
Copy link
Contributor

prrathi commented Dec 24, 2022

@rickecon @jdebacker able to fit the tax data using pyGAM. I first bin the data along both axes- labor income and capital income- (wrote a general function that should apply to any number of dimensions) and then fit the model using the weighted results. There are parameters/configurations to test around with like number and degree of splines, I've attached some pictures, the following three are different angles of same result for 100 by 100 bins with 20 splines for each labor and capital income:
angle3
angle2
origAngle

These three are for 100 by 100 bins with 100 splines for each labor and capital income:
2angle3
2angle2
2origangle

The data for the plots is only from the middle 50% of both labor and capital incomes to make trends more clear, but the models were trained on all data. For 20 splines fit mean deviation for middle 50% of both incomes is 0.08669 (units of etr), for 100 splines mean deviation for middle 50% is 0.08517, excluded some of the really big outliers (especially on the upper end) for this comparison

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 a pull request may close this issue.

3 participants