Skip to content

About

Equilibrium calibration code for a research project on middle-income trap

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Dynamic Product-Line Calibration with Hard Exit Moments

tests

This repository implements and validates a numerical calibration of a dynamic product-line model with country- and state-specific research capital. The exercise asks how hard exit targets for advanced- and middle-income producers restrict stationary solutions for catch-up, innovation, and frontier sorting.

The repository is a computational research prototype, not a finished structural estimate. The archived vectors solve the implemented system to high precision, while the diagnostics also show that the current moments do not point-identify a unique equilibrium.

What the code does

  • Translates the static and dynamic model blocks into nine equilibrium and first-order-condition residuals.
  • Adds four calibration targets: a wage ratio, an R&D-intensity ratio, and two catch-up probabilities implied by the exit moments.
  • Uses bounded parameter transformations and deterministic multistart nonlinear least squares.
  • Recomputes saved results instead of trusting stored metadata.
  • Checks transition-matrix invariance, constraints, archived roots, and local Jacobian rank.
  • Regenerates compact result tables and representative sampled points.

Verified numerical result

The archived reference vector has a maximum hard residual of $8.55\times10^{-14}$. All 333 archived vectors re-evaluate below the stated $10^{-6}$ tolerance; the worst recomputed residual is $2.73\times10^{-11}$.

The $13\times15$ residual Jacobian has numerical rank 12, so the local nullity is 3. The reference point is therefore described as the smallest-$\chi$ point in the archived sample, not as a unique solution or global minimum. See Validation and limitations for the complete interpretation.

Quick start

The archived search count is sensitive to numerical-library versions. Python 3.12.13, NumPy 2.3.3, pandas 2.2.3, and SciPy 1.16.2 are pinned here.

python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
pytest

Validate the reference point:

python scripts/reproduce_selected.py

Run the broader independent diagnostics:

python scripts/audit_selected_equilibrium.py

Regenerate result summaries from the archived roots:

python scripts/summarize_results.py

The full multistart search is slower and writes to outputs/recomputed/ so it does not overwrite the archived reference files:

python scripts/search_multistart.py --workers 8

A fast smoke test is available with --max-seeds 5 --workers 1.

Repository map

Path Purpose
src/hard_exit_model/equilibrium.py Economic primitives, transforms, static block, contests, Bellman equations, FOCs, and serialization
src/hard_exit_model/calibration.py Hard residuals, search bounds, and root deduplication
src/hard_exit_model/diagnostics.py Transition, metadata, Jacobian, and identification checks
scripts/search_multistart.py Deterministic parallel nonlinear search with run metadata
scripts/reproduce_selected.py Fail-loud verification of the archived reference vector
scripts/summarize_results.py Reproducible CSV and representative-result generation
scripts/audit_selected_equilibrium.py Independent numerical and model-scope audit
tests/ Transform, derivative, accounting, archive, seed, and solver tests
config/ Authoritative calibration targets and restrictions
seed_data/ Inputs used to construct deterministic multistart seeds
outputs/ Archived roots and compact descriptive results

Research status

The code establishes numerical accuracy for the equations that are actually implemented. It does not establish uniqueness, global optimality, empirical validation of the preliminary exit moments, or full resource feasibility. These distinctions are documented rather than hidden; see Model and computational structure, Validation and limitations, and Output provenance.

About

Equilibrium calibration code for a research project on middle-income trap

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages