Skip to content

Commit

Permalink
Update aggregate remittances in resource constraint in code
Browse files Browse the repository at this point in the history
  • Loading branch information
rickecon committed Sep 18, 2024
1 parent 9cf79d1 commit 3714290
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ogcore/SS.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ def SS_solver(
p_m (array_like): good prices
Y (scalar): real GDP
BQ (array_like): aggregate bequest amount(s)
RM (array_like): remittance amount(s)
TR (scalar): lump sum transfer amount
factor (scalar): scaling factor converting model units to dollars
p (OG-Core Specifications object): model parameters
Expand Down Expand Up @@ -925,13 +924,15 @@ def SS_solver(
I_g_vec_ss[-1] = I_g_ss
net_capital_outflows_vec = np.zeros(p.M)
net_capital_outflows_vec[-1] = net_capital_outflows

RC = aggr.resource_constraint(
Y_vec_ss,
C_m_vec_ss,
G_vec_ss,
I_d_vec_ss,
I_g_vec_ss,
net_capital_outflows_vec,
RM_ss,
)
if VERBOSE:
print("Foreign debt holdings = ", D_f_ss)
Expand Down
3 changes: 2 additions & 1 deletion ogcore/TPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,7 +1274,8 @@ def run_TPI(p, client=None):
net_capital_outflows_vec = np.zeros((p.T, p.M))
net_capital_outflows_vec[:, -1] = net_capital_outflows[: p.T]
RC_error = aggr.resource_constraint(
Y_vec, C_m_vec, G_vec, I_d_vec, I_g_vec, net_capital_outflows_vec
Y_vec, C_m_vec, G_vec, I_d_vec, I_g_vec, net_capital_outflows_vec,
RM[: p.T]
)
# Compute total investment (not just domestic)
I_total = aggr.get_I(None, K[1 : p.T + 1], K[: p.T], p, "total_tpi")
Expand Down
7 changes: 4 additions & 3 deletions ogcore/aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,15 @@ def get_r_p(r, r_gov, p_m, K_vec, K_g, D, MPKg_vec, p, method):
return np.squeeze(r_p)


def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows):
def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
r"""
Compute the error in the resource constraint.
.. math::
\text{rc_error} = \hat{Y}_t - \hat{C}_t -
\Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{K}^d_{t+1} -
\hat{K}^d_t\Bigr) - \delta\hat{K}_t - \hat{G}_t - \hat{I}_{g,t} -
\text{net capital outflows}_t
\text{net capital outflows}_t - RM_t
Args:
Y (array_like): aggregate output by industry
Expand All @@ -534,12 +534,13 @@ def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows):
I_d (array_like): aggregate private investment from domestic households
I_g (array_like): investment in government capital
net_capital_flows (array_like): net capital outflows
RM (array_like): aggregate remittances
Returns:
rc_error (array_like): error in the resource constraint
"""
rc_error = Y - C - I_d - I_g - G - net_capital_flows
rc_error = Y - C - I_d - I_g - G - net_capital_flows - RM

return rc_error

Expand Down
5 changes: 4 additions & 1 deletion tests/test_aggregates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,8 +1709,11 @@ def test_resource_constraint():
I_d = np.array([20, 5, 0.6, 10, 1])
I_g = np.zeros_like(I_d)
net_capital_flows = np.array([0.1, 0, 0.016, -1.67, -0.477])
RM = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
expected = np.array([-9.1, 1, 0.974, 13.67, 1.477])
test_RC = aggr.resource_constraint(Y, C, G, I_d, I_g, net_capital_flows)
test_RC = aggr.resource_constraint(
Y, C, G, I_d, I_g, net_capital_flows, RM
)

assert np.allclose(test_RC, expected)

Expand Down

0 comments on commit 3714290

Please sign in to comment.