Skip to content

Commit 1a943f4

Browse files
authored
Merge pull request #1036 from rickecon/remit
Fix remittances in aggregate resource constraint
2 parents e35cfd5 + 8848a71 commit 1a943f4

5 files changed

Lines changed: 57 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## [0.14.4] - 2025-06-23 18:00:00
10+
11+
### Added
12+
13+
- Fixes the sign error on the remittances `RM` term in `aggregates.py`, `resource_constraint()` function.
14+
- Added a test with positive remittances to `test_aggregates.py`, `test_resource_constraint()` function.
15+
916
## [0.14.3] - 2025-04-25 10:00:00
1017

1118
### Added
@@ -383,6 +390,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
383390
- Any earlier versions of OG-USA can be found in the [`OG-Core`](https://github.com/PSLmodels/OG-Core) repository [release history](https://github.com/PSLmodels/OG-Core/releases) from [v.0.6.4](https://github.com/PSLmodels/OG-Core/releases/tag/v0.6.4) (Jul. 20, 2021) or earlier.
384391

385392

393+
[0.14.4]: https://github.com/PSLmodels/OG-Core/compare/v0.14.3...v0.14.4
386394
[0.14.3]: https://github.com/PSLmodels/OG-Core/compare/v0.14.2...v0.14.3
387395
[0.14.2]: https://github.com/PSLmodels/OG-Core/compare/v0.14.1...v0.14.2
388396
[0.14.1]: https://github.com/PSLmodels/OG-Core/compare/v0.14.0...v0.14.1

ogcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
from ogcore.txfunc import *
2121
from ogcore.utils import *
2222

23-
__version__ = "0.14.3"
23+
__version__ = "0.14.4"

ogcore/aggregates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
526526
\text{rc_error} &= \hat{Y}_t - \hat{C}_t -
527527
\Bigl(e^{g_y}\bigl[1 + \tilde{g}_{n,t+1}\bigr]\hat{K}^d_{t+1} -
528528
\hat{K}^d_t\Bigr) - \delta\hat{K}_t - \hat{G}_t - \hat{I}_{g,t} ... \\
529-
&\qquad -\: \hat{\text{net capital outflows}}_t - \hat{RM}_t
529+
&\qquad -\: \hat{\text{net capital outflows}}_t + \hat{RM}_t
530530
\end{split}
531531
532532
Args:
@@ -542,7 +542,7 @@ def resource_constraint(Y, C, G, I_d, I_g, net_capital_flows, RM):
542542
rc_error (array_like): error in the resource constraint
543543
544544
"""
545-
rc_error = Y - C - I_d - I_g - G - net_capital_flows - RM
545+
rc_error = Y - C - I_d - I_g - G - net_capital_flows + RM
546546

547547
return rc_error
548548

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="ogcore",
8-
version="0.14.3",
8+
version="0.14.4",
99
author="Jason DeBacker and Richard W. Evans",
1010
license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",
1111
description="A general equilibrium overlapping generations model for fiscal policy analysis",

tests/test_aggregates.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,21 +1699,57 @@ def test_get_r_p(r, r_gov, p_m, K_vec, K_g, D, MPKg_vec, method, expected):
16991699
assert np.allclose(r_p_test, expected)
17001700

17011701

1702-
def test_resource_constraint():
1702+
test_data_rc = [
1703+
(
1704+
np.array([48, 55, 2, 99, 8]), # Y
1705+
np.array([33, 44, 0.4, 55, 6]), # C
1706+
np.array([4, 5, 0.01, 22, 0]), # G
1707+
np.array([20, 5, 0.6, 10, 1]), # I_d
1708+
np.array([0.0, 0.0, 0.0, 0.0, 0.0]), # I_g
1709+
np.array([0.1, 0, 0.016, -1.67, -0.477]), # net_capital_flows
1710+
np.array([0.0, 0.0, 0.0, 0.0, 0.0]), # RM1
1711+
np.array([-9.1, 1, 0.974, 13.67, 1.477]), # expected1
1712+
),
1713+
(
1714+
np.array([48, 55, 2, 99, 8]), # Y
1715+
np.array([33, 44, 0.4, 55, 6]), # C
1716+
np.array([4, 5, 0.01, 22, 0]), # G
1717+
np.array([20, 5, 0.6, 10, 1]), # I_d
1718+
np.array([0.0, 0.0, 0.0, 0.0, 0.0]), # I_g
1719+
np.array([0.1, 0, 0.016, -1.67, -0.477]), # net_capital_flows
1720+
np.array([0.0, 0.0, 0.0, 0.0, 0.03]), # RM2
1721+
np.array([-9.1, 1, 0.974, 13.67, 1.507]), # expected2
1722+
),
1723+
]
1724+
1725+
1726+
@pytest.mark.parametrize(
1727+
"Y,C,G,I_d,I_g,net_capital_flows,RM,expected",
1728+
test_data_rc,
1729+
ids=["RM=0, M=5", "RM>0, M=5"],
1730+
)
1731+
def test_resource_constraint(
1732+
Y, C, G, I_d, I_g, net_capital_flows, RM, expected
1733+
):
17031734
"""
17041735
Test resource constraint equation.
17051736
"""
1706-
Y = np.array([48, 55, 2, 99, 8])
1707-
C = np.array([33, 44, 0.4, 55, 6])
1708-
G = np.array([4, 5, 0.01, 22, 0])
1709-
I_d = np.array([20, 5, 0.6, 10, 1])
1710-
I_g = np.zeros_like(I_d)
1711-
net_capital_flows = np.array([0.1, 0, 0.016, -1.67, -0.477])
1712-
RM = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
1713-
expected = np.array([-9.1, 1, 0.974, 13.67, 1.477])
1737+
# Y = np.array([48, 55, 2, 99, 8])
1738+
# C = np.array([33, 44, 0.4, 55, 6])
1739+
# G = np.array([4, 5, 0.01, 22, 0])
1740+
# I_d = np.array([20, 5, 0.6, 10, 1])
1741+
# I_g = np.zeros_like(I_d)
1742+
# net_capital_flows = np.array([0.1, 0, 0.016, -1.67, -0.477])
1743+
# RM1 = np.array([0.0, 0.0, 0.0, 0.0, 0.0])
1744+
# expected1 = np.array([-9.1, 1, 0.974, 13.67, 1.477])
17141745
test_RC = aggr.resource_constraint(
17151746
Y, C, G, I_d, I_g, net_capital_flows, RM
17161747
)
1748+
# RM2 = np.array([0.0, 0.0, 0.0, 0.0, 0.03])
1749+
# expected2 = np.array([-9.1, 1, 0.974, 13.67, 1.477])
1750+
# test_RC2 = aggr.resource_constraint(
1751+
# Y, C, G, I_d, I_g, net_capital_flows, RM2
1752+
# )
17171753

17181754
assert np.allclose(test_RC, expected)
17191755

0 commit comments

Comments
 (0)