Skip to content

Conversation

@vahid-ahmadi
Copy link

@vahid-ahmadi vahid-ahmadi commented Dec 18, 2025

Summary

Updates OG-UK to work with the latest PolicyEngine-UK API and adds significant performance optimizations.

Key Changes

  • Fixed PolicyEngine-UK API compatibility (Microsimulation class changes)
  • Added age bracket-based tax function estimation (4 groups instead of 80)
  • Added live progress timer during model execution
  • Configurable run script with clear documentation
  • Uses performance-optimized OG-Core from PR #1082

OG-Core Dependency

This PR depends on vahid-ahmadi/OG-Core@performance-optimizations which includes:

  • Loosened SS tolerances (mindist_SS: 1e-9→1e-3, RC_SS: 1e-8→1e-4)
  • Optional Numba JIT compilation for hot-path functions
  • ~55% faster steady state convergence

Files Changed

  • oguk/calibrate.py - Updated for PolicyEngine-UK API, added bracket-based estimation
  • oguk/get_micro_data.py - Added age bracket utilities and helper functions
  • examples/run_oguk_simple.py - New configurable run script with live timer
  • setup.py - Updated dependencies to use performance-optimized OG-Core

Model Parameters & Runtime Impact

Parameter Setting Description Runtime Effect
tax_func_type DEP Deardorff polynomial functional form for tax approximation DEP balances accuracy and speed; GS would be ~1.5x slower
start_year 2026 Budget window (1 year only) Each additional year adds ~35s to tax estimation
J 5 Number of ability types (income quintiles) Model solves J×80 = 400 household problems per GE iteration
age_brackets 4 groups Groups ages for tax estimation: (20-35), (36-50), (51-65), (66-100) ~95% reduction in tax estimation time vs 80 individual ages
time_path False Steady state only, no transition dynamics TPI would add 30-60 min (~10-15x longer)

Age Brackets Detail

Bracket Ages Representative Description
1 20-35 27 Young workers
2 36-50 43 Mid-career
3 51-65 58 Late career
4 66-100 83 Retirement

Performance

  • Total runtime: ~4 minutes (with optimized OG-Core)
  • Baseline SS: ~2 min
  • Reform SS: ~2 min
  • Tax function estimation: ~35 sec per scenario

Test Plan

  • Baseline steady state computation completes
  • Reform steady state computation completes
  • Results comparison shows expected economic effects
  • Age bracket estimation produces valid tax parameters

🤖 Generated with Claude Code

vahid-ahmadi and others added 4 commits December 18, 2025 15:37
- Add bracket-based tax function estimation to calibrate.py
  - New estimate_tax_functions_by_bracket() method
  - Filters micro data per bracket, estimates separately, replicates to ages
  - Supports custom brackets or auto-generated N equal brackets

- Add age bracket utilities to get_micro_data.py
  - generate_age_brackets(): Auto-generate N equal brackets
  - create_custom_brackets(): Create from (min, max) tuples
  - filter_micro_data_by_age_bracket(): Filter data by age range
  - Updated DEFAULT_AGE_BRACKETS for UK (4 groups)

- Update run_oguk_simple.py with configuration options
  - USE_AGE_BRACKETS toggle for bracket vs single function
  - N_BRACKETS for auto-generated brackets
  - CUSTOM_BRACKETS for UK-specific age ranges
  - Live timer showing elapsed time during computation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Reformat files with black (line length 79)
- Bump version from 0.2.0 to 0.2.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Point to vahid-ahmadi/OG-Core@performance-optimizations
- Includes loosened SS tolerances (mindist_SS: 1e-9→1e-3, RC_SS: 1e-8→1e-4)
- Includes optional Numba JIT compilation for hot-path functions
- ~55% faster steady state convergence

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
"dask",
"distributed",
"ogcore",
"ogcore @ git+https://github.com/vahid-ahmadi/OG-Core.git@performance-optimizations",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not change the package from ogcore on PyPI. We'll update OG-Core if needed.

setuptools.setup(
name="oguk",
version="0.2.0",
version="0.2.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bump to version 0.3.0 after these significant changes to link to the current PE-UK API.

@jdebacker
Copy link
Member

@vahid-ahmadi Can you explain the age brackets? OG-Core allows for age specific (by year of age) and non-age specific (all ages face same tax functions). What is useful about the age brackets vs the separate functions by year of age?

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