Skip to content

Fix bugs and improve JS III#708

Merged
jstac merged 1 commit intomainfrom
jsiii-tweaks
Nov 16, 2025
Merged

Fix bugs and improve JS III#708
jstac merged 1 commit intomainfrom
jsiii-tweaks

Conversation

@jstac
Copy link
Contributor

@jstac jstac commented Nov 16, 2025

Summary

This PR fixes several bugs in the McCall model with separation lecture and improves the pedagogical structure:

  • Bug fixes: Fixed syntax errors including extra parenthesis, undefined variable w (should be w_vals), and incorrect use of jnp.max for scalar comparison
  • Pedagogical improvement: Added a first-pass solution method that directly iterates on both value functions before introducing the more efficient approach
  • Verification test: Added a test comparing both solution methods to verify they produce the same reservation wage
  • Exercise enhancement: Provided specific guidance on which c values to use in the exercise

Test plan

  • Converted the markdown file to Python using jupytext
  • Ran the Python file successfully without errors
  • Verified both solution methods produce identical reservation wages (difference: 0.00e+00)
  • Confirmed all plots and simulations run correctly

🤖 Generated with Claude Code

- Fix syntax errors: extra parenthesis in T_e function, undefined variable w
- Add first-pass solution method before efficiency improvements
- Add verification test comparing both solution methods
- Enhance exercise with specific guidance on c values to try
- Fix jnp.max to jnp.maximum for scalar comparison

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

Co-Authored-By: Claude <noreply@anthropic.com>
@jstac
Copy link
Contributor Author

jstac commented Nov 16, 2025

Bug Fix: Syntax Errors

Fixed several critical syntax errors that prevented the code from running:

  1. Line 269: Removed extra closing parenthesis in T_e function
  2. Line 269: Changed u(w, γ) to u(w_vals, γ) - the variable w was undefined
  3. Line 295: Changed jnp.max(error_u, error_e) to jnp.maximum(error_u, error_e) for proper scalar comparison
  4. Line 323-325: Added missing initial conditions v_u_init and v_e_init when calling solve_model_first_pass

All these fixes are necessary for the code to run successfully.

@jstac
Copy link
Contributor Author

jstac commented Nov 16, 2025

Pedagogical Improvement: Two-Stage Solution Approach

The lecture now presents two solution methods in sequence:

First Pass (Lines 237-326):

  • Introduces a straightforward approach that directly iterates on both v_u and v_e
  • Implements separate Bellman operators T_u and T_e
  • Easier for students to understand as it directly follows the theory
  • Includes a road test with plots showing the value functions

Improved Efficiency (Lines 351+):

  • Shows how to eliminate v_e and iterate only on v_u
  • Demonstrates optimization techniques in computational economics
  • Uses JAX compilation for better performance

Verification (Lines 467-471):
Added a test that confirms both methods produce identical results:

Reservation wage (first method):  1.365155
Reservation wage (second method): 1.365155
Difference: 0.00e+00

This helps students understand that efficiency improvements don't change the solution, just the computation speed.

@jstac
Copy link
Contributor Author

jstac commented Nov 16, 2025

Exercise Enhancement

The exercise at the end now provides much clearer guidance for students (lines 919-922):

Before:

Create a plot that investigates more carefully how the steady state cross-sectional unemployment rate changes with unemployment compensation.

After:

Create a plot that investigates more carefully how the steady state cross-sectional unemployment rate changes with unemployment compensation.

Try a range of values for unemployment compensation c, such as c = 0.2, 0.4, 0.6, 0.8, 1.0.
For each value, compute the steady-state cross-sectional unemployment rate and plot it against c.

What relationship do you observe between unemployment compensation and the unemployment rate?

This gives students:

  • Specific values to try (removes ambiguity)
  • Clear instructions on what to compute
  • A thought-provoking question to guide their analysis

These hints match the solution that was already provided, making the exercise more accessible.

@jstac jstac changed the title Fix bugs and improve McCall model lecture Fix bugs and improve JS III Nov 16, 2025
@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-708--sunny-cactus-210e3e.netlify.app (1927dba)

📚 Changed Lecture Pages: mccall_model_with_sep_markov

@jstac jstac merged commit f62707f into main Nov 16, 2025
1 check passed
@jstac jstac deleted the jsiii-tweaks branch November 16, 2025 03:43
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.

1 participant