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

Create income.py interpolant for general S and J #230

Closed rickecon closed 8 years ago

rickecon commented 8 years ago

I am currently working on making the income.py module robust to general ages and ability types S and J. The module currently only works with S=80 and J=7. Because the resulting 80 x 7 ability matrix is smooth, we can simply use scipy.interpolate.griddata() to interpolate this.

I currently have a function written that takes general S and J midpoints of income distribution bins to interpolate ability matrix values. The following 3D plot is the original 80 x 7 ability matrix. ability_orig A version that I interpolated using the above described griddata() function with S=20 and ability distribution midpoints of np.linspace(0.15, 0.95, 10) gives the following interpolated plot. ability_interp This looks right. I now need to incorporate this function into income.py and into parameters.py, which calls the get_e function from income.py. @jdebacker

rickecon commented 8 years ago

I was originally trying to use some bivariate kernel density estimation code to do this. But that approach is better when the data need to be smoothed. This original data in the first plot above is already smooth. So a simple interpolator works best.

rickecon commented 8 years ago

By the way, the second picture above uses the "...method='linear'" option. The "cubic" option, for cubic spline, gives too many curves. See the following graph. The linear interpolation method above is clearly better. ability_interp_spl

rickecon commented 8 years ago

@jdebacker , @kerkphil : I now have this working for calculating the steady-state with S=20 and J=1. It does not converge in the steady-state for anything lower than S=20. Now I just need to make sure that TPI works.