From dbf73f7e5d949e0284585c97e3346f68892e19ea Mon Sep 17 00:00:00 2001 From: John Ryan Date: Sat, 8 Feb 2025 09:43:13 -0600 Subject: [PATCH] Add bw option for kreg --- iot/inverse_optimal_tax.py | 6 ++++-- iot/iot_user.py | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/iot/inverse_optimal_tax.py b/iot/inverse_optimal_tax.py index 6d7d43e..92dfd89 100644 --- a/iot/inverse_optimal_tax.py +++ b/iot/inverse_optimal_tax.py @@ -45,6 +45,7 @@ def __init__( kde_bw=None, mtr_smoother="kreg", mtr_smooth_param=1000, + kreg_bw=[120_000], ): # keep the original data intact self.data_original = data.copy() @@ -75,7 +76,7 @@ def __init__( self.eti = eti_spl(self.z) # compute marginal tax rate schedule self.mtr, self.mtr_prime = self.compute_mtr_dist( - data, weight_var, income_measure, mtr_smoother, mtr_smooth_param + data, weight_var, income_measure, mtr_smoother, mtr_smooth_param, kreg_bw ) # compute theta_z, the elasticity of the tax base self.theta_z = 1 + ((self.z * self.f_prime) / self.f) @@ -108,7 +109,7 @@ def df(self): return df def compute_mtr_dist( - self, data, weight_var, income_measure, mtr_smoother, mtr_smooth_param + self, data, weight_var, income_measure, mtr_smoother, mtr_smooth_param, kreg_bw ): """ Compute marginal tax rates over the income distribution and @@ -150,6 +151,7 @@ def compute_mtr_dist( binned_data[income_measure].dropna(), var_type="c", reg_type="ll", + bw=kreg_bw, ) mtr, _ = mtr_function.fit(self.z) mtr_prime = np.gradient(mtr, self.z, edge_order=2) diff --git a/iot/iot_user.py b/iot/iot_user.py index f50d496..1ffa3dc 100644 --- a/iot/iot_user.py +++ b/iot/iot_user.py @@ -62,7 +62,8 @@ def __init__( dist_type="log_normal", kde_bw=None, mtr_smoother="kreg", - mtr_smooth_param=4, + mtr_smooth_param=1000, + kreg_bw=[120_000] ): self.income_measure = income_measure self.weight_var = weight_var @@ -111,6 +112,7 @@ def __init__( kde_bw=kde_bw, mtr_smoother=mtr_smoother, mtr_smooth_param=mtr_smooth_param, + kreg_bw=kreg_bw, ) )