Skip to content

Commit 903cfc2

Browse files
authored
Merge pull request #1073 from jdebacker/prepop
Better handle the pre-time path population distribution
2 parents 1e392a5 + 352b8b5 commit 903cfc2

17 files changed

Lines changed: 308 additions & 302 deletions

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
55
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

8+
## [0.16.3] - 2026-06-25 15:00:00
9+
10+
### Added
11+
12+
- Better functionality and more country repositories with the OG installer. See PR [#1162](https://github.com/PSLmodels/OG-Core/pull/1162)
13+
14+
### Bug Fix
15+
- Fixes an inconsistency with the pre-time path population distribution and growth rates. Note that the `demographics.get_pop` function has been changed and now only returns one object: the population distribution (not also the distribution prior to the start year). In addition, the `get_pop` and `get_pop_objs` functions no longer have the `pre_pop_dist` kwarg. See PR [#1073](https://github.com/PSLmodels/OG-Core/pull/1073).
16+
817
## [0.16.2] - 2026-06-15 12:00:00
918

1019
### Added
@@ -17,9 +26,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1726
- Fixes math notation for plot labels. ([PR #1148](https://github.com/PSLmodels/OG-Core/pull/1148))
1827
- Fixes reshaping issues with `J=1` parameterization. ([PR #1145](https://github.com/PSLmodels/OG-Core/pull/1145))
1928

20-
### Bug Fix
21-
22-
- Fixed math notion for tilde variables in plot labels in `output_plots.py` to be consistent with the documentation and the code. See PR [#1148](https://github.com/PSLmodels/OG-Core/pull/1148).
2329

2430
## [0.16.1] - 2026-06-04 12:00:00
2531

@@ -603,6 +609,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
603609
- 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.
604610

605611

612+
[0.16.3]: https://github.com/PSLmodels/OG-Core/compare/v0.16.2...v0.16.3
606613
[0.16.2]: https://github.com/PSLmodels/OG-Core/compare/v0.16.1...v0.16.2
607614
[0.16.1]: https://github.com/PSLmodels/OG-Core/compare/v0.16.0...v0.16.1
608615
[0.16.0]: https://github.com/PSLmodels/OG-Core/compare/v0.15.13...v0.16.0

ogcore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
from ogcore.txfunc import * # noqa: F403
2222
from ogcore.utils import * # noqa: F403
2323

24-
__version__ = "0.16.2"
24+
__version__ = "0.16.3"

ogcore/aggregates.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,14 @@ def get_I(b_splus1, K_p1, K, p, method):
9595
)
9696
.sum(1)
9797
.sum(1)
98-
) / (1 + np.squeeze(np.hstack((p.g_n[1 : p.T], p.g_n_ss))))
98+
) / (1 + np.squeeze(np.hstack((p.g_n[: p.T - 1], p.g_n_ss))))
9999
aggI = (
100-
1 + np.squeeze(np.hstack((p.g_n[1 : p.T], p.g_n_ss)))
100+
1 + np.squeeze(np.hstack((p.g_n[: p.T - 1], p.g_n_ss)))
101101
) * np.exp(p.g_y) * (K_p1 - part2) - (1.0 - p.delta) * K
102102
elif method == "total_ss":
103103
aggI = ((1 + p.g_n_ss) * np.exp(p.g_y) - 1 + p.delta) * K
104104
elif method == "total_tpi":
105-
aggI = (1 + p.g_n[1 : p.T + 1]) * np.exp(p.g_y) * K_p1 - (
106-
1.0 - p.delta
107-
) * K
105+
aggI = (1 + p.g_n[: p.T]) * np.exp(p.g_y) * K_p1 - (1.0 - p.delta) * K
108106

109107
return aggI
110108

@@ -133,8 +131,8 @@ def get_B(b, p, method, preTP):
133131
if preTP:
134132
part1 = b * np.transpose(p.omega_S_preTP * p.lambdas)
135133
omega_extended = np.append(p.omega_S_preTP[1:], [0.0])
136-
imm_extended = np.append(p.imm_rates[0, 1:], [0.0])
137-
pop_growth_rate = p.g_n[0]
134+
imm_extended = np.append(p.imm_rates_preTP[1:], [0.0])
135+
pop_growth_rate = p.g_n_preTP
138136
else:
139137
part1 = b * np.transpose(p.omega_SS * p.lambdas)
140138
omega_extended = np.append(p.omega_SS[1:], [0.0])
@@ -157,7 +155,7 @@ def get_B(b, p, method, preTP):
157155
)
158156
B_presum = part1 + part2
159157
B = B_presum.sum(1).sum(1)
160-
B /= 1.0 + np.hstack((p.g_n[1 : p.T], p.g_n_ss))
158+
B /= 1.0 + np.hstack((p.g_n[: p.T - 1], p.g_n_ss))
161159
return B
162160

163161

@@ -189,8 +187,8 @@ def get_BQ(r, b_splus1, j, p, method, preTP):
189187
if method == "SS":
190188
if preTP:
191189
omega = p.omega_S_preTP
192-
pop_growth_rate = p.g_n[0]
193-
rho = p.rho[0, :]
190+
pop_growth_rate = p.g_n_preTP
191+
rho = p.rho_preTP
194192
else:
195193
omega = p.omega_SS
196194
pop_growth_rate = p.g_n_ss
@@ -206,20 +204,24 @@ def get_BQ(r, b_splus1, j, p, method, preTP):
206204
p.omega_S_preTP.reshape(1, p.S), p.omega[: p.T - 1, :], axis=0
207205
)
208206
rho = np.append(
209-
p.rho[0, :].reshape(1, p.S), p.rho[: p.T - 1, :], axis=0
207+
p.rho_preTP.reshape(1, p.S), p.rho[: p.T - 1, :], axis=0
210208
)
211209

212210
if j is not None:
213211
BQ_presum = (b_splus1 * p.lambdas[j]) * (pop * rho)
214212
BQ = BQ_presum.sum(1)
215-
BQ *= (1.0 + r) / (1.0 + p.g_n[: p.T])
213+
BQ *= (1.0 + r) / (1.0 + np.append(p.g_n_preTP, p.g_n[: p.T - 1]))
216214
else:
217215
BQ_presum = (b_splus1 * np.squeeze(p.lambdas)) * np.tile(
218216
np.reshape(pop * rho, (p.T, p.S, 1)), (1, 1, p.J)
219217
)
220218
BQ = BQ_presum.sum(1)
221219
BQ *= np.tile(
222-
np.reshape((1.0 + r) / (1.0 + p.g_n[: p.T]), (p.T, 1)),
220+
np.reshape(
221+
(1.0 + r)
222+
/ (1.0 + np.append(p.g_n_preTP, p.g_n[: p.T - 1])),
223+
(p.T, 1),
224+
),
223225
(1, p.J),
224226
)
225227
if p.use_zeta:
@@ -261,15 +263,15 @@ def get_RM(Y, p, method):
261263
RM = np.zeros_like(Y)
262264
RM[0] = p.alpha_RM_1 * Y[0]
263265
for t in range(1, p.tG1):
264-
RM[t] = ((1 + p.g_RM[t]) / (np.exp(p.g_y) * (1 + p.g_n[t]))) * RM[
265-
t - 1
266-
]
266+
RM[t] = (
267+
(1 + p.g_RM[t]) / (np.exp(p.g_y) * (1 + p.g_n[t - 1]))
268+
) * RM[t - 1]
267269
rho_vec = np.linspace(0, 1, p.tG2 - p.tG1)
268270
for t in range(p.tG1, p.tG2 - 1):
269271
RM[t] = (
270272
rho_vec[t - p.tG1] * p.alpha_RM_T * Y[t]
271273
+ (1 - rho_vec[t - p.tG1])
272-
* ((1 + p.g_RM[t]) / (np.exp(p.g_y) * (1 + p.g_n[t])))
274+
* ((1 + p.g_RM[t]) / (np.exp(p.g_y) * (1 + p.g_n[t - 1])))
273275
* RM[t - 1]
274276
)
275277
RM[p.tG2 - 1 :] = p.alpha_RM_T * Y[p.tG2 - 1 :]

ogcore/default_parameters.json

Lines changed: 98 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)