Skip to content

Commit acf04f4

Browse files
committed
misc
1 parent f358d2a commit acf04f4

File tree

2 files changed

+447
-0
lines changed

2 files changed

+447
-0
lines changed

sandpit/cons_smooth.md

Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
---
2+
jupytext:
3+
text_representation:
4+
extension: .md
5+
format_name: myst
6+
format_version: 0.13
7+
jupytext_version: 1.14.5
8+
kernelspec:
9+
display_name: Python 3 (ipykernel)
10+
language: python
11+
name: python3
12+
---
13+
14+
## Some dynamic models with matrices
15+
16+
In this notebook, we'll present some useful models of economic dynamics using only linear algebra -- matrix multiplication and matrix inversion.
17+
18+
**Present value formulas** are at the core of the models.
19+
20+
+++
21+
22+
## Consumption smoothing
23+
24+
Let
25+
26+
* $T \geq 2$ be a positive integer that constitutes a time-horizon
27+
28+
* $\vec y = \{y_t\}_{t=0}^T$ be an exogenous sequence of non-negative financial incomes $y_t$
29+
30+
* $\vec a = \{a_t\}_{t=0}^{T+1}$ be a sequence of financial wealth
31+
32+
* $\vec c = \{c_t\}_{t=0}^T$ be a sequence of non-negative consumption rates
33+
34+
* $R \geq 1$ be a fixed gross one period rate of return on financial assets
35+
36+
* $\beta \in (0,1)$ be a fixed discount factor
37+
38+
* $a_0$ be a given initial level of financial assets
39+
40+
* $a_{T+1} \geq 0$ be a terminal condition on final assets
41+
42+
A sequence of budget constraints constrains the triple of sequences $\vec y, \vec c, \vec a$
43+
44+
$$
45+
a_{t+1} = R (a_t+ y_t - c_t), \quad t =0, 1, \ldots T
46+
$$
47+
48+
Our model has the following logical flow
49+
50+
* start with an exogenous income sequence $\vec y$, an initial financial wealth $a_0$, and
51+
a candidate consumption path $\vec c$.
52+
53+
* use equation (1) to compute a path $\vec a$ of financial wealth
54+
55+
* verify that $a_{T+1}$ satisfies the terminal wealth constraint $a_{T+1} \geq 0$.
56+
57+
* If it does, declare that the candiate path is budget feasible.
58+
59+
* if the candidate consumption path is not budget feasible, propose a path with less consumption sometimes and start over
60+
61+
Below, we'll describe how to execute these steps using linear algebra -- matrix inversion and multiplication.
62+
63+
64+
We shall eventually evaluate alternative budget feasible consumption paths $\vec c$ using the following **welfare criterion**
65+
66+
$$
67+
W = \sum_{t=0}^T \beta^t (g_1 c_t - \frac{g_2}{2} c_t^2 )
68+
$$
69+
70+
where $g_1 > 0, g_2 > 0$.
71+
72+
We shall see that when $\beta R = 1$ (a condition assumed by Milton Friedman and Robert Hall), this criterion assigns higher welfare to **smoother** consumption paths.
73+
74+
75+
76+
77+
+++
78+
79+
## Difference equations with linear algebra ##
80+
81+
As a warmup, we'll describe a useful way of representing and "solving" linear difference equations.
82+
83+
To generate some $y$ vectors, we'll just write down a linear difference equation
84+
with appropriate initial conditions and then use linear algebra to solve it.
85+
86+
#### First-order difference equation
87+
88+
A first-order linear difference equation cast as a matrix equation
89+
90+
$$
91+
\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \cr
92+
-\lambda & 1 & 0 & \cdots & 0 & 0 \cr
93+
0 & -\lambda & 1 & \cdots & 0 & 0 \cr
94+
\vdots & \vdots & \vdots & \cdots & \vdots & \vdots \cr
95+
0 & 0 & 0 & \cdots & -\lambda & 1
96+
97+
\end{bmatrix} \begin{bmatrix} y_1 \cr y_2 \cr y_3 \cr \vdots \cr y_T \end{bmatrix}
98+
= \begin{bmatrix} \lambda y_0 \cr 0 \cr 0 \cr \vdots \cr 0 \end{bmatrix}
99+
$$
100+
101+
Here $y_0$ is an initial condition.
102+
103+
Multiplying both sides by inverse of the matrix on the left provides the solution
104+
105+
$$
106+
\begin{bmatrix} y_1 \cr y_2 \cr y_3 \cr \vdots \cr y_T \end{bmatrix} =
107+
\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \cr
108+
\lambda & 1 & 0 & \cdots & 0 & 0 \cr
109+
\lambda^2 & \lambda & 1 & \cdots & 0 & 0 \cr
110+
\vdots & \vdots & \vdots & \cdots & \vdots & \vdots \cr
111+
\lambda^{T-1} & \lambda^{T-2} & \lambda^{T-3} & \cdots & -\lambda & 1
112+
\end{bmatrix}
113+
\begin{bmatrix} \lambda y_0 \cr 0 \cr 0 \cr \vdots \cr 0 \end{bmatrix}
114+
115+
$$
116+
117+
118+
#### Second order difference equation
119+
120+
121+
$$
122+
\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 & 0 \cr
123+
-\lambda_1 & 1 & 0 & \cdots & 0 & 0 & 0 \cr
124+
-\lambda_2 & -\lambda_2 & 1 & \cdots & 0 & 0 & 0 \cr
125+
\vdots & \vdots & \vdots & \cdots & \vdots & \vdots \cr
126+
0 & 0 & 0 & \cdots & \lambda_2 & -\lambda_1 & 1
127+
128+
\end{bmatrix} \begin{bmatrix} y_1 \cr y_2 \cr y_3 \cr \vdots \cr y_T \end{bmatrix}
129+
= \begin{bmatrix} \lambda_1 y_0 + \lambda_2 y_{-1} \cr \lambda_2 y_0 \cr 0 \cr \vdots \cr 0 \end{bmatrix}
130+
$$
131+
132+
Multiplying both sides by inverse of the matrix on the left again provides the solution.
133+
134+
#### Extensions
135+
136+
As an exercise, we ask you to represent and solve a **third order linear difference equation**.
137+
How many initial conditions must you specify?
138+
139+
+++
140+
141+
## Friedman-Hall consumption-smoothing model
142+
143+
144+
A key object is what Milton Friedman called "non-human" or "non-financial" wealth at time $0$:
145+
146+
147+
$$
148+
h_0 \equiv \sum_{t=0}^T R^t y_t = \begin{bmatrix} 1 & R & \cdots & R^T \end{bmatrix}
149+
\begin{bmatrix} y_0 \cr y_1 \cr \vdots \cr y_T \end{bmatrix}
150+
$$
151+
152+
By iterating on equation (1) and imposing the terminal condition
153+
154+
$$
155+
a_{T+1} = 0,
156+
$$
157+
158+
it is possible to convert a sequence of budget constraints into the single intertemporal constraint
159+
160+
$$
161+
\sum_{t=0}^T R^t c_t = a_0 + h_0,
162+
$$
163+
164+
which says that the present value of the consumption stream equals the sum of finanical and non-financial wealth.
165+
166+
Robert Hall (1978) showed that when $\beta R = 1$, a condition Milton Friedman had assumed,
167+
it is "optimal" for a consumer to **smooth consumption** by setting
168+
169+
$$
170+
c_t = c_0 \quad t =0, 1, \ldots, T
171+
$$
172+
173+
In this case, we can use the intertemporal budget constraint to write
174+
175+
$$
176+
c_0 = \left(\sum_{t=0}^T R^t\right)^{-1} (a_0 + h_0)
177+
$$
178+
179+
This is the consumption-smoothing model in a nutshell.
180+
181+
We'll put the model through some paces with Python code below.
182+
183+
+++
184+
185+
## Permanent income model of consumption
186+
187+
As promised, we'll provide step by step instructions on how to use linear algebra, readily implemented
188+
in Python, to solve the consumption smoothing model.
189+
190+
**Note to programmer teammate:**
191+
192+
In the calculations below, please we'll set default values of $R > 1$, e.g., $R = 1.05$, and $\beta = R^{-1}$.
193+
194+
#### Step 1 ####
195+
196+
For some $T+1 \times 1$ $y$ vector, use matrix algebra to compute
197+
198+
$$
199+
\sum_{t=0}^T R^t y_t = \begin{bmatrix} 1 & R & \cdots & R^T \end{bmatrix}
200+
\begin{bmatrix} y_0 \cr y_1 \cr \vdots \cr y_T \end{bmatrix}
201+
$$
202+
203+
#### Step 2 ####
204+
205+
Compute
206+
207+
$$
208+
c_0 = \left( \frac{1 - R^{-1}}{1 - R^{-(T+1)}} \right) (a_0 + \sum_{t=0}^T R^t y_t )
209+
$$
210+
211+
212+
#### Step 3 ####
213+
214+
Formulate system
215+
216+
$$
217+
\begin{bmatrix}
218+
1 & 0 & 0 & \cdots & 0 & 0 & 0 \cr
219+
-R & 1 & 0 & \cdots & 0 & 0 & 0 \cr
220+
0 & -R & 1 & \cdots & 0 & 0 & 0 \cr
221+
\vdots &\vdots & \vdots & \cdots & \vdots & \vdots & \vdots \cr
222+
0 & 0 & 0 & \cdots & -R & 1 & 0 \cr
223+
0 & 0 & 0 & \cdots & 0 & -R & 1
224+
\end{bmatrix} \begin{bmatrix} a_1 \cr a_2 \cr a_3 \cr \vdots \cr a_T \cr a_{T+1} \end{bmatrix}
225+
= R \begin{bmatrix} y_0 + a_0 - c_0 \cr y_1 - c_0 \cr y_2 - c_0 \cr \vdots\cr y_T - y_0 \cr 0
226+
\end{bmatrix}
227+
228+
$$
229+
230+
Multiply both sides by the inverse of the matrix on the left side to compute
231+
232+
$$
233+
\begin{bmatrix} a_1 \cr a_2 \cr a_3 \cr \vdots \cr a_T \cr a_{T+1} \end{bmatrix}
234+
$$
235+
236+
It should turn out automatically that
237+
238+
$$
239+
a_{T+1} = 0.
240+
$$
241+
242+
Let's verify this with our Python code.
243+
244+
245+
246+
### Feasible consumption variations ###
247+
248+
To explore what types of consumption paths are welfare-improving, we shall create an **admissible consumption path variation** sequence $\{v_t\}_{t=0}^T$
249+
that satisfies
250+
251+
$$
252+
\sum_{t=0}^T v_t = 0
253+
$$
254+
255+
We'll compute a two-parameter class of admissible variations
256+
of the form
257+
258+
$$
259+
v_t = \xi_1 \phi^t - \xi_0
260+
$$
261+
262+
We say two and not three-parameter class because $\xi_0$ will be a function of $(\phi, \xi_1; R)$ that guarantees that the variation is feasibile.
263+
264+
Let's compute that function.
265+
266+
We require
267+
268+
$$
269+
\sum_{t=0}^T \left[ \xi_1 \phi^t - \phi_0 \right] = 0
270+
$$
271+
272+
which implies that
273+
274+
$$
275+
\xi_1 \sum_{t=0}^T \phi_t R^{-t} - \xi_0 \sum_{t=0}^T R^{-t} = 0
276+
$$
277+
278+
which implies that
279+
280+
$$
281+
\xi_1 \frac{1 - (\phi R^{-1})^{T+1}}{1 - \phi R^{-1}} - \xi_0 \frac{1 - R^{-(T+1)}}{1-R^{-1} } =0
282+
$$
283+
284+
which implies that
285+
286+
$$
287+
\xi_0 = \xi_0(\phi, \xi_1; R) = \xi_1 \left(\frac{1 - R^{-1}}{1 - R^{-(T+1)}}\right) \left(\frac{1 - (\phi R^{-1})^{T+1}}{1 - \phi R^{-1}}\right)
288+
$$
289+
290+
This is our formula for $\xi_0$.
291+
292+
Evidently, if $\vec c^o$ is a budget-feasible consumption path, then so is $\vec c^o + \vec v$,
293+
where $\vec v$ is a budget-feasible variation.
294+
295+
Given $R$, we thus have a two parameter class of budget feasible variations $\vec v$ that we can use
296+
to compute alternative consumption paths, then evaluate their welfare.
297+
298+
**Note to John:** We can do some fun simple experiments with these variations -- we can use
299+
graphs to show that, when $\beta R =1$ and starting from the smooth path, all nontrivial budget-feasible variations lower welfare according to the criterion above.
300+
301+
We can even use the Python numpy grad command to compute derivatives of welfare with respect to our two parameters. Notice that we are teaching the key idea beneath the calculus of variations.
302+
303+
304+
```{code-cell} ipython3
305+
306+
```

0 commit comments

Comments
 (0)