Add model_fit_table() function to summarize endogenous calibration targets#1138
Add model_fit_table() function to summarize endogenous calibration targets#1138jdebacker wants to merge 17 commits into
model_fit_table() function to summarize endogenous calibration targets#1138Conversation
Adds calib_table() to output_tables.py, which produces a 5-column table showing each calibrated parameter's name/symbol, value (or range), data target description, model moment, and data moment. Supports wealth Gini (beta_annual), investment rate I/K (delta_annual), and income Gini (e) as initial target types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1138 +/- ##
==========================================
- Coverage 73.34% 73.26% -0.09%
==========================================
Files 21 21
Lines 5302 5394 +92
==========================================
+ Hits 3889 3952 +63
- Misses 1413 1442 +29
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the project’s Python/tooling requirements to Python 3.12+, and adds new output functionality to summarize model-vs-data fit for selected moments, along with a small change to how lifecycle profile plots can overlay/normalize external data.
Changes:
- Bump required Python version from
>=3.11to>=3.12and update lockfile accordingly. - Add
model_fit_table()to generate a grouped “Data vs Model” moments table fromtpi_outputandparams. - Normalize
plot_datainss_profiles()(non-labor variables) to align the first point with the baseline profile.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
uv.lock |
Updates lock metadata for Python >=3.12 and reflects dependency/metadata adjustments. |
pyproject.toml |
Raises requires-python to >=3.12 and adds a dev dependency group (ipykernel). |
ogcore/output_tables.py |
Introduces model_fit_table() for reporting model fit moments vs. data targets. |
ogcore/output_plots.py |
Adjusts ss_profiles() to normalize plotted data series (when provided) for better comparability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Example of new table: macro_moments = cm.get_macro_moments()
fiscal_moments = cm.get_fiscal_moments()
params.start_year = 2026
demog_moments = cm.get_demographic_moments(params)
inequality_moments = cm.get_inequality_moments()
target_moments = {
**macro_moments,
**fiscal_moments,
**demog_moments,
**inequality_moments,
}
# %%
# Call function and create table
calib_df = ot.model_fit_table(target_moments, params, tpi_vars)
print(calib_df)produces: |
|
With changes in OG-USA PR #150, together with the update to the plotting function in this PR, one can produce comparisons between lifecycle profiles between the model and data for savings, consumption, earnings, and hours worked that look like this one for assets: |
calib_table function to summarize endogenous calibration targetsmodel_fit_table() function to summarize endogenous calibration targets

Adds
calib_table()tooutput_tables.py, which produces a 5-column table showing each calibrated parameter's name/symbol, value (or range), data target description, model moment, and data moment. Supports wealth Gini (beta_annual), investment rate I/K (delta_annual), and income Gini (e) as initial target types.