Skip to content

🇬🇧 English · 🇪🇸 Español

Showcase notebooks

Choose an economic question, run one example, and then change an assumption. The catalog links to executed notebooks and their editable Python sources in both languages. The 00 notebooks describe earlier releases; they are historical tours, not the starting point for the current package.

Choose a learning path

For portfolio, technical and fundamental research, start with the investment research guide and its executed bilingual notebooks, investment_research.ipynb and investment_research_es.ipynb.

The numbers below refer to the linked catalog. The order within each row moves from a focused example to a broader application.

Your question Suggested sequence What to examine
How do I identify a macroeconomic shock? 06 → 07 → 14 → 28 Ordering, shock units, identifying assumptions and weak instruments
How do I evaluate a policy intervention? 10 → 15 → 24 → 29 → 60 Comparison groups, estimands, uncertainty and overlap
How do I forecast with many indicators? 34 → 19 → 48 → 59 Held-out observations, a benchmark, release dates and revisions
How do I build an uncertainty index? 11 → 13 → 30 → 37 Corpus provenance, normalization and validation of the measure
Why does household heterogeneity matter? 01 → 03 → 05 → 31 → 44 → 74 Budget constraints, distributions, distributional LP and equilibrium feedback
How do I solve and estimate structural models? 21 → 41 → 42 → 43 → 74 Equilibrium residuals, identification, Tempered SMC and sampling diagnostics
Which numerical method fits my model? 22 → 51 → 52 → 53 → 56 → 70 → 71 → 72 Approximation error, grid sensitivity, reduced nonlinear examples and convergence
How do tariffs propagate through production? 55 → 61 → 62 → 63 → 65; then 64 → 75 Calibration provenance, accounting, welfare definition, CES supply-chain bottlenecks and solver limits
How do I model sovereign debt crises and default risk? 36 → 50 → 73 Endogenous default incentives, debt maturity, collateral sudden stops and debt restructuring
How do supply chains, climate policy and spatial migration interact? 32 → 55 → 65 → 71 → 75 2nd-order network curvature, carbon border adjustments, dynamic spatial hat-algebra and PolicyStudio audits
How do I preserve a complete empirical or model experiment? 69 → 06 → 55 Explicit units and assumptions, retained audits, archive round-trips and scenario limits
How do I check a solver against a published result? 66 → 67 → 68 → 12 Closed forms, independent solution routes, tolerances and the evaluation criterion

For a first session, choose one of 06, 10, 11 or 34. Choose 69 for a complete three-workflow study/export tutorial (Puremacro 5.6.0). For v6.0.0 flagship and pedagogical workflows, explore 72 for the unified end-to-end suite, 73 for quantitative sovereign default, 74 for distributional micro-to-macro HANK, or 75 for supply-chain networks and spatial climate policy. Each gives a specific question to answer before moving to a larger policy exercise.

This catalog follows the library in the repository checkout. The separate MAV course edition pins puremacro==5.5.0 with Python 3.12+ and immutable course tag course-2026A-5.5.0. Its 72-notebook execution evidence identifies the candidate archive actually executed; public-wheel equivalence belongs to the release record. Use that edition's own setup in a separate environment. Its numbering and HTML/JavaScript labs are separate from this catalog.

For nonlinear DSGE work, the updated MAV T02_A–D sequence uses the v5.7.1 model and solver workflows. It has separate execution evidence and setup instructions from the original 5.5.0 course edition.

Run and change an example

A local workstation install is the supported path. From a repository checkout, install the notebook tools and a notebook interface:

python -m pip install -e ".[notebooks]" jupyterlab
python -m jupyterlab notebooks

Select the kernel for that environment. Keep notebooks/_nbstyle.py beside the showcases; several examples also use bundled files from the repository. Open an .ipynb, restart its kernel, and run all cells before changing an exercise.

The .py files in Jupytext percent format are the editable sources. Rebuild both languages after an edit:

python tools/build_notebooks.py 34_penalized_macro_forecasting 34_penalized_macro_forecasting_es

# Execute to temporary artifacts and validate their outputs.
python tools/build_notebooks.py --check 34_penalized_macro_forecasting 34_penalized_macro_forecasting_es

