@@ -51,14 +51,14 @@ A sequence of budget constraints constrains the triple of sequences $y, c, a$
5151
5252$$
5353a_{t+1} = R (a_t+ y_t - c_t), \quad t =0, 1, \ldots T
54- $$
54+ $$ (eq:a_t)
5555
5656Our model has the following logical flow
5757
5858 * start with an exogenous income sequence $y$, an initial financial wealth $a_0$, and
5959 a candidate consumption path $c$.
6060
61- * use equation (1) to compute a path $a$ of financial wealth
61+ * use equation {eq}`eq:a_t` to compute a path $a$ of financial wealth
6262
6363 * verify that $a_{T+1}$ satisfies the terminal wealth constraint $a_{T+1} \geq 0$.
6464
@@ -160,7 +160,7 @@ y_1 \cr y_2 \cr y_3 \cr \vdots \cr y_T
160160```{exercise}
161161:label: consmooth_ex1
162162
163- In the {eq}`fst_ord_inverse`, we multiply the inverse of the matrix on the left ( $A$) . In this exercise, please confirm that
163+ In the {eq}`fst_ord_inverse`, we multiply the inverse of the matrix $A$. In this exercise, please confirm that
164164
165165$$
166166\begin{bmatrix}
@@ -222,7 +222,7 @@ h_0 \equiv \sum_{t=0}^T R^{-t} y_t = \begin{bmatrix} 1 & R^{-1} & \cdots & R^{-T
222222\begin{bmatrix} y_0 \cr y_1 \cr \vdots \cr y_T \end{bmatrix}
223223$$
224224
225- By iterating on equation (1) and imposing the terminal condition
225+ By iterating on equation {eq}`eq:a_t` and imposing the terminal condition
226226
227227$$
228228a_ {T+1} = 0,
251251
252252This is the consumption-smoothing model in a nutshell.
253253
254- We implement this model in ` compute_optimal `
255-
256- ``` {code-cell} ipython3
257- def compute_optimal(model, a0, y_seq):
258- R, T = model.R, model.T
259-
260- # non-financial wealth
261- h0 = model.β_seq @ y_seq # since β = 1/R
262-
263- # c0
264- c0 = (1 - 1/R) / (1 - (1/R)**(T+1)) * (a0 + h0)
265- c_seq = c0*np.ones(T+1)
266-
267- # verify
268- A = np.diag(-R*np.ones(T), k=-1) + np.eye(T+1)
269- b = y_seq - c_seq
270- b[0] = b[0] + a0
271-
272- a_seq = np.linalg.inv(A) @ b
273- a_seq = np.concatenate([[a0], a_seq])
274-
275- return c_seq, a_seq
276- ```
277-
278254+++ {"user_expressions": []}
279255
280256## Permanent income model of consumption
@@ -286,7 +262,7 @@ In the calculations below, please we'll set default values of $R > 1$, e.g., $
286262
287263### Step 1
288264
289- For some $(T+1) \times 1$ $y$ vector, use matrix algebra to compute
265+ For some $(T+1) \times 1$ $y$ vector, use matrix algebra to compute $h_0$
290266
291267$$
292268\sum_ {t=0}^T R^{-t} y_t = \begin{bmatrix} 1 & R^{-1} & \cdots & R^{-T} \end{bmatrix}
335311
336312Let's verify this with our Python code.
337313
314+ First we implement this model in `compute_optimal`
315+
316+ ```{code-cell} ipython3
317+ def compute_optimal(model, a0, y_seq):
318+ R, T = model.R, model.T
319+
320+ # non-financial wealth
321+ h0 = model.β_seq @ y_seq # since β = 1/R
322+
323+ # c0
324+ c0 = (1 - 1/R) / (1 - (1/R)**(T+1)) * (a0 + h0)
325+ c_seq = c0*np.ones(T+1)
326+
327+ # verify
328+ A = np.diag(-R*np.ones(T), k=-1) + np.eye(T+1)
329+ b = y_seq - c_seq
330+ b[0] = b[0] + a0
331+
332+ a_seq = np.linalg.inv(A) @ b
333+ a_seq = np.concatenate([[a0], a_seq])
334+
335+ return c_seq, a_seq
336+ ```
337+
338338We use an example where the consumer inherits $a_0<0$ (which can be interpreted as a student debt).
339339
340340The income process $\{y_t\}_{t=0}^{T}$ is constant and positive up to $t=45$ and then becomes zero afterward.
@@ -353,6 +353,8 @@ print('check a_T+1=0:',
353353 np.abs(a_seq[-1] - 0) <= 1e-8)
354354```
355355
356+ The visualization shows the path of income, consumption, and financial assets.
357+
356358```{code-cell} ipython3
357359# Sequence Length
358360T = cs_model.T
@@ -368,9 +370,9 @@ plt.ylabel(r'$c_t,y_t,a_t$')
368370plt.show()
369371```
370372
371- +++ {"user_expressions": [ ] }
373+ Note that $a_{T+1} = 0$ is satisfied.
372374
373- We can evaluate the welfare using the formula {eq}` welfare `
375+ We can further evaluate the welfare using the formula {eq}`welfare`
374376
375377```{code-cell} ipython3
376378def welfare(model, c_seq):
@@ -384,7 +386,7 @@ print('Welfare:', welfare(cs_model, c_seq))
384386
385387+++ {"user_expressions": []}
386388
387- ### Feasible consumption variations ###
389+ ### Feasible consumption variations
388390
389391To explore what types of consumption paths are welfare-improving, we shall create an **admissible consumption path variation sequence** $\{v_t\}_{t=0}^T$
390392that satisfies
0 commit comments