Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
bq[0, -1, j],
rm[0, -1, j],
tr[0, -1, j],
theta * p.replacement_rate_adjust[0],
theta * p.replacement_rate_adjust[0, j],
factor,
ubi[0, -1, j],
j,
Expand All @@ -436,7 +436,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
ind2 = np.arange(s + 2)
b_guesses_to_use = np.diag(guesses_b[: p.S, :], p.S - (s + 2))
n_guesses_to_use = np.diag(guesses_n[: p.S, :], p.S - (s + 2))
theta_to_use = theta[j] * p.replacement_rate_adjust[: p.S]
theta_to_use = theta[j] * p.replacement_rate_adjust[: p.S, j]
bq_to_use = np.diag(bq[: p.S, :, j], p.S - (s + 2))
rm_to_use = np.diag(rm[: p.S, :, j], p.S - (s + 2))
tr_to_use = np.diag(tr[: p.S, :, j], p.S - (s + 2))
Expand Down Expand Up @@ -499,7 +499,7 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p):
for t in range(0, p.T):
b_guesses_to_use = 0.75 * np.diag(guesses_b[t : t + p.S, :])
n_guesses_to_use = np.diag(guesses_n[t : t + p.S, :])
theta_to_use = theta[j] * p.replacement_rate_adjust[t : t + p.S]
theta_to_use = theta[j] * p.replacement_rate_adjust[t : t + p.S, j]
bq_to_use = np.diag(bq[t : t + p.S, :, j])
rm_to_use = np.diag(rm[t : t + p.S, :, j])
tr_to_use = np.diag(tr[t : t + p.S, :, j])
Expand Down
6 changes: 3 additions & 3 deletions ogcore/default_parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -4057,16 +4057,16 @@
},
"replacement_rate_adjust": {
"title": "Adjustment to the Social Security retirement benefits replacement rate",
"description": "Adjustment to the Social Security retirement benefits replacement rate. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.",
"description": "Adjustment to the Social Security retirement benefits replacement rate for year t and household type j. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.",
"section_1": "Fiscal Policy Parameters",
"section_2": "Government Pension Parameters",
"notes": "This parameter willy only vary along the time path. It is assumed to be one in the steady state. The steady state retirement rate can be adjusted by changing the parameters of the retirement benefits function.",
"type": "float",
"number_dims": 1,
"number_dims": 2,
"value": [
{
"value": [
1.0
[1.0]
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion ogcore/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def compute_default_params(self):
"m_wealth",
"p_wealth",
"retirement_age",
"replacement_rate_adjust",
"zeta_D",
"zeta_K",
"r_gov_scale",
Expand Down Expand Up @@ -208,6 +207,7 @@ def compute_default_params(self):
tp_param_list3 = [
"labor_income_tax_noncompliance_rate",
"capital_income_tax_noncompliance_rate",
"replacement_rate_adjust",
]
for item in tp_param_list3:
param_in = getattr(self, item)
Expand Down
8 changes: 4 additions & 4 deletions ogcore/pensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,24 +168,24 @@ def SS_amount(w, n, theta, t, j, shift, method, e, p):
else:
retireTPI = p.retire[t] - 1 - p.S
pension[retireTPI:] = (
theta[j] * p.replacement_rate_adjust[t] * w[retireTPI:]
theta[j] * p.replacement_rate_adjust[t, j] * w[retireTPI:]
)
elif len(n.shape) == 2:
for tt in range(pension.shape[0]):
pension[tt, retireTPI[tt] :] = (
theta * p.replacement_rate_adjust[t + tt] * w[tt]
theta * p.replacement_rate_adjust[t + tt, j] * w[tt]
)
else:
for tt in range(pension.shape[0]):
pension[tt, retireTPI[tt] :, :] = (
theta.reshape(1, p.J)
* p.replacement_rate_adjust[t + tt]
* p.replacement_rate_adjust[t + tt, :].reshape(1, p.J)
* w[tt]
)
elif method == "TPI_scalar":
# The above methods won't work if scalars are used. This option
# is only called by the SS_TPI_firstdoughnutring function in TPI.
pension = theta * p.replacement_rate_adjust[0] * w
pension = theta * p.replacement_rate_adjust[0, j] * w

return pension

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
target-version = ["py311", "py312"]
target-version = ["py312", "py313"]
include = '\.pyi?$'
15 changes: 14 additions & 1 deletion tests/test_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"chi_n": np.ones(2),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((40, 2)) / (40 * 2)),
"lambdas": [0.6, 0.4],
"omega": np.ones((160, 40)) / 40,
Expand Down Expand Up @@ -58,6 +59,7 @@ def test_get_L(n, p, method, expected):
"e": np.ones((40, 2)),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((40, 2)) / (40 * 2)),
"lambdas": [0.6, 0.4],
"omega": np.ones((160, 40)) / 40,
Expand Down Expand Up @@ -140,6 +142,7 @@ def test_get_I(b_splus1, K_p1, K, p, method, expected):
"e": np.ones((40, 2)),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((40, 2)) / (40 * 2)),
"lambdas": [0.6, 0.4],
"omega": np.ones((160, 40)) / 40,
Expand Down Expand Up @@ -198,6 +201,7 @@ def test_get_B(b, p, method, PreTP, expected):
"e": np.ones((40, 2)),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((40, 2)) / (40 * 2)),
"lambdas": [0.6, 0.4],
"omega": np.ones((160, 40)) / 40,
Expand Down Expand Up @@ -1128,6 +1132,7 @@ def test_get_RM(Y, p, method, expected):
"M": 3,
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((40, 2)) / (40 * 2)),
"lambdas": [0.6, 0.4],
"omega": np.ones((160, 40)) / 40,
Expand Down Expand Up @@ -1178,6 +1183,7 @@ def test_get_C(c, p, method, expected):
"e": np.ones((20, 2)),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((20, 2)) / (20 * 2)),
"lambdas": [0.6, 0.4],
"tau_bq": [0.17],
Expand Down Expand Up @@ -1245,7 +1251,13 @@ def test_get_C(c, p, method, expected):
"m_wealth": [1.0],
"cit_rate": [[0.2]],
"inv_tax_credit": [[0.02]],
"replacement_rate_adjust": [1.5, 1.5, 1.5, 1.6, 1.0],
"replacement_rate_adjust": [
[1.5, 1.5],
[1.5, 1.5],
[1.5, 1.5],
[1.6, 1.6],
[1.0, 1.0],
],
"delta_tau_annual": [
[float(1 - ((1 - 0.0975) ** (20 / (p3.ending_age - p3.starting_age))))]
],
Expand All @@ -1272,6 +1284,7 @@ def test_get_C(c, p, method, expected):
"e": np.ones((20, 2)),
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"eta": (np.ones((20, 2)) / (20 * 2)),
"lambdas": [0.6, 0.4],
"tau_bq": [0.17],
Expand Down
3 changes: 2 additions & 1 deletion tests/test_pensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lambdas": [1.0],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"J": 1,
"T": 4,
"chi_n": np.ones(4),
Expand Down Expand Up @@ -456,7 +457,7 @@ def test_deriv_NDC(args, d_NDC_expected):
n_ss = np.array([0.4, 0.45, 0.4, 0.42, 0.3, 0.2, 0.2])
omegas = (1 / p4.S) * np.ones(p4.S)
theta = np.array([0.4, 0.4])
p4.replacement_rate_adjust = np.ones(p4.T)
p4.replacement_rate_adjust = np.ones((p4.T, p4.J))
pension_expected_ss = [0, 0, 0, 0, 0.404, 0.396, 0.32]
method = "TPI"
shift = False
Expand Down
12 changes: 11 additions & 1 deletion tests/test_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"m_wealth": [4],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
}
p1.update_specifications(new_param_values)
expected1 = np.array([0.14285714, 0.6, 0.93103448])
Expand All @@ -41,6 +42,7 @@
"m_wealth": [3, 4, 3],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
}
p2.update_specifications(new_param_values2)
expected2 = np.array([0.084615385, 0.278021978, 0.734911243])
Expand Down Expand Up @@ -76,6 +78,7 @@ def test_ETR_wealth(b, p, expected):
"m_wealth": [5],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
}
p1.update_specifications(new_param_values)
expected1 = np.array([0.81122449, 1.837370242, 2.173849525])
Expand All @@ -95,6 +98,7 @@ def test_ETR_wealth(b, p, expected):
"m_wealth": [3, 4, 3],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
}
p2.update_specifications(new_param_values2)
expected2 = np.array([0.165976331, 0.522436904, 1.169769966])
Expand Down Expand Up @@ -896,6 +900,7 @@ def test_get_biz_tax(w, Y, L, K, p_m, p, m, method, expected):
p.S = 3
p.labor_income_tax_noncompliance_rate = np.zeros((p.T, p.S, p.J))
p.capital_income_tax_noncompliance_rate = np.zeros((p.T, p.S, p.J))
p.replacement_rate_adjust = np.ones((p.T, p.J))
p.lambdas = np.array([1.0])
p.e = np.array([0.5, 0.45, 0.3]).reshape(3, 1)
p.h_wealth = np.ones(p.T + p.S) * 1
Expand All @@ -910,13 +915,15 @@ def test_get_biz_tax(w, Y, L, K, p_m, p, m, method, expected):
p3.T = 3
p3.labor_income_tax_noncompliance_rate = np.zeros((p3.T, p3.S, p3.J))
p3.capital_income_tax_noncompliance_rate = np.zeros((p3.T, p3.S, p3.J))
p3.replacement_rate_adjust = np.ones((p3.T, p3.J))
p4 = copy.deepcopy(p)
p5 = copy.deepcopy(p)
p5.e = np.array([[0.3, 0.2], [0.5, 0.4], [0.45, 0.3]])
p5.J = 2
p5.T = 3
p5.labor_income_tax_noncompliance_rate = np.zeros((p5.T, p5.S, p5.J))
p5.capital_income_tax_noncompliance_rate = np.zeros((p5.T, p5.S, p5.J))
p5.replacement_rate_adjust = np.ones((p5.T, p5.J))
p5.lambdas = np.array([0.65, 0.35])
# set variables and other parameters for each case
r1 = 0.04
Expand Down Expand Up @@ -1139,7 +1146,7 @@ def test_get_biz_tax(w, Y, L, K, p_m, p, m, method, expected):
p7.retire = (np.array([1, 2, 2])).astype(int)