# Inspect existing artifacts without executing them.
python tools/build_notebooks.py --validate-only --suite showcase

--suite showcase selects the top-level showcases and notebooks/course/; --suite curso selects curso/notebooks/. Without a name or suite, the tool processes both suites. Build individual examples first: simulation, bootstrap and Bayesian examples have different computation costs. Browser execution is best-effort; consult the tablet and Pyodide guide. Local LLM inference requires a desktop engine; its mock fallback demonstrates the interface only.

Read the evidence before the conclusion

Check the data provenance, observation units, estimand, and uncertainty measure before interpreting a chart. Country labels and realistic dates do not make simulated observations empirical evidence. Fixed seeds reproduce an experiment; they do not establish its accuracy or generality.

  • 10 — DiD: the overall ATT needs uncertainty for its own aggregation. The event-study bands are pointwise. An interval can miss the planted truth in one simulated sample.
  • 34 — forecasting: compare predictions for later, unused observations with a simple benchmark. In-sample fit and variable selection answer other questions.
  • 48 and 59 — nowcasting: 48 holds target GDP out of bridge estimation and labels its single-vintage projection contributions as diagnostics. Exact news attribution requires two information sets under a fixed model, as in 59. Its separate simulated PIT experiment does not validate the actual nowcast densities. These are synthetic examples, not official forecasts.
  • 50 — fiscal analysis: identify the shock before interpreting an impulse response as a multiplier. Debt ratios, percentage points and decimal changes must use consistent units; the debt scenarios impose their own assumptions.
  • 61 and 62 — policy simulations: the small trade preset in 61 is hand-built; 62 separates flexible building blocks evaluated at given prices from a small synthetic benchmark solved under consistent accounting. With an active flexible setting, solve_flexible_trade_equilibrium uses the quasi-condensed solver on calibrations of up to 100 country-sector cells, or at any size with method="quasi_condensed" (dense Newton). On larger tables without an explicit method, or with another method, it raises ValueError. Final-demand sourcing stays fixed-coefficient unless sigma_trade is set. Report nominal wages, price-deflated wages, output and welfare according to their definitions.
  • 63–65 — advanced trade: 63 audits tariff-game best responses; 64 separates a scalar toy fold from synthetic CGE continuation; 65 demonstrates Hicksian EV/CV and endpoint attribution. The historical TOT/Alloc/TariffRec decomposition remains unavailable. See structural validation status.
  • 66 — optimal policy: the closed-form checks show that the policy solvers implement the Clarida–Galí–Gertler formulas at any admissible calibration. By default stabilization_bias compares unconditional losses. At low discount factors that criterion ranks timeless commitment below discretion, although commitment still wins when the loss is evaluated from the steady state, which loss_criterion="conditional" does.
  • 67 — Bewley classics: Aiyagari's Table I is reproduced exactly and every ordering in Aiyagari's Table II and Huggett's tables holds, but their decimals differ by more than the notebook's numerical error. At high persistence, the choice of Markov chain moves Aiyagari's rates by more than those differences.
  • 68 — third order: matching simulated paths does not show that a tensor is right; the notebook compares every tensor with closed forms and with live Dynare output, and checks higher-order Sylvester conditioning and algebraic residuals. The exact pruned moments match a closed form and Dynare's means and variances. Dynare's order-3 autocorrelations do not: a closed form and Dynare's own long simulations both reject them. Skewness and kurtosis still come from simulations.
  • 70 — nonlinear DSGE workflows: ordered .mod commands preserve per-statement parameter snapshots; third-order Sylvester operator conditioning (curvature_operator_condition) is distinct from diagonal Schur-block conditioning (schur_block_condition); separable Chebyshev time iteration and constrained matrix-free Newton–Krylov transitions (mcp=True, terminal_policy) agree with direct solvers on the declared domain and horizon.
  • 71 — frontier macro workflows: unites pure-NumPy forward AD (DualArray, HyperDualArray, hessian_forward), sequence-space DAG Jacobians and Whittle HANK estimation (BlockDAG, hank_loglik_whittle), 2nd/3rd-order pruned nonlinear OccBin with precautionary risk shifts, mixed-frequency state-space nowcasting with Banbura–Modugno news decomposition, continuous-time upwind HJB / adjoint KFE with a HetBlock bridge, Baqaee–Farhi 2nd-order network macro, Caliendo–Parro–Rossi-Hansberg dynamic spatial migration hat-algebra, and self-auditing PolicyStudio counterfactual grids with zero-server interactive HTML5/SVG export.
  • 72 — v6 component workflows: native DSGE likelihood and score checks, a Gaussian SMC reference, reduced HANK and aggregate-risk demonstrations, sovereign calculations, synthetic distributional LPs and separate climate scenarios. See each section for its validation limits.
  • 73 — sovereign debt and restructuring: checks short-term price bounds and iteration residuals, distinguishes grid averages from simulated statistics, and explores long-term prices, experimental collateral diagnostics, spread accounting and signed restructuring effects. It is not a published replication.
  • 74 — distributional LPs and reduced transitions: synthetic-panel adding-up checks, a bridge identity check using the same matrix twice, Gaussian SMC diagnostics and prescribed nonlinear DAG responses. It does not estimate HANK or validate independently solved household deciles.
  • 75 — green transition networks and spatial IAM: verifies exact global population conservation (\(\sum_r L_{r,t} = \bar{L}\) to \(< 10^{-12}\)) and atmospheric carbon mass balance; documents 2nd-order macroeconomic Hessian amplification in CES supply chains under bottleneck sector shocks; contrasts emissions leakage and spatial welfare incidence under unilateral carbon pricing vs Carbon Border Adjustment Mechanisms (CBAM); and exports an audited, self-contained interactive HTML5/SVG counterfactual report via PolicyStudio.

