Skip to content

Conversation

@jstac
Copy link
Contributor

@jstac jstac commented Nov 11, 2025

Summary

This PR updates the Job Search III lecture (mccall_model_with_sep_markov.md) to properly apply the CRRA utility function throughout the code implementation.

Key changes:

  • Added utility function transformation u(c, γ) = (c^(1-γ) - 1)/(1-γ) to all value function computations
  • Updated Bellman operator T() to use u(w_vals, γ) and u(c, γ) instead of raw values
  • Modified get_greedy() policy function to apply utility transformation
  • Updated plotting code to compute utility-transformed accept/reject values
  • Added γ parameter to model unpacking in all relevant functions
  • Fixed syntax error (missing comma) in create_js_with_sep_model() parameter list

Benefits:

  • Code now correctly matches the mathematical formulation in the Bellman equations
  • Wages and unemployment compensation properly enter value functions through utility function
  • Maintains consistency between mathematical theory and implementation

Test plan

  • Tested mccall_model_with_sep_markov.py script runs successfully
  • Converted back to markdown using jupytext
  • All code examples maintain correct functionality
  • Mathematical formulation and code implementation now aligned

🤖 Generated with Claude Code

…mulation

Modified mccall_model_with_sep_markov.md to correctly apply the CRRA utility function u(c, γ) = (c^(1-γ) - 1)/(1-γ) throughout the code implementation.

Key changes:
- Updated Bellman operator T() to use u(w_vals, γ) and u(c, γ)
- Updated get_greedy() policy function to apply utility transformation
- Modified plotting code to use utility-transformed values
- Added γ parameter unpacking in all relevant functions
- Fixed missing comma in create_js_with_sep_model() parameter list

The code now correctly matches the mathematical formulation where wages and unemployment compensation enter the value functions through the utility function rather than directly.

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

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

jstac commented Nov 11, 2025

Implementation Details

Updated the lecture to ensure mathematical consistency between the theory and code:

Mathematical Formulation (Bellman Equations)

The lecture correctly specifies that wages and unemployment compensation enter through a utility function:

v_e(w) = u(w) + β[α(Pv_u)(w) + (1-α)v_e(w)]
v_u(w) = max{v_e(w), u(c) + β(Pv_u)(w)}

Code Changes

Previously, the code was using raw wage values w and c directly. Now it properly applies the CRRA utility function:

Before:

accept = d * (w_vals + α * β * P @ v)
reject = c + β * P @ v

After:

accept = d * (u(w_vals, γ) + α * β * P @ v)
reject = u(c, γ) + β * P @ v

This ensures the code matches the theoretical model, where risk aversion (controlled by γ) affects decision-making through the utility function rather than using linear utility implicitly.

…mplementation

Updated mccall_fitted_vfi.md to implement the continuous wage offer model with CRRA utility.

Key changes:
- Added CRRA utility function u(c, γ) = (c^(1-γ) - 1)/(1-γ) to mathematical formulation
- Updated Model class to include ρ, ν, and γ parameters
- Implemented Monte Carlo integration for computing conditional expectations (Pv_u)(w)
- Updated Bellman operator T() to use u(w, γ) and u(c, γ)
- Added get_greedy() function for computing optimal policy
- Fixed all model unpacking throughout code
- Implemented compute_expectation() using w' = w^ρ * exp(ν * z) with standard normal draws
- Added Exercise 3: Exploring reservation wage as function of risk aversion γ
- Reformatted text: each sentence on separate line for better version control

Mathematical consistency:
- Code now matches theory where wages and unemployment compensation enter through utility function
- Monte Carlo approximation: (Pv_u)(w) ≈ (1/N) Σ v_u(w^ρ exp(ν z_i))
- Proper JAX implementation with interpolation for fitted value function iteration

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

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

jstac commented Nov 11, 2025

Additional Update: Job Search IV (Fitted VFI) Lecture

I've now completed the Job Search IV: Fitted Value Function Iteration lecture (mccall_fitted_vfi.md) with the same utility function approach.

Mathematical Updates

Added CRRA Utility to Bellman Operator:
The continuous wage case now correctly uses the utility function in the Bellman operator:

(Tv_u)(w) = max{
    (1/(1-β(1-α))) * (u(w) + αβ(Pv_u)(w)),
    u(c) + β(Pv_u)(w)
}

Monte Carlo Integration:
Implemented the conditional expectation using Monte Carlo with standard normal draws:

(Pv_u)(w) = ∫ v_u(w^ρ exp(ν z)) ψ(z) dz
          ≈ (1/N) Σ v_u(w^ρ exp(ν z_i))

Code Implementation

  1. Utility function: Added u(c, γ) with CRRA form
  2. Model structure: Extended to include ρ, ν, γ parameters and z_draws for Monte Carlo
  3. Bellman operator T(): Now uses u(w_grid, γ) and u(c, γ) throughout
  4. Expectation computation: Implemented compute_expectation(w) that:
    • Generates next period wages: w_next = w**ρ * jnp.exp(ν * z_draws)
    • Interpolates value function at these points
    • Returns the mean over Monte Carlo draws
  5. Policy function: Added get_greedy() using utility transformation
  6. New exercise: Shows how reservation wage decreases with risk aversion γ

Key Features

  • Fitted VFI: Combines value function iteration with linear interpolation
  • JAX implementation: Fully compatible with JAX's JIT compilation
  • Mathematical consistency: Code matches theory where utility mediates all consumption values
  • Clean formatting: Each sentence on separate line for better git diffs

The lecture now provides a complete treatment of continuous state space job search with risk aversion, demonstrating how fitted value function iteration handles infinite-dimensional problems through interpolation and Monte Carlo integration.

@jstac
Copy link
Contributor Author

jstac commented Nov 11, 2025

@mmcky Can you please trigger a rebuild of this when you've merged your changes and the system is stable again?

@mmcky
Copy link
Contributor

mmcky commented Nov 12, 2025

@jstac the latex build is reporting a missing equation reference

/home/runner/_work/lecture-python.myst/lecture-python.myst/lectures/mccall_fitted_vfi.md:146: WARNING: equation not found: bell2mcmc
  • Should this reference the bellman equation in VFI section?

Added the label 🏷️ bell2mcmc to the Bellman operator equation and
converted it from $$ delimiters to the {math} directive to support
cross-references. This fixes the build warning:

  WARNING: equation not found: bell2mcmc

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

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

jstac commented Nov 12, 2025

Ready to Merge

This PR is ready to merge. I've fixed the build error that was preventing the documentation from building.

Build Fix Applied

Fixed missing equation reference in mccall_fitted_vfi.md

Error: WARNING: equation not found: bell2mcmc

Fix: Added the label :label: bell2mcmc to the Bellman operator equation and converted it from $$ delimiters to the {math} directive to support cross-references.

Merge Strategy

This PR should be merged before PR #691. PR #691 builds on top of this PR and includes:

  • The new Job Search V lecture (persistent/transitory wage shocks)
  • Additional bibliography entries
  • Table of contents updates

After this PR is merged, PR #691 will need a simple rebase onto main, which should go smoothly with no conflicts. ✅

@jstac jstac merged commit e2c1183 into main Nov 12, 2025
1 check failed
@jstac jstac deleted the new_mccall_fitted branch November 12, 2025 10:06
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.

3 participants