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 7da86fe
Browse filesBrowse the repository at this point in the historyBrowse files
In this lecture we study a basic infinite-horizon job search with Markov wage
20
+
In this lecture we study a basic infinite-horizon job search problem with Markov wage
21
21
draws
22
22
23
-
The exercise at the end asks you to add recursive preferences and compare
24
-
the result.
23
+
```{note}
24
+
For background on infinite horizon job search see, e.g., [DP1](https://dp.quantecon.org/).
25
+
```
26
+
27
+
The exercise at the end asks you to add risk-sensitive preferences and see how
28
+
the main results change.
25
29
26
30
In addition to what’s in Anaconda, this lecture will need the following libraries:
27
31
@@ -49,23 +53,32 @@ We study an elementary model where
49
53
50
54
* jobs are permanent
51
55
* unemployed workers receive current compensation $c$
52
-
* the wage offer distribution $\{W_t\}$ is Markovian
53
56
* the horizon is infinite
54
57
* an unemployment agent discounts the future via discount factor $\beta \in (0,1)$
55
58
56
-
The wage process obeys
59
+
### Set up
60
+
61
+
At the start of each period, an unemployed worker receives wage offer $W_t$.
62
+
63
+
To build a wage offer process we consider the dynamics
57
64
58
65
$$
59
-
W_{t+1} = \rho W_t + \nu Z_{t+1},
60
-
\qquad \{Z_t\} \text{ is IID and } N(0, 1)
66
+
W_{t+1} = \rho W_t + \nu Z_{t+1}
61
67
$$
62
68
63
-
We discretize this using Tauchen's method to produce a stochastic matrix $P$
69
+
where $(Z_t)_{t \geq 0}$ is IID and standard normal.
70
+
71
+
We then discretize this wage process using Tauchen's method to produce a stochastic matrix $P$.
72
+
73
+
Successive wage offers are drawn from $P$.
74
+
75
+
### Rewards
64
76
65
77
Since jobs are permanent, the return to accepting wage offer $w$ today is
66
78
67
79
$$
68
-
w + \beta w + \beta^2 w + \cdots = \frac{w}{1-\beta}
80
+
w + \beta w + \beta^2 w +
81
+
\cdots = \frac{w}{1-\beta}
69
82
$$
70
83
71
84
The Bellman equation is
@@ -79,30 +92,50 @@ $$
79
92
80
93
We solve this model using value function iteration.
81
94
95
+
+++
96
+
97
+
## Code
82
98
83
99
Let's set up a `namedtuple` to store information needed to solve the model.
84
100
85
101
```{code-cell} ipython3
86
102
Model = namedtuple('Model', ('n', 'w_vals', 'P', 'β', 'c'))
87
103
```
88
104
89
-
The function below holds default values and populates the namedtuple.
105
+
The function below holds default values and populates the `namedtuple`.
90
106
91
107
```{code-cell} ipython3
92
108
def create_js_model(
93
109
n=500, # wage grid size
94
110
ρ=0.9, # wage persistence
95
111
ν=0.2, # wage volatility
96
112
β=0.99, # discount factor
97
-
c=1.0 # unemployment compensation
113
+
c=1.0, # unemployment compensation
98
114
):
99
115
"Creates an instance of the job search model with Markov wages."
100
116
mc = qe.tauchen(n, ρ, ν)
101
-
w_vals, P = jnp.exp(mc.state_values), mc.P
102
-
P = jnp.array(P)
117
+
w_vals, P = jnp.exp(mc.state_values), jnp.array(mc.P)
103
118
return Model(n, w_vals, P, β, c)
104
119
```
105
120
121
+
Let's test it:
122
+
123
+
```{code-cell} ipython3
124
+
model = create_js_model(β=0.98)
125
+
```
126
+
127
+
```{code-cell} ipython3
128
+
model.c
129
+
```
130
+
131
+
```{code-cell} ipython3
132
+
model.β
133
+
```
134
+
135
+
```{code-cell} ipython3
136
+
model.w_vals.mean()
137
+
```
138
+
106
139
Here's the Bellman operator.
107
140
108
141
```{code-cell} ipython3
@@ -135,13 +168,13 @@ $$
135
168
136
169
Here $\mathbf 1$ is an indicator function.
137
170
138
-
The statement above means that the worker accepts ($\sigma(w) = 1$) when the value of stopping
139
-
is higher than the value of continuing.
171
+
*$\sigma(w) = 1$ means stop
172
+
* $\sigma(w) = 0$ means continue.
140
173
141
174
```{code-cell} ipython3
142
175
@jax.jit
143
176
def get_greedy(v, model):
144
-
"""Get a v-greedy policy."""
177
+
"Get a v-greedy policy."
145
178
n, w_vals, P, β, c = model
146
179
e = w_vals / (1 - β)
147
180
h = c + β * P @ v
@@ -153,8 +186,7 @@ Here's a routine for value function iteration.
153
186
154
187
```{code-cell} ipython3
155
188
def vfi(model, max_iter=10_000, tol=1e-4):
156
-
"""Solve the infinite-horizon Markov job search model by VFI."""
157
-
189
+
"Solve the infinite-horizon Markov job search model by VFI."
Copy file name to clipboardExpand all lines: lectures/newtons_method.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,18 +20,14 @@ kernelspec:
20
20
21
21
One of the key features of JAX is automatic differentiation.
22
22
23
-
While other software packages also offer this feature, the JAX version is
24
-
particularly powerful because it integrates so closely with other core
25
-
components of JAX, such as accelerated linear algebra, JIT compilation and
26
-
parallelization.
23
+
We introduced this feature in {doc}`autodiff`.
27
24
28
-
The application of automatic differentiation we consider is computing economic equilibria via Newton's method.
25
+
In this lecture we apply automatic differentiation to the problem of computing economic equilibria via Newton's method.
29
26
30
27
Newton's method is a relatively simple root and fixed point solution algorithm, which we discussed
31
28
in [a more elementary QuantEcon lecture](https://python.quantecon.org/newton_method.html).
32
29
33
-
JAX is almost ideally suited to implementing Newton's method efficiently, even
34
-
in high dimensions.
30
+
JAX is ideally suited to implementing Newton's method efficiently, even in high dimensions.
0 commit comments