For detailed derivations, mathematical exposition, and parameter reference tables of the underlying v6.0.0 engines, see the dedicated documentation guides: - Forward AD and the Differentiable Model Protocol - Vectorized Tempered SMC Inference - Sequence-Space HANK and Aggregate Risk - Quantitative Sovereign Default and Sudden Stops - Distributional and Quantile Local Projections - Production Networks, Spatial Migration and Climate IAM

The notebook template connects a motivating question, equations, intuition, runnable code, output interpretation, an exercise and related examples. Use its evidence checklist when adapting an example to your own data. Copy runnable code from the linked sources, where inputs, seeds and diagnostics appear together.

Complete showcase catalog

Each title opens an executed notebook; “source” opens its editable .py file.

Notebook Question and method Spanish edition
00_whats_new_in_puremacro_3_0 · source Milestone 3.0: Analytic Kalman gradients, NUTS HMC, and HANK Sequence-Space bridge 00_whats_new_in_puremacro_3_0_es · source
00_whats_new_in_puremacro_2_0 · source Milestone 2.0: Unified API (lags, horizon, ci), result objects, and exporters 00_whats_new_in_puremacro_2_0_es · source
01_wealth_inequality · source Aiyagari & Huggett incomplete markets, permanent \(\beta\)-heterogeneity, Lorenz & Gini 01_wealth_inequality_es · source
02_aggregate_shocks · source Krusell–Smith approximate aggregation, transition dynamics, representative-agent benchmark 02_aggregate_shocks_es · source
03_life_cycle_and_demographics · source Finite-horizon life-cycle consumption-saving, cohort wealth by age, mortality weighting 03_life_cycle_and_demographics_es · source
04_firm_dynamics · source Hopenhayn industry equilibrium with endogenous entry/exit and selection 04_firm_dynamics_es · source
05_portfolios_and_preferences · source Two-asset portfolio choice, Epstein–Zin recursive utility, EGM vs VFI 05_portfolios_and_preferences_es · source
06_svar_identification · source Structural VAR identification: Cholesky recursive ordering vs sign restrictions 06_svar_identification_es · source
07_local_projections · source Jordà Local Projections with Newey-West HAC inference & state-dependent IRFs 07_local_projections_es · source
08_garch_volatility · source Pure-NumPy GARCH(1,1) MLE & Engle Dynamic Conditional Correlation (DCC) 08_garch_volatility_es · source
09_growth_at_risk · source Adrian-Boyarchenko-Giannone Growth-at-Risk via quantile autoregression & skew-\(t\) fitting 09_growth_at_risk_es · source
10_staggered_did · source Staggered DiD with pointwise event-study bands and a unit-bootstrap interval for overall ATT 10_staggered_did_es · source
11_narrative_uncertainty · source Pure-NumPy Economic Policy Uncertainty (EPU) text index construction 11_narrative_uncertainty_es · source
12_validation_gallery · source Validation scorecard comparing puremacro implementations against independent references 12_validation_gallery_es · source
13_build_your_own_index · source Four index recipes: text EPU, simplified JLN-style uncertainty, FCI and comovement 13_build_your_own_index_es · source
14_tax_multiplier_three_ways · source US tax multiplier: Blanchard-Perotti SVAR, Romer-Romer narrative LP, Mertens-Ravn proxy-SVAR 14_tax_multiplier_three_ways_es · source
15_lp_did · source Local Projections Difference-in-Differences (LP-DiD) under staggered treatment 15_lp_did_es · source
16_regime_girf · source Generalized Impulse Response Functions (GIRF) for threshold VAR / Markov-switching VAR 16_regime_girf_es · source
18_beveridge_curve · source Beveridge curve dynamics, matching efficiency, and vacancy-unemployment shifts 18_beveridge_curve_es · source
19_model_confidence_set · source Hansen-Lunde-Nason Model Confidence Set (MCS) for competitive forecasting 19_model_confidence_set_es · source
20_unit_roots_with_power · source Elliott-Rothenberg-Stock DF-GLS and Ng-Perron high-power unit root tests 20_unit_roots_with_power_es · source
21_dynare_vfi_dsl · source Declarative dynamic programming with puremacro.dp: precautionary savings, the exact wealth Gini and a simulated panel 21_dynare_vfi_dsl_es · source
22_continuous_time_hjb · source Achdou et al. (2022) Continuous-Time Hamilton-Jacobi-Bellman finite difference scheme 22_continuous_time_hjb_es · source
23_aiyagari_endogenous_labor · source General equilibrium incomplete markets with endogenous labor supply choice 23_aiyagari_endogenous_labor_es · source
24_synthetic_control · source Abadie et al. Synthetic Control Method with in-space and in-time placebo tests 24_synthetic_control_es · source
25_frequency_connectedness · source Baruník & Křehlík frequency-domain variance decomposition spillover networks 25_frequency_connectedness_es · source
26_cycles_and_bandpass · source Baxter-King, Christiano-Fitzgerald, and Beveridge-Nelson cycle filtering 26_cycles_and_bandpass_es · source
27_garch_midas_macro_risk · source Engle-Ghysels-Sohn GARCH-MIDAS mixed-frequency volatility modeling 27_garch_midas_macro_risk_es · source
28_weak_iv_anderson_rubin · source Anderson-Rubin weak-instrument robust confidence sets for LP-IV 28_weak_iv_anderson_rubin_es · source
29_synthetic_did · source Arkhangelsky et al. Synthetic Difference-in-Differences (SDID) 29_synthetic_did_es · source
30_narrative_bursts_and_transcripts · source Kleinberg burst detection on central bank speech transcripts 30_narrative_bursts_and_transcripts_es · source
31_sequence_space_hank · source Auclert et al. (2021) Sequence-Space Jacobian method for HANK models 31_sequence_space_hank_es · source
32_climate_macro_dice · source Nordhaus DICE integrated assessment model & optimal carbon tax policy 32_climate_macro_dice_es · source
33_gdp_nowcasting_news · source Single-vintage PCA/bridge demonstration; use 48 for a held-out target 33_gdp_nowcasting_news_es · source
34_penalized_macro_forecasting · source Elastic Net and Adaptive Lasso with chronological holdout forecasts and a benchmark 34_penalized_macro_forecasting_es · source
35_empirical_benchmark_replications · source Replication scorecard across SVAR, LP, and DiD benchmark literatures 35_empirical_benchmark_replications_es · source
36_climate_sovereign_debt_risk · source Physical and transition climate risk transmission to sovereign debt sustainability 36_climate_sovereign_debt_risk_es · source
37_central_bank_narrative_sentiment · source Central bank communication sentiment scoring and high-frequency monetary LP 37_central_bank_narrative_sentiment_es · source
38_real_time_vintages_and_revisions · source Vintage and revision diagnostics; distinguish simulated examples from provider coverage 38_real_time_vintages_and_revisions_es · source
39_multilingual_narrative_harvesting · source Multi-source narrative harvesting (50+ connectors) and multilingual macro scoring 39_multilingual_narrative_harvesting_es · source
40_quarterly_national_accounts · source Three approaches to GDP accounting: rebasing, identities, and growth contributions 40_quarterly_national_accounts_es · source
41_dynare_frontier_showcase · source Smets-Wouters (2007) native smoother & estimation, OccBin ZLB, Ramsey transitions 41_dynare_frontier_showcase_es · source
42_dsge_bayesian_estimation_and_diagnostics · source Flagship Smets-Wouters Bayesian estimation, mode_check, MCMC, fan charts, MDD 42_dsge_bayesian_estimation_and_diagnostics_es · source
43_dsge_nuts_and_analytic_gradients · source Bayesian DSGE via NUTS with exact analytic Kalman score recursion 43_dsge_nuts_and_analytic_gradients_es · source
44_hank_sequence_space_bridge · source HANK Sequence-Space bridge from .mod files, Fake-News Jacobians, MIT transitions 44_hank_sequence_space_bridge_es · source
45_dsge_discretion_dsge_var_and_news_shocks · source Discretionary policy vs commitment, DSGE-VAR prior optimization, news shocks 45_dsge_discretion_dsge_var_and_news_shocks_es · source
46_dsge_particle_filtering_and_markov_switching · source Differentiable OccBin for NUTS, Markov-switching DSGE, particle filtering 46_dsge_particle_filtering_and_markov_switching_es · source
47_applied_central_bank_policy_suite · source Monetary policy stance, counterfactual Taylor rules, fan charts, sentiment 47_applied_central_bank_policy_suite_es · source
48_applied_realtime_nowcasting_and_news · source Synthetic ragged-edge nowcast with held-out GDP, projection diagnostics and revision tests 48_applied_realtime_nowcasting_and_news_es · source
49_applied_macroprudential_gar_and_stress · source Growth-at-Risk quantile densities (skew-\(t\)), systemic connectedness networks 49_applied_macroprudential_gar_and_stress_es · source
50_applied_fiscal_multipliers_and_debt_sustainability · source Frozen US fiscal data, narrative tax instruments and stochastic debt scenarios with explicit units 50_applied_fiscal_multipliers_and_debt_sustainability_es · source
51_continuous_projection_collocation_and_fem · source Continuous state-space DP: Chebyshev orthogonal collocation vs FEM Galerkin with borrowing kinks 51_continuous_projection_collocation_and_fem_es · source
52_continuous_transition_mit_shocks · source Non-linear continuous transition dynamics & MIT shocks via coupled EGM-Young operator 52_continuous_transition_mit_shocks_es · source
53_exact_analytic_ift_gradients · source IFT parameter sensitivities, adjoints and comparison with finite differences 53_exact_analytic_ift_gradients_es · source
54_deep_macro_pinns_high_dim · source High-dimensional dynamic models (10+ states) via pure-NumPy Physics-Informed Neural Networks 54_deep_macro_pinns_high_dim_es · source
55_quantitative_spatial_and_trade_ge · source Quantitative spatial & trade general equilibrium: Caliendo-Parro tariffs & Allen-Arkolakis geography 55_quantitative_spatial_and_trade_ge_es · source
56_implicit_hjb_and_continuous_kfe · source Continuous-time HJB implicit upwind solver, adjoint KFE stationary wealth density & Aiyagari GE 56_implicit_hjb_and_continuous_kfe_es · source
57_multiconstraint_occbin_and_dml · source Multi-constraint OccBin (\(M \ge 2\): ZLB + credit limits) & Double Machine Learning (DML-PLR) 57_multiconstraint_occbin_and_dml_es · source
58_latin_america_realtime_macro · source Simulated Latin American vintages, portable .pmz cartridges and news/noise diagnostics 58_latin_america_realtime_macro_es · source
59_latam_realtime_nowcast_and_news · source Synthetic Latin America nowcasting, vintage news attribution and a separate PIT experiment 59_latam_realtime_nowcast_and_news_es · source
60_interactive_dml_irm_and_iv · source Interactive Double ML: IRM (ATE/ATT) with regularized logistic CD, propensity overlap & DML-IV 60_interactive_dml_irm_and_iv_es · source
61_quantitative_policy_simulators · source Stylized trade preset and sequence-space HANK monetary experiments 61_quantitative_policy_simulators_es · source
62_flexible_trade_cge · source Flexible cost/demand/markup building blocks and a synthetic benchmark GE solved by two routes 62_flexible_trade_cge_es · source
63_trade_wars_and_nash_tariffs · source Hicksian tariff games: fixed baseline and actions, best-response regret and audited equilibrium recovery 63_trade_wars_and_nash_tariffs_es · source
64_singularities_and_keller_pac · source Spectral bounds, scalar toy fold, small synthetic CGE continuation and a planted stiff matrix 64_singularities_and_keller_pac_es · source
65_gvc_cascades_and_welfare_decomposition · source Data provenance, cost propagation and Hicksian EV/CV with price, factor-income and fiscal-transfer attribution 65_gvc_cascades_and_welfare_decomposition_es · source
66_optimal_policy_cgg1999_replication · source Replication of Clarida–Galí–Gertler (1999): discretion, simple-rule and timeless commitment against closed forms, and the loss criterion 66_optimal_policy_cgg1999_replication_es · source
67_bewley_classics_replication · source Replication of Huggett (1993) and Aiyagari (1994): Table I exactly, the equilibrium tables' orderings, their decimals against numerical error, and the Markov chain 67_bewley_classics_replication_es · source
68_third_order_perturbation_trust · source Third-order perturbation checked against closed forms and live Dynare 7.0, a tensor error no path can see, and what the checked third order says 68_third_order_perturbation_trust_es · source
69_reproducible_studies · source Reproducible Mexico VAR, household transfer and OECD tariff studies: assumptions, audits, figures and portable archives 69_reproducible_studies_es · source
70_nonlinear_dsge_workflows_and_accuracy · source Ordered .mod commands, Sylvester conditioning, separable Chebyshev policies and constrained Newton–Krylov transitions 70_nonlinear_dsge_workflows_and_accuracy_es · source
71_frontier_macro_workflows · source Frontier macro suite: forward AD, sequence-space HANK, pruned OccBin, mixed-frequency nowcasting, continuous HJB, network/spatial GE & PolicyStudio 71_frontier_macro_workflows_es · source
72_macro_v6_flagship_workflows · source puremacro v6.0.0 flagship suite: differentiable protocol, tempered SMC, nonlinear HANK & aggregate risk, quantitative sovereign default, distributional LP & spatial climate IAM 72_macro_v6_flagship_workflows_es · source
73_sovereign_debt_crises_and_restructuring · source Sovereign debt crises: Arellano endogenous default, Chatterjee–Eyigungor long-term debt, Mendoza collateral sudden stops and debt restructuring 73_sovereign_debt_crises_and_restructuring_es · source
74_inequality_distributional_lp_and_hank · source Micro to macro inequality: functional/quantile distributional LPs with exact adding-up, structural HANK bridge, Tempered SMC and nonlinear transitions 74_inequality_distributional_lp_and_hank_es · source
75_green_transition_networks_and_spatial_iam · source Green transition and spatial IAM: Baqaee–Farhi 2nd-order supply chain bottlenecks, dynamic spatial migration, carbon border adjustments and PolicyStudio 75_green_transition_networks_and_spatial_iam_es · source
76_bilingual_macro_showcase · source Policy, counterfactuals and portfolios: sequence-space Ramsey policy, risky steady state, SVAR identification suite, McKay–Wolf counterfactual rules, GIV and functional VARs, risk-parity/HRP/Black–Litterman allocation and backtests 76_bilingual_macro_showcase_es · source
local_llm_uncertainty · source Local inference with optional desktop engines; offline mock fallback local_llm_uncertainty_es · source