From 44547a0ed7342208ddcc04cd9ddd5866cb15ca51 Mon Sep 17 00:00:00 2001 From: jdebacker Date: Sat, 28 Oct 2023 16:44:34 -0400 Subject: [PATCH] use cubic spline to interpolate ETI(z) if enough data --- iot/inverse_optimal_tax.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/iot/inverse_optimal_tax.py b/iot/inverse_optimal_tax.py index 98d403e..58f3c3b 100644 --- a/iot/inverse_optimal_tax.py +++ b/iot/inverse_optimal_tax.py @@ -67,8 +67,12 @@ def __init__( assert len(eti["knot_points"]) == len(eti["eti_values"]) # want to interpolate across income distribution with knot points # assume that eti can't go beyond 1 (or the max of the eti_values provided) + if len(eti["knot_points"]) > 3: + spline_order = 3 + else: + spline_order = 1 eti_spl = UnivariateSpline( - eti["knot_points"], eti["eti_values"], k=1, s=0 + eti["knot_points"], eti["eti_values"], k=spline_order, s=0 ) self.eti = eti_spl(self.z) # compute marginal tax rate schedule @@ -276,7 +280,7 @@ def sw_weights(self): return g_z, g_z_numerical -def find_eti(iot1, iot2, g_z_type="g_z_numerical"): +def find_eti(iot1, iot2, g_z_type="g_z"): """ This function solves for the ETI that would result in the policy represented via MTRs in iot2 be consistent with the @@ -302,9 +306,8 @@ def find_eti(iot1, iot2, g_z_type="g_z_numerical"): g_z = iot1.g_z_numerical # The equation below is a simplication of the above to make the integration easier eti_beliefs_lw = ( - ((1 - iot2.mtr) / iot2.mtr) - * ((1 - iot2.F) / (iot2.z * iot2.f)) - * (1 - iot2.F - (g_z.sum() - np.cumsum(g_z))) + ((1 - iot2.mtr) / (iot2.z * iot2.f * iot2.mtr)) * + (1 - iot2.F - (g_z.sum() - np.cumsum(g_z))) ) # derivation from JJZ analytical solution that doesn't involved integration eti_beliefs_jjz = (g_z - 1) / (