From eae659894853196a28c43122841c5fcaaffa1d8a Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Mon, 23 Nov 2026 14:10:40 -0500 Subject: [PATCH 1/7] eta can vary over the time path Government transfers are shared out by eta, held at one age-by-group matrix in every year. As the population ages, each person's transfer then drifts away from its intended profile. eta now takes a (T+S) x S x J path, like omega and rho. An S x J matrix is still accepted and held constant over time, so existing inputs give the same model parameters, bit for bit. --- ogcore/default_parameters.json | 8 +++---- ogcore/parameters.py | 33 ++++++++++++++++++++++++++++ tests/test_parameters.py | 39 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 4 deletions(-) diff --git a/ogcore/default_parameters.json b/ogcore/default_parameters.json index cdfd16e60..5f7e164bc 100644 --- a/ogcore/default_parameters.json +++ b/ogcore/default_parameters.json @@ -1755,12 +1755,12 @@ "param_notation": "$\\eta_{j,s,t}$", "section_1": "Fiscal Policy Parameters", "section_2": "Spending", - "notes": "This SxJ matrix gives the fraction of total aggregate transfers going to each age s and ability type j.", + "notes": "This (T+S)xSxJ array gives the fraction of total aggregate transfers going to each age s and ability type j in each period t; each period should sum to one. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period.", "type": "float", - "number_dims": 2, + "number_dims": 3, "value": [ { - "value": [ + "value": [[ [ 0.00395156539, 0.00395156539, @@ -2481,7 +2481,7 @@ 4.26755474e-05, 4.74172749e-06 ] - ] + ]] } ], "validators": { diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 358683a22..066d877a8 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -117,6 +117,38 @@ def _rename_deprecated_params(revision): return revision +# Parameters stored by period, age and ability type, (T+S) x S x J, that +# also accept a single S x J matrix held constant over time +TIME_VARYING_SJ_PARAMS = ["eta"] + + +def _sj_to_time_path(revision): + """ + Wrap an S x J value of a parameter in ``TIME_VARYING_SJ_PARAMS`` as a + single period, so revisions written before the parameter could vary + over time still validate; ``extrapolate_array`` then holds it + constant over the time path. + + Args: + revision (dict): `PARAM: VALUE` pairs + + Returns: + revision (dict): the revision with such values wrapped; the + caller's dict is left unchanged + """ + wrap = [ + name + for name in TIME_VARYING_SJ_PARAMS + if name in revision and np.ndim(revision[name]) == 2 + ] + if not wrap: + return revision + revision = dict(revision) + for name in wrap: + revision[name] = [np.asarray(revision[name]).tolist()] + return revision + + class Specifications(paramtools.Parameters): """ Inherits ParamTools Parameters abstract base class. @@ -1066,6 +1098,7 @@ def update_specifications(self, revision, raise_errors=True): # a JSON string or a path to a JSON file revision = self.read_params(revision) revision = _rename_deprecated_params(revision) + revision = _sj_to_time_path(revision) # Pension regimes are a list of dicts, which paramtools cannot # validate, so set them aside and check them in # _build_cohort_pension_arrays (called by compute_default_params) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 818795d6c..6c8d8ae14 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -108,6 +108,45 @@ def test_tau_payroll_extended_over_T_and_J(): assert np.allclose(specs.tau_payroll[1, :], 0.2) +def test_eta_accepts_SxJ_or_time_path(): + # eta may vary over the time path, (T+S) x S x J, so transfers per + # person can keep their profile as the population ages; an S x J + # matrix is still accepted and held constant over time. + specs = Specifications() + TS, S, J = specs.T + specs.S, specs.S, specs.J + assert specs.eta.shape == (TS, S, J) + eta_SJ = specs.eta[-1].copy() + # S x J, as a list or an array, gives the same constant path + for value in (eta_SJ.tolist(), eta_SJ): + revision = {"eta": value} + specs = Specifications() + specs.update_specifications(revision) + assert np.array_equal(specs.eta, np.tile(eta_SJ, (TS, 1, 1))) + # the caller's revision is left as it was + assert np.ndim(revision["eta"]) == 2 + # a full path is used period by period; the steady state uses the + # last period + path = np.tile(eta_SJ, (TS, 1, 1)) + path[0] = np.ones((S, J)) / (S * J) + specs = Specifications() + specs.update_specifications({"eta": path.tolist()}) + assert np.allclose(specs.eta[0], 1 / (S * J)) + assert np.allclose(specs.eta[1:], eta_SJ) + # a shorter path is extended with its last period + specs = Specifications() + specs.update_specifications({"eta": path[:2].tolist()}) + assert specs.eta.shape == (TS, S, J) + assert np.allclose(specs.eta[0], 1 / (S * J)) + assert np.allclose(specs.eta[2:], eta_SJ) + # shares outside [0, 1] are still rejected + bad = eta_SJ.copy() + bad[0, 0] = -0.01 + for value in (bad.tolist(), [bad.tolist()]): + specs = Specifications() + with pytest.raises(Exception): + specs.update_specifications({"eta": value}) + + def test_TxJ_params_collapse_when_J_changes(): # A previously extrapolated T+S x J array that is uniform across J # should be re-extrapolated to the new J when J is changed, rather From 0bb2f2a447f5eee47253ba8a1260cb52927e6481 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Mon, 23 Nov 2026 14:25:33 -0500 Subject: [PATCH 2/7] eta_RM can vary over the time path too; warn when shares do not sum to one Remittances are shared out by eta_RM the same way transfers are shared out by eta, so it gets the same (T+S) x S x J path. Older 2-D inputs, S x J or T x S, give the same model parameters as before. A warning now flags any period where eta or eta_RM does not sum to one, since households would then receive a different total than the aggregate. --- ogcore/default_parameters.json | 8 ++--- ogcore/parameters.py | 60 +++++++++++++++++++++++++--------- tests/test_parameters.py | 26 +++++++++++++++ 3 files changed, 74 insertions(+), 20 deletions(-) diff --git a/ogcore/default_parameters.json b/ogcore/default_parameters.json index 5f7e164bc..40e5c8584 100644 --- a/ogcore/default_parameters.json +++ b/ogcore/default_parameters.json @@ -2498,12 +2498,12 @@ "param_notation": "$\\eta_{RM,j,s,t}$", "section_1": "Household Parameters", "section_2": "Endowments", - "notes": "This SxJ matrix gives the fraction of total aggregate remittances going to each age s and ability type j.", + "notes": "This (T+S)xSxJ array gives the fraction of total aggregate remittances going to each age s and ability type j in each period t; each period should sum to one. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period.", "type": "float", - "number_dims": 2, + "number_dims": 3, "value": [ { - "value": [ + "value": [[ [ 0.00395156539, 0.00395156539, @@ -3224,7 +3224,7 @@ 4.26755474e-05, 4.74172749e-06 ] - ] + ]] } ], "validators": { diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 066d877a8..23df2d6c0 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -119,33 +119,43 @@ def _rename_deprecated_params(revision): # Parameters stored by period, age and ability type, (T+S) x S x J, that # also accept a single S x J matrix held constant over time -TIME_VARYING_SJ_PARAMS = ["eta"] +TIME_VARYING_SJ_PARAMS = ["eta", "eta_RM"] -def _sj_to_time_path(revision): +def _sj_to_time_path(revision, S, T, J): """ - Wrap an S x J value of a parameter in ``TIME_VARYING_SJ_PARAMS`` as a - single period, so revisions written before the parameter could vary - over time still validate; ``extrapolate_array`` then holds it - constant over the time path. + Give a 2-D value of a parameter in ``TIME_VARYING_SJ_PARAMS`` the + 3-D shape its schema expects, so revisions written before the + parameter could vary over time still validate: an S x J matrix + becomes a single period, which ``extrapolate_array`` holds constant + over the time path, and a T x S or (T+S) x S path is split equally + across the J ability types, as ``extrapolate_array`` does. Args: revision (dict): `PARAM: VALUE` pairs + S (int): number of ages + T (int): number of periods in the time path + J (int): number of lifetime ability types Returns: - revision (dict): the revision with such values wrapped; the + revision (dict): the revision with such values reshaped; the caller's dict is left unchanged """ - wrap = [ - name - for name in TIME_VARYING_SJ_PARAMS - if name in revision and np.ndim(revision[name]) == 2 - ] - if not wrap: + reshaped = {} + for name in TIME_VARYING_SJ_PARAMS: + if name not in revision or np.ndim(revision[name]) != 2: + continue + value = np.asarray(revision[name], dtype=float) + if value.shape[0] == S: + reshaped[name] = value[np.newaxis, :, :].tolist() + elif value.shape[0] in (T, T + S): + reshaped[name] = ( + np.repeat(value[:, :, np.newaxis], J, axis=2) / J + ).tolist() + if not reshaped: return revision revision = dict(revision) - for name in wrap: - revision[name] = [np.asarray(revision[name]).tolist()] + revision.update(reshaped) return revision @@ -469,6 +479,19 @@ def compute_default_params(self): param_in, dims=(self.T + self.S, self.S, self.J), item=item ) setattr(self, item, param_out) + # each period of an allocation matrix should sum to one, or the + # transfers (remittances) households receive differ from the + # aggregate in the budget (resource constraint) + for item in TIME_VARYING_SJ_PARAMS: + sums = getattr(self, item).sum(axis=(1, 2)) + off = np.flatnonzero(np.abs(sums - 1.0) > 1e-6) + if off.size: + warnings.warn( + f"{item} does not sum to one in {off.size} of " + f"{sums.size} periods (first period {off[0]} sums to " + f"{sums[off[0]]:.6f}); households then receive a " + "different total than the aggregate" + ) # extrapolate SS demog objects demog_obj_to_SS = [ "omega_SS", @@ -1098,7 +1121,12 @@ def update_specifications(self, revision, raise_errors=True): # a JSON string or a path to a JSON file revision = self.read_params(revision) revision = _rename_deprecated_params(revision) - revision = _sj_to_time_path(revision) + revision = _sj_to_time_path( + revision, + revision.get("S", self.S), + revision.get("T", self.T), + len(revision.get("lambdas", self.lambdas)), + ) # Pension regimes are a list of dicts, which paramtools cannot # validate, so set them aside and check them in # _build_cohort_pension_arrays (called by compute_default_params) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index 6c8d8ae14..ddc5dfe83 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -138,6 +138,12 @@ def test_eta_accepts_SxJ_or_time_path(): assert specs.eta.shape == (TS, S, J) assert np.allclose(specs.eta[0], 1 / (S * J)) assert np.allclose(specs.eta[2:], eta_SJ) + # a T x S path is still split equally across ability types + TxS = np.ones((specs.T, S)) / S + specs = Specifications() + specs.update_specifications({"eta": TxS.tolist()}) + assert specs.eta.shape == (TS, S, J) + assert np.allclose(specs.eta, 1 / (S * J)) # shares outside [0, 1] are still rejected bad = eta_SJ.copy() bad[0, 0] = -0.01 @@ -145,6 +151,26 @@ def test_eta_accepts_SxJ_or_time_path(): specs = Specifications() with pytest.raises(Exception): specs.update_specifications({"eta": value}) + # a period that does not sum to one is warned about + specs = Specifications() + with pytest.warns(UserWarning, match="eta does not sum to one"): + specs.update_specifications({"eta": (eta_SJ * 1.1).tolist()}) + + +def test_eta_RM_accepts_SxJ_or_time_path(): + # eta_RM shares out remittances as eta shares out transfers + specs = Specifications() + TS, S, J = specs.T + specs.S, specs.S, specs.J + assert specs.eta_RM.shape == (TS, S, J) + flat = np.ones((S, J)) / (S * J) + specs.update_specifications({"eta_RM": flat.tolist()}) + assert np.allclose(specs.eta_RM, flat) + path = np.tile(flat, (TS, 1, 1)) + path[0] = specs.eta[0] + specs = Specifications() + specs.update_specifications({"eta_RM": path.tolist()}) + assert np.allclose(specs.eta_RM[0], path[0]) + assert np.allclose(specs.eta_RM[1:], flat) def test_TxJ_params_collapse_when_J_changes(): From be2f13fc70e8122a9da3937f7c3645f1bda8e113 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Mon, 23 Nov 2026 21:35:04 -0500 Subject: [PATCH 3/7] Changelog, version 0.25.3, and docs notes for eta and eta_RM over time --- CHANGELOG.md | 8 ++++++++ docs/book/content/intro/parameters.md | 2 +- docs/book/content/theory/households.md | 2 +- ogcore/__init__.py | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24bd01193..6bdb01127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.25.3] - 2026-11-23 + +### Added +- `eta` and `eta_RM`, which share out government transfers and remittances across ages and lifetime income groups, can now vary over time, as a (T+S) x S x J path like `omega` and `rho`. Before, each was one S x J matrix used in every year. As the population ages, holding that matrix fixed changes what each person receives: in an aging country the oldest households can end up receiving many times their intended transfer. A path lets a calibration keep each person's transfer on its intended profile in every year. +- An S x J matrix is still accepted and held constant over time, and the older T x S form of `eta_RM` is still accepted, so existing inputs give the same model parameters, bit for bit. A path shorter than T+S is extended with its last period. +- `Specifications` warns when `eta` or `eta_RM` does not sum to one in some period, since households would then receive a different total than the aggregate. +- Adds tests that both parameters accept either form and that an S x J matrix gives the same parameters as before. + ## [0.25.2] - 2026-11-23 ### Added diff --git a/docs/book/content/intro/parameters.md b/docs/book/content/intro/parameters.md index e977b294d..9f3d0f1da 100644 --- a/docs/book/content/intro/parameters.md +++ b/docs/book/content/intro/parameters.md @@ -121,7 +121,7 @@ _Out-of-Range Action:_ error #### `eta_RM` _Description:_ Matrix that allocates aggregate remittances across households. -_Notes:_ This SxJ matrix gives the fraction of total aggregate remittances going to each age s and ability type j. +_Notes:_ This (T+S)xSxJ array gives the fraction of total aggregate remittances going to each age s and ability type j in each period t; each period should sum to one. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period. _Value Type:_ float _Valid Range:_ min = 0.0 and max = 1.0 _Out-of-Range Action:_ error diff --git a/docs/book/content/theory/households.md b/docs/book/content/theory/households.md index 8caa8a8da..669b9e38c 100644 --- a/docs/book/content/theory/households.md +++ b/docs/book/content/theory/households.md @@ -244,7 +244,7 @@ In this section, we describe what is arguably the most important economic agent rm_{j,s,t} = \eta_{RM,j,s,t}\frac{RM_t}{\lambda_j\omega_{s,t}} \quad\forall \quad j,s,t ``` - The distribution object $\eta_{RM,j,s,t}$ is an $S\times J$ matrix in every period $t$ whose elements sum to one in every period. This object governs how total remittances in every period $RM_t$ are distributed as income among household budget constraints. + The distribution object $\eta_{RM,j,s,t}$ is an $S\times J$ matrix in every period $t$ whose elements sum to one in every period. This object governs how total remittances in every period $RM_t$ are distributed as income among household budget constraints. Both $\eta_{RM,j,s,t}$ and the transfer allocation $\eta_{j,s,t}$ below can be entered as a path over the time periods, or as a single $S\times J$ matrix held constant over time. (SecHHgovtransfers)= diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 19b2469fd..6e1846568 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -21,4 +21,4 @@ from ogcore.txfunc import * # noqa: F403 from ogcore.utils import * # noqa: F403 -__version__ = "0.25.2" +__version__ = "0.25.3" diff --git a/pyproject.toml b/pyproject.toml index 0b0f0e86e..4541e4ee2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ogcore" -version = "0.25.2" +version = "0.25.3" authors = [ {name = "Jason DeBacker and Richard W. Evans"}, ] diff --git a/uv.lock b/uv.lock index d71c5388c..f830be339 100644 --- a/uv.lock +++ b/uv.lock @@ -2027,7 +2027,7 @@ wheels = [ [[package]] name = "ogcore" -version = "0.25.2" +version = "0.25.3" source = { editable = "." } dependencies = [ { name = "dask" }, From 9a08acdf10b257ae94d706ddff8a1b2cbbd91264 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Mon, 23 Nov 2026 16:30:41 -0500 Subject: [PATCH 4/7] Net family transfers between households (phi_FT) Households can now pass resources to each other, such as working-age children supporting their parents. phi_FT gives, for each period, age and ability type, the net transfer received as a share of GDP; each period must sum to zero, so aggregate resources, revenue and the government budget are unchanged. The transfers reach the household budget next to remittances, outside taxes and government transfers. Off (zero) by default, which leaves every result as it was. --- ogcore/SS.py | 7 ++- ogcore/TPI.py | 34 ++++++++++- ogcore/default_parameters.json | 101 +++++++++++++++++++++++++++++++++ ogcore/household.py | 63 ++++++++++++++++++++ ogcore/parameters.py | 37 +++++++++++- tests/test_household.py | 53 +++++++++++++++++ tests/test_parameters.py | 29 ++++++++++ 7 files changed, 317 insertions(+), 7 deletions(-) diff --git a/ogcore/SS.py b/ogcore/SS.py index 6da647c3a..97e1c90d2 100644 --- a/ogcore/SS.py +++ b/ogcore/SS.py @@ -375,6 +375,8 @@ def inner_loop(outer_loop_vars, p, client, scattered_p=None): p_tilde = aggr.get_ptilde(p_i, p.tau_c[-1, :], p.alpha_c) bq = household.get_bq(BQ, None, p, "SS") rm = household.get_rm(RM, None, p, "SS") + # net family transfers reach households alongside remittances + rm = household.add_family_transfers(rm, Y, p, "SS") tr = household.get_tr(TR, None, p, "SS") ubi = p.ubi_nom_array[-1, :, :] / factor @@ -636,6 +638,7 @@ def inner_loop(outer_loop_vars, p, client, scattered_p=None): new_bq = household.get_bq(new_BQ, None, p, "SS") new_RM = aggr.get_RM(Y, p, "SS") new_rm = household.get_rm(new_RM, None, p, "SS") + new_rm = household.add_family_transfers(new_rm, Y, p, "SS") tr = household.get_tr(TR, None, p, "SS") theta = theta_in_solve(nssmat, new_w, new_factor, None, p) @@ -1055,6 +1058,7 @@ def SS_solver( bqssmat = household.get_bq(BQss, None, p, "SS") trssmat = household.get_tr(TR_ss, None, p, "SS") rmssmat = household.get_rm(RM_ss, None, p, "SS") + ftssmat = household.get_ft(Yss, None, p, "SS") ubissmat = p.ubi_nom_array[-1, :, :] / factor_ss theta = pensions.replacement_rate_vals(nssmat, wss, factor_ss, None, p) @@ -1194,7 +1198,7 @@ def SS_solver( bssmat_splus1, nssmat, bqssmat, - rmssmat, + household.add_family_transfers(rmssmat, Yss, p, "SS"), taxss + household.fdc_net_flow(fdc_ss), np.squeeze(p.e[-1, :, :]).reshape((p.S, p.J)), p.tau_c[-1, :], @@ -1411,6 +1415,7 @@ def SS_solver( "c_i": c_i_ss_mat, "bq": bqssmat, "rm": rmssmat, + "ft": ftssmat, "tr": trssmat, "ubi": ubissmat, "before_tax_income": yss_before_tax_mat, diff --git a/ogcore/TPI.py b/ogcore/TPI.py index cce134a30..3e45ab1af 100644 --- a/ogcore/TPI.py +++ b/ogcore/TPI.py @@ -801,7 +801,9 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p): aggregates used in household problem (r_p, r, w, p_m, BQ, RM, TR, theta), optionally followed by ndc_rates (NDCRates), the calendar paths of the NDC credited - and discount rates + and discount rates, and Y, the path of aggregate output + (length T+S), which scales net family transfers (required + when phi_FT is not zero) r_p (Numpy array): real interest rate on household portfolio r (Numpy array): real interest rate on private capital w (Numpy array): real wage rate @@ -847,6 +849,14 @@ def inner_loop(guesses, outer_loop_vars, initial_values, ubi, j, ind, p): tr = household.get_tr(TR, None, p, "TPI") # compute rm rm = household.get_rm(RM, None, p, "TPI") + # net family transfers reach households alongside remittances + if np.any(p.phi_FT): + if len(outer_loop_vars) < 10 or outer_loop_vars[9] is None: + raise ValueError( + "inner_loop needs the output path Y (outer_loop_vars[9]) " + "to compute net family transfers" + ) + rm = household.add_family_transfers(rm, outer_loop_vars[9], p, "TPI") # initialize arrays b_mat = np.zeros((p.T + p.S, p.S)) @@ -1446,7 +1456,21 @@ def run_TPI(p, client=None): ndc_rates = pensions.ndc_rates_path(r_p, Y, w, L, p, "TPI") else: ndc_rates = None - outer_loop_vars = (r_p, r, w, p_m, BQ, RM, TR, theta, ndc_rates) + # output path, held at its steady-state value after T, which + # scales net family transfers + Y_path = np.concatenate([Y[: p.T], np.ones(p.S) * ss_vars["Y"]]) + outer_loop_vars = ( + r_p, + r, + w, + p_m, + BQ, + RM, + TR, + theta, + ndc_rates, + Y_path, + ) # compute composite good price p_i = ( np.tile(p.io_matrix.reshape(1, p.I, p.M), (p.T + p.S, 1, 1)) @@ -1546,6 +1570,7 @@ def run_TPI(p, client=None): bqmat = household.get_bq(BQ, None, p, "TPI") rmmat = household.get_rm(RM, None, p, "TPI") + ftmat = household.get_ft(Y_path, None, p, "TPI") trmat = household.get_tr(TR, None, p, "TPI") tax_mat = tax.net_taxes( r_p[: p.T], @@ -1612,7 +1637,9 @@ def run_TPI(p, client=None): bmat_splus1, n_mat[: p.T, :, :], bqmat[: p.T, :, :], - rmmat[: p.T, :, :], + household.add_family_transfers(rmmat, Y_path, p, "TPI")[ + : p.T, :, : + ], tax_mat + fdc_net, p.e, p.tau_c[: p.T, :], @@ -2360,6 +2387,7 @@ def run_TPI(p, client=None): "c_i": c_i[: p.T, ...], "bq": bqmat[: p.T, ...], "rm": rmmat[: p.T, ...], + "ft": ftmat[: p.T, ...], "tr": trmat[: p.T, ...], "ubi": ubi[: p.T, ...], "before_tax_income": y_before_tax_mat[: p.T, ...], diff --git a/ogcore/default_parameters.json b/ogcore/default_parameters.json index 40e5c8584..d43a68ffc 100644 --- a/ogcore/default_parameters.json +++ b/ogcore/default_parameters.json @@ -3234,6 +3234,107 @@ } } }, + "phi_FT": { + "title": "Net family transfers", + "description": "Net transfers between households, such as support from working-age children to their parents, as a share of GDP, received by each age and ability type.", + "short_description": "Net family transfers", + "param_notation": "$\\phi_{FT,j,s,t}$", + "section_1": "Household Parameters", + "section_2": "Endowments", + "notes": "This (T+S)xSxJ array gives the net family transfers received by all households of age s and ability type j in period t, as a share of GDP: positive for receivers, negative for givers. Each period must sum to zero, so the transfers net out across households and leave aggregate resources and the government budget unchanged. They enter the household budget outside taxes and government transfers. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period. Zero (the default) turns them off.", + "type": "float", + "number_dims": 3, + "value": [ + { + "value": [[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], +[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]] + } + ], + "validators": { + "range": { + "min": -1.0, + "max": 1.0 + } + } + }, "zeta": { "title": "Bequest distribution process", "description": "Matrix that describes the bequest distribution process.", diff --git a/ogcore/household.py b/ogcore/household.py index 10e02cb1c..c2ca17a84 100644 --- a/ogcore/household.py +++ b/ogcore/household.py @@ -298,6 +298,69 @@ def get_rm(RM, j, p, method): return rm +def get_ft(Y, j, p, method): + r""" + Calculate net family transfers received by each household. + + .. math:: + \hat{ft}_{j,s,t} = \phi_{FT,j,s,t} + \frac{\hat{Y}_{t}}{\lambda_{j}\hat{\omega}_{s,t}} \quad\forall j,s,t + + Each period of :math:`\phi_{FT}` sums to zero, so the transfers net + out across households: what the givers (negative shares) pay is what + the receivers (positive shares) get. + + Args: + Y (array_like): aggregate output + j (int): index of lifetime ability group + p (OG-Core Specifications object): model parameters + method (str): adjusts calculation dimensions based on 'SS' or + 'TPI' + + Returns: + ft (array_like): net family transfers received by household + + """ + if j is not None: + if method == "SS": + ft = (p.phi_FT[-1, :, j] * Y) / p.omega_SS[:, j] + else: + len_T = Y.shape[0] + ft = (p.phi_FT[:len_T, :, j] * Y.reshape((len_T, 1))) / ( + p.omega[:len_T, :, j] + ) + else: + if method == "SS": + ft = (p.phi_FT[-1, :, :] * Y) / p.omega_SS + else: + len_T = Y.shape[0] + ft = (p.phi_FT[:len_T, :, :] * utils.to_timepath_shape(Y)) / ( + p.omega[:len_T, :, :] + ) + + return ft + + +def add_family_transfers(rm, Y, p, method): + """ + Remittances plus net family transfers: both reach the household + budget outside taxes and government transfers. With ``phi_FT`` zero + (the default) the remittances are returned unchanged. + + Args: + rm (array_like): remittances received by household + Y (array_like): aggregate output + p (OG-Core Specifications object): model parameters + method (str): 'SS' or 'TPI' + + Returns: + (array_like): remittances plus net family transfers + """ + if not np.any(p.phi_FT): + return rm + return rm + get_ft(Y, None, p, method) + + def get_cons( r_p, w, diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 23df2d6c0..2828e238b 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -119,7 +119,11 @@ def _rename_deprecated_params(revision): # Parameters stored by period, age and ability type, (T+S) x S x J, that # also accept a single S x J matrix held constant over time -TIME_VARYING_SJ_PARAMS = ["eta", "eta_RM"] +TIME_VARYING_SJ_PARAMS = ["eta", "eta_RM", "phi_FT"] +# Of those, the allocation matrices, each period of which sums to one +ALLOCATION_PARAMS = ["eta", "eta_RM"] +# Tolerance on each period's sum of the net family transfer shares, phi_FT +PHI_FT_SUM_TOL = 1e-9 def _sj_to_time_path(revision, S, T, J): @@ -472,7 +476,18 @@ def compute_default_params(self): # Try to deal with size of eta and eta_RM. They may vary by S, J, T, # but want to allow user to enter one that varies by only S, S and J, # S and T, or T and S and J. - eta_params_to_TP = ["eta", "eta_RM", "omega", "rho", "imm_rates"] + # net family transfers are off by default: zeros sized to the + # current S and J, so changing either does not require them + if not np.any(self.phi_FT): + self.phi_FT = np.zeros((1, self.S, self.J)) + eta_params_to_TP = [ + "eta", + "eta_RM", + "phi_FT", + "omega", + "rho", + "imm_rates", + ] for item in eta_params_to_TP: param_in = getattr(self, item) param_out = extrapolate_array( @@ -482,7 +497,7 @@ def compute_default_params(self): # each period of an allocation matrix should sum to one, or the # transfers (remittances) households receive differ from the # aggregate in the budget (resource constraint) - for item in TIME_VARYING_SJ_PARAMS: + for item in ALLOCATION_PARAMS: sums = getattr(self, item).sum(axis=(1, 2)) off = np.flatnonzero(np.abs(sums - 1.0) > 1e-6) if off.size: @@ -492,6 +507,22 @@ def compute_default_params(self): f"{sums[off[0]]:.6f}); households then receive a " "different total than the aggregate" ) + # net family transfers move resources between households: in each + # period what the givers pay equals what the receivers get, so + # they leave aggregate resources and the budget unchanged + if self.phi_FT.shape != (self.T + self.S, self.S, self.J): + raise ValueError( + f"phi_FT has shape {self.phi_FT.shape[1:]} by age and " + f"ability type; it must be ({self.S}, {self.J})" + ) + ft_sums = self.phi_FT.sum(axis=(1, 2)) + off = np.flatnonzero(np.abs(ft_sums) > PHI_FT_SUM_TOL) + if off.size: + raise ValueError( + f"phi_FT must sum to zero in every period, but it does " + f"not in {off.size} of {ft_sums.size} periods (period " + f"{off[0]} sums to {ft_sums[off[0]]:.3e})" + ) # extrapolate SS demog objects demog_obj_to_SS = [ "omega_SS", diff --git a/tests/test_household.py b/tests/test_household.py index 9e1c87262..c2c8d4a99 100644 --- a/tests/test_household.py +++ b/tests/test_household.py @@ -1566,3 +1566,56 @@ def test_fdc_labor_wedge_linkage(linkage): assert np.all(wedge[:R] > cost[:R]) else: assert np.allclose(wedge, cost) + + +def _net_zero_phi(p, scale=1e-3): + """Net family transfer shares, (S, J): the oldest 15 ages receive and + ages 10-29 (model index) give, each in proportion to its population, + so every receiver gets the same amount and every giver pays the same; + the shares sum to zero.""" + phi = np.zeros((p.S, p.J)) + recv, give = slice(p.S - 15, p.S), slice(10, 30) + phi[recv] = p.omega_SS[recv] / p.omega_SS[recv].sum() + phi[give] = -p.omega_SS[give] / p.omega_SS[give].sum() + return scale * phi + + +def test_get_ft_nets_to_zero(): + # net family transfers move resources between households, so they + # sum to zero across households (population weighted) in the steady + # state and in every period of the time path + p = Specifications() + phi = _net_zero_phi(p) + p.update_specifications({"phi_FT": phi.tolist()}) + Y = 2.0 + ft = household.get_ft(Y, None, p, "SS") + assert ft.shape == (p.S, p.J) + assert np.allclose(ft, phi * Y / p.omega_SS) + assert abs((p.omega_SS * ft).sum()) < 1e-15 + # receivers get the same per person, givers pay the same per person + assert np.allclose(ft[p.S - 15 :], ft[-1, 0]) + assert np.allclose(ft[10:30], ft[10, 0]) and ft[10, 0] < 0 + for j in range(p.J): + assert np.allclose(household.get_ft(Y, j, p, "SS"), ft[:, j]) + Y_path = np.linspace(1.0, 2.0, p.T + p.S) + ft_path = household.get_ft(Y_path, None, p, "TPI") + assert ft_path.shape == (p.T + p.S, p.S, p.J) + net = (p.omega[: p.T + p.S] * ft_path).sum(axis=(1, 2)) + assert np.allclose(net, 0.0, atol=1e-15) + for j in (0, p.J - 1): + assert np.allclose( + household.get_ft(Y_path, j, p, "TPI"), ft_path[:, :, j] + ) + + +def test_add_family_transfers(): + # off by default: remittances come back unchanged (the same object); + # on: remittances plus net family transfers + p = Specifications() + rm = np.ones((p.S, p.J)) + assert household.add_family_transfers(rm, 2.0, p, "SS") is rm + p.update_specifications({"phi_FT": _net_zero_phi(p).tolist()}) + assert np.allclose( + household.add_family_transfers(rm, 2.0, p, "SS"), + rm + household.get_ft(2.0, None, p, "SS"), + ) diff --git a/tests/test_parameters.py b/tests/test_parameters.py index ddc5dfe83..77ea0e248 100644 --- a/tests/test_parameters.py +++ b/tests/test_parameters.py @@ -173,6 +173,35 @@ def test_eta_RM_accepts_SxJ_or_time_path(): assert np.allclose(specs.eta_RM[1:], flat) +def test_phi_FT_off_by_default_and_must_net_to_zero(): + # net family transfers are zero by default; a profile that nets to + # zero in every period is accepted (an S x J matrix is held constant + # over time); one that does not, or of the wrong shape, is rejected + specs = Specifications() + TS, S, J = specs.T + specs.S, specs.S, specs.J + assert specs.phi_FT.shape == (TS, S, J) + assert not np.any(specs.phi_FT) + phi = np.zeros((S, J)) + phi[-1, :] = 0.001 + phi[30, :] = -0.001 + specs.update_specifications({"phi_FT": phi.tolist()}) + assert np.array_equal(specs.phi_FT, np.tile(phi, (TS, 1, 1))) + path = np.tile(phi, (TS, 1, 1)) + path[0] *= 2 + specs = Specifications() + specs.update_specifications({"phi_FT": path.tolist()}) + assert np.allclose(specs.phi_FT[0], 2 * phi) + assert np.allclose(specs.phi_FT[1:], phi) + bad = phi.copy() + bad[0, 0] = 0.001 + specs = Specifications() + with pytest.raises(ValueError, match="sum to zero"): + specs.update_specifications({"phi_FT": bad.tolist()}) + specs = Specifications() + with pytest.raises(Exception): + specs.update_specifications({"phi_FT": [phi[:, :3].tolist()]}) + + def test_TxJ_params_collapse_when_J_changes(): # A previously extrapolated T+S x J array that is uniform across J # should be re-extrapolated to the new J when J is changed, rather From 009c3400a3cacf29c69a79ba930c61aa078a38f0 Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Mon, 23 Nov 2026 21:37:06 -0500 Subject: [PATCH 5/7] Changelog, version 0.25.4, docs and output variable for net family transfers --- CHANGELOG.md | 9 ++++++++ docs/book/content/intro/parameters.md | 8 +++++++ docs/book/content/theory/government.md | 4 ++-- docs/book/content/theory/households.md | 23 +++++++++++++++----- docs/book/content/theory/stationarization.md | 10 ++++++++- ogcore/__init__.py | 2 +- ogcore/model_variables.json | 9 ++++++++ pyproject.toml | 2 +- uv.lock | 2 +- 9 files changed, 58 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdb01127..dbf7f3430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.25.4] - 2026-11-23 + +### Added +- Adds net family transfers between households, set by the new parameter `phi_FT`: support that moves from some households to others, such as working-age children supporting their parents. Each household has its own budget constraint, so before this nothing could move resources between households outside bequests, and in countries where older people live mostly on family support their consumption fell far below what the data show. `phi_FT` is a (T+S) x S x J path (an S x J matrix is also accepted and held constant) giving the transfers received by each age and lifetime income group as a share of GDP, positive for receivers and negative for givers. +- Each period of `phi_FT` must sum to zero, so the transfers net out: they leave aggregate resources and the government budget unchanged. `Specifications` raises an error if a period does not sum to zero or the shape is wrong. The default is zero, which turns them off, so results are unchanged unless a calibration sets it. +- The transfers reach households next to remittances, outside taxes and government transfers, in the steady state and on the time path. Adds `household.get_ft` and `household.add_family_transfers`, and an `ft` output in the steady state and on the time path (also in `model_variables.json`). +- Documents net family transfers in the households chapter (a new section, and the budget constraint) and in the stationarization and government chapters. +- Adds tests that the transfers net to zero in the steady state and in every period of the path, that they are added to remittances only when turned on, and that `Specifications` rejects shares that do not sum to zero. + ## [0.25.3] - 2026-11-23 ### Added diff --git a/docs/book/content/intro/parameters.md b/docs/book/content/intro/parameters.md index 9f3d0f1da..609844fb6 100644 --- a/docs/book/content/intro/parameters.md +++ b/docs/book/content/intro/parameters.md @@ -127,6 +127,14 @@ _Valid Range:_ min = 0.0 and max = 1.0 _Out-of-Range Action:_ error +#### `phi_FT` +_Description:_ Net transfers between households, such as support from working-age children to their parents, as a share of GDP, received by each age and ability type. +_Notes:_ This (T+S)xSxJ array gives the net family transfers received by all households of age s and ability type j in period t, as a share of GDP: positive for receivers, negative for givers. Each period must sum to zero, so the transfers net out across households and leave aggregate resources and the government budget unchanged. They enter the household budget outside taxes and government transfers. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period. Zero (the default) turns them off. +_Value Type:_ float +_Valid Range:_ min = -1.0 and max = 1.0 +_Out-of-Range Action:_ error + + #### `zeta` _Description:_ Matrix that describes the bequest distribution process. _Notes:_ This SxJ matrix gives the fraction of total aggregate bequests going to each age s and ability type j. diff --git a/docs/book/content/theory/government.md b/docs/book/content/theory/government.md index b97f9604e..814bbf1f4 100644 --- a/docs/book/content/theory/government.md +++ b/docs/book/content/theory/government.md @@ -21,7 +21,7 @@ Income taxes are modeled through the net tax liability function for each househo \begin{aligned} p_t c_{j,s,t} + &\sum_{i=1}^I (1 + \tau^{c}_{i,t})p_{i,t}c_{min,i} + b_{j,s+1,t+1} = \\ &(1 + r_{p,t})b_{j,s,t} + w_t e_{j,s} n_{j,s,t} ... \\ - &\qquad +\: bq_{j,s,t} + rm_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ + &\qquad +\: bq_{j,s,t} + rm_{j,s,t} + ft_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ &\qquad\quad\forall j,t\quad\text{and}\quad E+1\leq s\leq E+S \quad\text{where}\quad b_{j,E+1,t}=0 \end{aligned} ``` @@ -797,7 +797,7 @@ Note that the budget closure rule (described in Section ref{`SecUnbalGBCcloseRul \begin{aligned} p_t c_{j,s,t} + &\sum_{i=1}^I (1 + \tau^{c}_{i,t})p_{i,t}c_{min,i} + b_{j,s+1,t+1} = \\ &(1 + r_{p,t})b_{j,s,t} + w_t e_{j,s} n_{j,s,t} ... \\ - &\qquad +\: (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ + &\qquad +\: (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + ft_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ &\qquad\quad\forall j,t\quad\text{and}\quad E+1\leq s\leq E+S \quad\text{where}\quad b_{j,E+1,t}=0 \end{aligned} ``` diff --git a/docs/book/content/theory/households.md b/docs/book/content/theory/households.md index 669b9e38c..68a47ec78 100644 --- a/docs/book/content/theory/households.md +++ b/docs/book/content/theory/households.md @@ -106,16 +106,16 @@ In this section, we describe what is arguably the most important economic agent \begin{aligned} p_t c_{j,s,t} + &\sum_{i=1}^I (1 + \tau^{c}_{i,t})p_{i,t}c_{min,i} + b_{j,s+1,t+1} = \\ &(1 + r_{p,t})b_{j,s,t} + w_t e_{j,s} n_{j,s,t} ... \\ - &\quad\quad + (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ + &\quad\quad + (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + ft_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ &\quad\quad\forall j,t\quad\text{and}\quad E+1\leq s\leq E+S \quad\text{where}\quad b_{j,E+1,t}=0 \end{aligned} ``` where $c_{j,s,t}$ is consumption, $b_{j,s+1,t+1}$ is savings for the next period, $r_{p,t}$ is the normalized interest rate (return) on household savings invested in the financial intermediary, $b_{j,s,t}$ is current period wealth (savings from last period), $w_t$ is the normalized wage, and $n_{j,s,t}$ is labor supply. Equations {eq}`eq_rK` and {eq}`eq_portfolio_return` of Chapter {ref}`Chap_FinInt` show how the rate of return from the financial intermediary $r_{p,t}$ might differ from the marginal product of capital $r_t$ and from the interest rate the government pays $r_{gov,t}$. Note that we must add in the cost of minimum consumption $c_{min,i}$ for all $i$ because that amount is subtracted out of composite consumption in {eq}`EqHHCompCons`. - The last six terms on the right-hand-side of the budget constraint {eq}`EqHHBC` have to do with dfferent types of transfers to households: bequests $bq_{j,s,t}$, remittances $rm_{j,s,t}$, government transfers $tr_{j,s,t}$, universal basic income $ubi_{j,s,t}$, public pension benefits $pension_{j,s,t}$, and net taxes $tax_{j,s,t}$. The first four types of transfers to households are detailed in the section below entitled {ref}`SecHHtransfers`. + The last seven terms on the right-hand-side of the budget constraint {eq}`EqHHBC` have to do with dfferent types of transfers to households: bequests $bq_{j,s,t}$, remittances $rm_{j,s,t}$, net family transfers $ft_{j,s,t}$, government transfers $tr_{j,s,t}$, universal basic income $ubi_{j,s,t}$, public pension benefits $pension_{j,s,t}$, and net taxes $tax_{j,s,t}$. The first five types of transfers to households are detailed in the section below entitled {ref}`SecHHtransfers`. - The third term $bq_{j,s,t}$ on the right-hand-side of the budget constraint {eq}`EqHHBC` represents the portion of total bequests $BQ_t$ that go to the age-$s$, income-group-$j$ household. Section {ref}`SecHHbequests` details how total bequests are distributed among the different households. The next term on the right-hand-side of the budget constraint {eq}`EqHHBC` represents remittances received by the household $rm_{j,s,t}$. We describe these remittances in Section {ref}`SecHHremit` below. + The third term $bq_{j,s,t}$ on the right-hand-side of the budget constraint {eq}`EqHHBC` represents the portion of total bequests $BQ_t$ that go to the age-$s$, income-group-$j$ household. Section {ref}`SecHHbequests` details how total bequests are distributed among the different households. The next term on the right-hand-side of the budget constraint {eq}`EqHHBC` represents remittances received by the household $rm_{j,s,t}$. We describe these remittances in Section {ref}`SecHHremit` below. The term after it, $ft_{j,s,t}$, is net family transfers received from other households, described in Section {ref}`SecHHfamily`. The next term is government transfers $tr_{j,s,t}$ to households of lifetime income group $j$ in age $s$ at time $t$. Section {ref}`SecHHgovtransfers` details how total government transfers to households are distributed among the differenty household types. The term $ubi_{j,s,t}$ the time series of a matrix of universal basic income (UBI) transfers by lifetime income group $j$ and age group $s$ in each period $t$. There is a specification where the time series of this matrix is stationary (growth adjusted) and a specification in which it's stationary value is going to zero in the limit (non-growth-adjusted). The calibration chapter on UBI in the country-specific repository documentation describes the exact way in which this matrix is calibrated from the values of five parameters, household composition data, and OG-Core's demographics. Similar to the transfers term $TR_{t}$, the UBI transfers will not be distortionary. @@ -181,7 +181,7 @@ In this section, we describe what is arguably the most important economic agent (SecHHtransfers)= ## Transfers to household - The household budget constraint {eq}`EqHHBC` includes four terms that represent different types of transfers to households: bequests $bq_{j,s,t}$, remittances $rm_{j,s,t}$, government transfers $tr_{j,s,t}$, and universal basic income $ubi_{j,s,t}$. These four types of household transfers are detailed in the following subsections. + The household budget constraint {eq}`EqHHBC` includes five terms that represent different types of transfers to households: bequests $bq_{j,s,t}$, remittances $rm_{j,s,t}$, net family transfers $ft_{j,s,t}$, government transfers $tr_{j,s,t}$, and universal basic income $ubi_{j,s,t}$. These five types of household transfers are detailed in the following subsections. (SecHHbequests)= @@ -247,6 +247,19 @@ In this section, we describe what is arguably the most important economic agent The distribution object $\eta_{RM,j,s,t}$ is an $S\times J$ matrix in every period $t$ whose elements sum to one in every period. This object governs how total remittances in every period $RM_t$ are distributed as income among household budget constraints. Both $\eta_{RM,j,s,t}$ and the transfer allocation $\eta_{j,s,t}$ below can be entered as a path over the time periods, or as a single $S\times J$ matrix held constant over time. +(SecHHfamily)= +### Net family transfers + + In many countries, older people rely on support from their working-age children and other relatives, more than on savings or government programs. Each household in the model has its own budget constraint, so without this term nothing can move resources from one household to another outside bequests. Net family transfers $ft_{j,s,t}$ add that channel. They are a share $\phi_{FT,j,s,t}$ of GDP received by all households of age $s$ in lifetime income group $j$, positive for households that receive support and negative for those that give it. + + ```{math} + :label: EqHH_IndFamilyTfer + ft_{j,s,t} = \phi_{FT,j,s,t}\frac{Y_t}{\lambda_j\omega_{s,t}} \quad\forall \quad j,s,t \quad\text{where}\quad \sum_{s=E+1}^{E+S}\sum_{j=1}^J\phi_{FT,j,s,t}=0 \quad\forall t + ``` + + Because the shares sum to zero in every period, what the givers pay is exactly what the receivers get. Family transfers therefore leave aggregate resources, market clearing, and the government budget unchanged; they only move resources between households. Like remittances, they are lump sum from the household's point of view, so they do not directly distort its choices. The default $\phi_{FT,j,s,t}=0$ turns them off. Country calibrations set the shares from data on transfers within families by age, such as the National Transfer Accounts. + + (SecHHgovtransfers)= ### Government transfers @@ -299,7 +312,7 @@ In this section, we describe what is arguably the most important economic agent \begin{aligned} \text{s.t.}\quad &p_t c_{j,s,t} + \sum_{i=1}^I (1 + \tau^{c}_{i,t})p_{i,t}c_{min,i} + b_{j,s+1,t+1} = \\ &\quad (1 + r_{p,t})b_{j,s,t} + w_t e_{j,s} n_{j,s,t} ...\\ - &\qquad +\: (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ + &\qquad +\: (1-\tau^{bq}_t)bq_{j,s,t} + rm_{j,s,t} + ft_{j,s,t} + tr_{j,s,t} + ubi_{j,s,t} + pension_{j,s,t} - tax_{j,s,t} \\ &\qquad\text{and}\quad c_{j,s,t}\geq 0,\: n_{j,s,t} \in[0,\tilde{l}],\:\text{and}\: b_{j,1,t}=0 \quad\forall j, t, \:\text{and}\: E+1\leq s\leq E+S \end{aligned} ``` diff --git a/docs/book/content/theory/stationarization.md b/docs/book/content/theory/stationarization.md index d9eff988e..dc67f26c6 100644 --- a/docs/book/content/theory/stationarization.md +++ b/docs/book/content/theory/stationarization.md @@ -50,6 +50,7 @@ The previous chapters derive all the equations necessary to solve for the steady - $\hat{D}_t\equiv\frac{D_t}{e^{g_y t}\tilde{N}_t}$ - $p_{m,t} \equiv \frac{\tilde{p}_{m,t}}{\tilde{p}_{M,t}}$ * - $\hat{rm}_{j,s,t} \equiv \frac{rm_{j,s,t}}{e^{g_y t}}$ +* - $\hat{ft}_{j,s,t} \equiv \frac{ft_{j,s,t}}{e^{g_y t}}$ - - $\hat{RM}_t \equiv \frac{RM_t}{e^{g_y t}\tilde{N}_t}$ - @@ -95,7 +96,7 @@ The usual definition of equilibrium would be allocations and prices such that ho \begin{aligned} p_t\hat{c}_{j,s,t} + &\sum_{i=1}^I (1 + \tau^{c}_{i,t})p_{i,t}\hat{c}_{min,i} + e^{g_y}\hat{b}_{j,s+1,t+1} = \\ &(1 + r_{p,t})\hat{b}_{j,s,t} + \hat{w}_t e_{j,s} n_{j,s,t} ... \\ - &\qquad +\: (1-\tau^{bq}_t)\hat{bq}_{j,s,t} + \hat{rm}_{j,s,t} + \hat{tr}_{j,s,t} + \hat{ubi}_{j,s,t} + \hat{pension}_{j,s,t} - \hat{tax}_{j,s,t} \\ + &\qquad +\: (1-\tau^{bq}_t)\hat{bq}_{j,s,t} + \hat{rm}_{j,s,t} + \hat{ft}_{j,s,t} + \hat{tr}_{j,s,t} + \hat{ubi}_{j,s,t} + \hat{pension}_{j,s,t} - \hat{tax}_{j,s,t} \\ &\quad\forall j,t\quad\text{and}\quad E+1\leq s\leq E+S \quad\text{where}\quad \hat{b}_{j,E+1,t}=0 \end{aligned} ``` @@ -147,6 +148,13 @@ The usual definition of equilibrium would be allocations and prices such that ho \hat{rm}_{j,s,t} = \eta_{RM,j,s,t}\frac{\hat{RM}_t}{\lambda_j\hat{\omega}_{s,t}} \quad\forall \quad j,s,t ``` + Net family transfers {eq}`EqHH_IndFamilyTfer` are a share of GDP, so their stationarized form follows directly. + + ```{math} + :label: EqHH_IndFamilyTferStnrz + \hat{ft}_{j,s,t} = \phi_{FT,j,s,t}\frac{\hat{Y}_t}{\lambda_j\hat{\omega}_{s,t}} \quad\forall \quad j,s,t + ``` + (SecStnrzFirms)= ## Stationarized Firms Equations diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 6e1846568..1d2a8d2d1 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -21,4 +21,4 @@ from ogcore.txfunc import * # noqa: F403 from ogcore.utils import * # noqa: F403 -__version__ = "0.25.3" +__version__ = "0.25.4" diff --git a/ogcore/model_variables.json b/ogcore/model_variables.json index 14bbe8133..23f16ef67 100644 --- a/ogcore/model_variables.json +++ b/ogcore/model_variables.json @@ -503,6 +503,15 @@ "label": "Remittances ($rm_{j,s,t}$)", "toGDP_label": "" }, + "ft": { + "desc": "Net family transfers received by households", + "section": "Household Variables", + "type": "array-like", + "TPI dimensions": "TxSxJ", + "SS dimensions": "SxJ", + "label": "Net family transfers ($ft_{j,s,t}$)", + "toGDP_label": "" + }, "tr": { "desc": "Government transfers received by households", "section": "Household Variables", diff --git a/pyproject.toml b/pyproject.toml index 4541e4ee2..58b7d3aca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ogcore" -version = "0.25.3" +version = "0.25.4" authors = [ {name = "Jason DeBacker and Richard W. Evans"}, ] diff --git a/uv.lock b/uv.lock index f830be339..464618142 100644 --- a/uv.lock +++ b/uv.lock @@ -2027,7 +2027,7 @@ wheels = [ [[package]] name = "ogcore" -version = "0.25.3" +version = "0.25.4" source = { editable = "." } dependencies = [ { name = "dask" }, From 50d238ba352ba4a6c1c69f93070de605ae09f00c Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Tue, 24 Nov 2026 13:33:04 -0500 Subject: [PATCH 6/7] Version 0.25.4 (#1279 takes 0.25.3) --- CHANGELOG.md | 3 ++- ogcore/__init__.py | 2 +- pyproject.toml | 2 +- uv.lock | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bdb01127..2dbe2127c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.25.3] - 2026-11-23 +## [0.25.4] - 2026-11-24 ### Added - `eta` and `eta_RM`, which share out government transfers and remittances across ages and lifetime income groups, can now vary over time, as a (T+S) x S x J path like `omega` and `rho`. Before, each was one S x J matrix used in every year. As the population ages, holding that matrix fixed changes what each person receives: in an aging country the oldest households can end up receiving many times their intended transfer. A path lets a calibration keep each person's transfer on its intended profile in every year. @@ -950,6 +950,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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. +[0.25.4]: https://github.com/PSLmodels/OG-Core/compare/v0.25.3...v0.25.4 [0.25.2]: https://github.com/PSLmodels/OG-Core/compare/v0.25.1...v0.25.2 [0.25.1]: https://github.com/PSLmodels/OG-Core/compare/v0.25.0...v0.25.1 [0.25.0]: https://github.com/PSLmodels/OG-Core/compare/v0.24.6...v0.25.0 diff --git a/ogcore/__init__.py b/ogcore/__init__.py index 6e1846568..1d2a8d2d1 100644 --- a/ogcore/__init__.py +++ b/ogcore/__init__.py @@ -21,4 +21,4 @@ from ogcore.txfunc import * # noqa: F403 from ogcore.utils import * # noqa: F403 -__version__ = "0.25.3" +__version__ = "0.25.4" diff --git a/pyproject.toml b/pyproject.toml index 4541e4ee2..58b7d3aca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ogcore" -version = "0.25.3" +version = "0.25.4" authors = [ {name = "Jason DeBacker and Richard W. Evans"}, ] diff --git a/uv.lock b/uv.lock index f830be339..464618142 100644 --- a/uv.lock +++ b/uv.lock @@ -2027,7 +2027,7 @@ wheels = [ [[package]] name = "ogcore" -version = "0.25.3" +version = "0.25.4" source = { editable = "." } dependencies = [ { name = "dask" }, From d2b25b846c3a979a6c20c6c042767ccbc6d6ef1e Mon Sep 17 00:00:00 2001 From: marcelolafleur Date: Wed, 25 Nov 2026 17:27:12 -0500 Subject: [PATCH 7/7] Docs: the eta parameter entry describes the time path; CHANGELOG notes that a 2-D eta passed directly to adjust now fails validation --- CHANGELOG.md | 1 + docs/book/content/intro/parameters.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dbe2127c..ea9835a02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - An S x J matrix is still accepted and held constant over time, and the older T x S form of `eta_RM` is still accepted, so existing inputs give the same model parameters, bit for bit. A path shorter than T+S is extended with its last period. - `Specifications` warns when `eta` or `eta_RM` does not sum to one in some period, since households would then receive a different total than the aggregate. - Adds tests that both parameters accept either form and that an S x J matrix gives the same parameters as before. +- A two-dimensional `eta` or `eta_RM` is converted to the new shape by `update_specifications`; passing one directly to paramtools' `adjust` now raises a validation error. ## [0.25.2] - 2026-11-23 diff --git a/docs/book/content/intro/parameters.md b/docs/book/content/intro/parameters.md index 9f3d0f1da..99886f626 100644 --- a/docs/book/content/intro/parameters.md +++ b/docs/book/content/intro/parameters.md @@ -627,7 +627,7 @@ _Out-of-Range Action:_ error #### `eta` _Description:_ Matrix that allocated government transfers across households. -_Notes:_ This SxJ matrix gives the fraction of total aggregate transfers going to each age s and ability type j. +_Notes:_ This (T+S)xSxJ array gives the fraction of total aggregate transfers going to each age s and ability type j in each period t; each period should sum to one. An SxJ matrix is also accepted and held constant over time; a path shorter than T+S is extended with its last period. _Value Type:_ float _Valid Range:_ min = 0.0 and max = 1.0 _Out-of-Range Action:_ error