p8 = copy.deepcopy(p6)
p8.replacement_rate_adjust = [1.5, 0.6, 1.0]
p8.replacement_rate_adjust = np.array([[1.5, 1.5], [0.6, 0.6], [1.0, 1.0]])

factor = 105000
ubi1 = np.zeros((p1.T, p1.S, p1.J))
Expand All @@ -1163,6 +1170,7 @@ def test_get_biz_tax(w, Y, L, K, p_m, p, m, method, expected):
"ubi_nom_65p": 500,
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
}
p_u.update_specifications(new_param_values_ubi)
p_u.tax_func_type = "DEP"
Expand Down Expand Up @@ -1298,13 +1306,15 @@ def test_get_biz_tax(w, Y, L, K, p_m, p, m, method, expected):
p12.capital_income_tax_noncompliance_rate = (
np.ones((p12.T + p12.S, p12.J)) * 0.05
)
p12.replacement_rate_adjust = np.ones((p12.T + p12.S, p12.J)) * 1.0
p13 = copy.deepcopy(p5)
p13.labor_income_tax_noncompliance_rate = (
np.ones((p13.T + p13.S, p13.J)) * 0.05
)
p13.capital_income_tax_noncompliance_rate = (
np.ones((p13.T + p13.S, p13.J)) * 0.05
)
p13.replacement_rate_adjust = np.ones((p13.T + p13.S, p13.J)) * 1.0

expected1 = np.array([0.47374766, -0.09027663, 0.03871394])
expected2 = np.array([0.20374766, -0.09027663, 0.03871394])
Expand Down
1 change: 1 addition & 0 deletions tests/testing_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"chi_b": [80, 80],
"labor_income_tax_noncompliance_rate": [[0.0]],
"capital_income_tax_noncompliance_rate": [[0.0]],
"replacement_rate_adjust": [[1.0]],
"tax_func_type": "linear",
"age_specific": false,
"etr_params": [[[0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2], [0.2]],
Expand Down
Loading