Skip to content

Allow demographics to vary across income groups#1165

Open
jdebacker wants to merge 30 commits into
PSLmodels:masterfrom
jdebacker:demog_J
Open

Allow demographics to vary across income groups#1165
jdebacker wants to merge 30 commits into
PSLmodels:masterfrom
jdebacker:demog_J

Conversation

@jdebacker

Copy link
Copy Markdown
Member

This PR updates OG-Core to allow demographic parameters (mortality, fertility, immigration rates -- and the resulting population distribution) to vary across lifetime income group (J).

With income specific demographics, the $\lambda_j$ are redefined and no longer will represent the shares of each income group in a model period. Rather, the $\lambda_j$ will define the fraction of new "births" into each lifetime income group.

@codecov-commenter

codecov-commenter commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.80392% with 77 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.66%. Comparing base (d907c8e) to head (9d1d18a).

Files with missing lines Patch % Lines
ogcore/demographics.py 67.21% 60 Missing ⚠️
ogcore/parameters.py 40.00% 9 Missing ⚠️
ogcore/output_plots.py 62.50% 3 Missing ⚠️
ogcore/utils.py 66.66% 3 Missing ⚠️
ogcore/parameter_plots.py 66.66% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1165      +/-   ##
==========================================
- Coverage   72.92%   72.66%   -0.26%     
==========================================
  Files          22       22              
  Lines        5525     5725     +200     
==========================================
+ Hits         4029     4160     +131     
- Misses       1496     1565      +69     
Flag Coverage Δ
unittests 72.66% <69.80%> (-0.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ogcore/SS.py 79.02% <ø> (ø)
ogcore/TPI.py 36.29% <100.00%> (ø)
ogcore/aggregates.py 100.00% <100.00%> (ø)
ogcore/household.py 90.77% <100.00%> (ø)
ogcore/output_tables.py 88.15% <100.00%> (ø)
ogcore/parameter_plots.py 78.64% <66.66%> (-0.18%) ⬇️
ogcore/output_plots.py 87.60% <62.50%> (-0.53%) ⬇️
ogcore/utils.py 83.56% <66.66%> (-0.39%) ⬇️
ogcore/parameters.py 81.76% <40.00%> (-0.49%) ⬇️
ogcore/demographics.py 58.41% <67.21%> (+5.04%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdebacker
jdebacker marked this pull request as ready for review July 18, 2026 00:33
@jdebacker

Copy link
Copy Markdown
Member Author

All tests pass locally:

(base) jason.debacker@MacBookPro OG-Core % uv run pytest
============================= test session starts ==============================
platform darwin -- Python 3.12.12, pytest-9.0.3, pluggy-1.6.0
rootdir: /Users/jason.debacker/repos/OG-Core
configfile: pyproject.toml
testpaths: tests
plugins: cov-7.1.0, xdist-3.8.0
collected 643 items

tests/test_SS.py ..........................................              [  6%]
tests/test_TPI.py .........................................              [ 12%]
tests/test_aggregates.py ..........................................      [ 19%]
tests/test_basic.py ....                                                 [ 20%]
tests/test_demographics.py ....................                          [ 23%]
tests/test_elliptical_u_est.py .......                                   [ 24%]
tests/test_execute.py .                                                  [ 24%]
tests/test_firm.py ..................................................... [ 32%]
................                                                         [ 35%]
tests/test_fiscal.py ..........................                          [ 39%]
tests/test_household.py ................................................ [ 46%]
...                                                                      [ 47%]
tests/test_output_plots.py ............................................. [ 54%]
.....                                                                    [ 54%]
tests/test_output_tables.py ...................                          [ 57%]
tests/test_parameter_plots.py .......................................... [ 64%]
.                                                                        [ 64%]
tests/test_parameter_tables.py .......                                   [ 65%]
tests/test_parameters.py ................                                [ 68%]
tests/test_pensions.py ....................................              [ 73%]
tests/test_population_accounting.py ..                                   [ 74%]
tests/test_run_example.py ..                                             [ 74%]
tests/test_run_ogcore.py .                                               [ 74%]
tests/test_tax.py .....................................                  [ 80%]
tests/test_txfunc.py ...................................                 [ 85%]
tests/test_user_inputs.py .....^[[B....                                      [ 87%]
tests/test_utils.py .................................................... [ 95%]
...............................                                          [100%]
================ 643 passed, 82 warnings in 22030.20s (6:07:10) ================

@jdebacker
jdebacker requested a review from rickecon July 18, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants