Skip to content

Update macro calibration: API-driven parameters, updated defaults, and documentation - #6

Merged
jdebacker merged 12 commits into
PSLmodels:mainfrom
jdebacker:update_macro
Jun 26, 2026
Merged

Update macro calibration: API-driven parameters, updated defaults, and documentation#6
jdebacker merged 12 commits into
PSLmodels:mainfrom
jdebacker:update_macro

Conversation

@jdebacker

Copy link
Copy Markdown
Member

Summary

This PR updates OG-BRA's macro calibration to use direct API calls for parameter retrieval, refreshes the default parameter values from current data, and expands the calibration documentation.

Macro parameters (macro_params.py / calibrate.py)

  • Refactored macro_params.py to use direct REST API calls (World Bank WDI/QPSD, IMF GFS, ILO ILOSTAT) instead of pandas-datareader, following the OG-ZAF pattern
  • Added update_from_api=False flag to Calibration.__init__() so the class can be instantiated without triggering API calls (preserves current behavior by default)
  • Added update_baseline.py script to programmatically refresh and write ogbra_default_parameters.json
  • Added Makefile with new-baseline target and AGENTS.md documenting the workflow

Updated default parameter values (ogbra_default_parameters.json)

Key changes from running make new-baseline against current API data:

Parameter Old value New value Source
initial_debt_ratio 0.600 0.741 World Bank WDI
g_y_annual 0.036 0.021 World Bank WDI
gamma 0.588 0.407 ILO SDG 10.4.1
alpha_T 0.097 0.038 IMF GFS
alpha_G [0.215, 0.209, 0.207] [0.118] IMF GFS
cit_rate 0.340 PwC / statutory (IRPJ 25% + CSLL 9%)
tau_c 0.120 0.090 Federal consumption taxes (PIS + COFINS)
tau_payroll 0.280 Employer INSS (20%) + FGTS (8%)
start_year 2023 2026
g_n_ss 0.0072 −0.011 UN demographics
All demographic arrays 2023 vintage 2026 vintage UN Population Data Portal

Documentation updates

  • macro.md: Updated all macro parameter values and data sources; fixed broken links
  • firms.md: Updated capital share (γ) from 0.588 to 0.407 with ILO source
  • government.md: Updated α_G and α_T from IMF GFS
  • demographics.md: Updated population data vintage (2026) and cross-references
  • taxes.md: Expanded from stub to full documentation covering:
    • Personal income tax (IRPF brackets, 2026 reform via Law 15,270/2025)
    • Payroll taxes (INSS + FGTS, tau_payroll = 0.28)
    • Corporate income tax (cit_rate = 0.34, IRPJ + CSLL)
    • Value-added taxes (tau_c = 0.09, PIS + COFINS; context on CBS/IBS reform)
  • exogenous_parameters.md: Replaced static hardcoded table with auto-generated {include} directive
  • create_doc_figures.py: Refactored to use importlib.resources, dynamic start_year, and main() wrapper

Dependencies

  • Removed pandas-datareader, xlwt, linearmodels from pyproject.toml (no longer used after macro_params.py refactor)
  • Updated test suite (tests/test_macro_params.py) with monkeypatched unit tests (no live API calls)

🤖 Generated with Claude Code

@codecov-commenter

codecov-commenter commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.15789% with 42 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@8ad69c3). Learn more about missing BASE report.

Files with missing lines Patch % Lines
ogbra/macro_params.py 80.62% 31 Missing ⚠️
ogbra/calibrate.py 84.09% 7 Missing ⚠️
tests/test_macro_params.py 97.29% 3 Missing ⚠️
ogbra/update_baseline.py 94.44% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main       #6   +/-   ##
=======================================
  Coverage        ?   86.60%           
=======================================
  Files           ?       15           
  Lines           ?      687           
  Branches        ?        0           
=======================================
  Hits            ?      595           
  Misses          ?       92           
  Partials        ?        0           
Flag Coverage Δ
unittests 86.60% <91.15%> (?)

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jdebacker and others added 2 commits June 25, 2026 21:59
Port missing test modules from OG-ZAF, adapted for OG-BRA:
- test_import_smoke: basic package import sanity check
- test_calibrate: offline/online mode and partial-failure behavior
  for the Calibration class (all API calls monkeypatched)
- test_update_baseline: verifies main() writes a valid JSON that
  can be loaded into OG-Core Specifications without errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jdebacker
jdebacker merged commit 699cafb into PSLmodels:main Jun 26, 2026
8 checks passed
@jdebacker
jdebacker deleted the update_macro branch June 26, 2026 02:12
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