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
Copy file name to clipboardExpand all lines: lectures/calvo_gradient.md
+77-42Lines changed: 77 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,55 +14,68 @@ kernelspec:
14
14
# Machine Learning a Ramsey Plan
15
15
16
16
17
-
In this lecture, we'll study the same Ramsey problem that we also study in this quantecon lecture
17
+
## Introduction
18
+
19
+
This lecture studies a problem that we also study in another quantecon lecture
18
20
{doc}`calvo`.
19
21
20
-
In that lecture, we an analytic approach based on ``dynamic programming squared`` to guide computation of a Ramsey plan.
22
+
That lecture used an analytic approach based on ``dynamic programming squared`` to guide computation of a Ramsey plan in a version of a model of Calvo {cite}`Calvo1978`.
23
+
24
+
Dynamic programming squared guided the calculations in that lecture by providing much useful information about mathematical objects in terms of which the Ramsey plan can be represented recursively.
21
25
22
-
Dynamic programming squared provided us with much useful information about mathematical objects that represent a Ramsey plan recursively and how to compute it efficiently.
26
+
That paved the way to computing the Ramsey plan efficiently.
23
27
24
-
Included in that information are descriptions of
28
+
Included in the structural information that dynamic programming squared provided in quantecon lecture {doc}`calvo` are descriptions of
25
29
26
-
*the**state** variable confronting a continuation Ramsey planner
30
+
*a**state** variable confronting a continuation Ramsey planner, and
27
31
* two Bellman equations
28
32
* one that describes the behavior of the representative agent
29
33
* another that describes the decision problems of a Ramsey planner and of a continuation Ramsey planner
30
34
31
35
32
-
In this lecture, we approach the Ramsey planner in a less sophisticated way that proceeds not knowing any of the structure imparted by dynamic programming squared.
36
+
In this lecture, we approach the Ramsey planner in a much less sophisticated way that proceeds without knowing the structure imparted by dynamic programming squared.
33
37
34
-
Instead, we use a brute force **machine learning**approach that naively states the Ramsey problem
38
+
Instead, we use a brute force approach that naively states the Ramsey problem
35
39
in terms of a pair of infinite sequences of real numbers that the Ramsey planner chooses
36
40
* a sequence $\vec \theta$ of inflation rates
37
41
* a sequence $\vec \mu$ of money growh rates
38
42
43
+
We take the liberty of calling this a **machine learning** approach because of how it fails to take advantage of the structure exploited by dynamic programming squared, at the cost of proliferating parameters.
44
+
45
+
This is what many machine learning algorithms do.
46
+
47
+
Comparing the calculations in this lecture with those in our sister lecture {doc}`calvo` provides us
48
+
with good laboratory to help appreciate the promises and limits of machine learning approaches
49
+
more generally.
50
+
39
51
We'll actually deploy two machine learning approaches, one more naive than the other.
40
52
41
-
* the first is really lazy.
42
-
* it just hands a Python function that computes the Ramsey planner's objective over to a gradient descent algorithm
43
-
* the second is less lazy.
44
-
* it exerts the effort required to express the Ramsey planner's criterion as an affine quadratic form in $\vec \mu$, computes first-order conditions for an optimum, and solves the resulting system of simultaneous linear equations for $\vec \mu$ and then $\vec \theta$.
53
+
* the first is really lazy
54
+
* it just writes a Python function to computes the Ramsey planner's objective as a function of a money growth rate sequence and then hands it over to a gradient descent optimizer
55
+
* the second is less lazy
56
+
* it exerts the effort required to express the Ramsey planner's objective as an affine quadratic form in $\vec \mu$, computes first-order conditions for an optimum, and solves the resulting system of simultaneous linear equations for $\vec \mu$ and then $\vec \theta$.
57
+
58
+
While both of these machine learning (ML) approaches succeed in recovering the Ramsey plan computed in via dynamic programming squared in quantecon lecture {doc}`calvo`, they don't reveal the structure that is exploited in that lecture.
59
+
60
+
That structure lies hidden with the answers provided by our ML approach
45
61
46
-
While these machine learning (ML) approaches succeed in recovering the same Ramsey plan computed in
47
-
this quantecon lecture {doc}`calvo`, they don't reveal the structure that is exploited in that
48
-
lecture's application of dynamic programming squared.
62
+
We can ferret out that structure if only we ask the right questions.
49
63
50
-
But that structure is lurking in the answers provided by our ML approach, if only we ask exactly the right questions.
64
+
At the end of this lecture we show what those questions are and how they can be answered by running particular linear regressions on components of
65
+
$\vec \mu, \vec \theta$.
51
66
52
-
Those questions can be answered by running particular linear regressions on components of
53
-
$\vec \mu, \vec \theta$, as we show at the end of this lecture.
67
+
Application of human intelligence, not the artificial intelligence exhibited in our machine learning approaches, is a key input into figuring out what regressions to run.
54
68
55
69
56
70
## The Model
57
71
58
-
The basic model is linear-quadratic version of a model that Guillermo Calvo {cite}`Calvo1978` used to illustrate the **time inconsistency** of optimal government
59
-
plans.
72
+
We study a linear-quadratic version of a model that Guillermo Calvo {cite}`Calvo1978` used to illustrate the **time inconsistency** of optimal government plans.
60
73
61
74
62
75
The model focuses attention on intertemporal tradeoffs between
63
76
64
-
-welfare benefits that a representative agent's anticipations of future deflation generate by decreasing costs of holding real money balances and thereby increasing a representative agent's *liquidity*, as measured by holdings of real money balances, and
65
-
- costs associated with the distorting taxes that the government levies to acquire the paper money that it destroys in order to generate anticipated deflation
77
+
-utility that a representative agent's anticipations of future deflation generate by decreasing costs of holding real money balances and thereby increasing the agent's *liquidity*, as measured by holdings of real money balances, and
78
+
-social costs associated with the distorting taxes that the government levies to acquire the paper money that it destroys in order to generate anticipated deflation
66
79
67
80
The model features
68
81
@@ -136,7 +149,7 @@ the linear difference equation {eq}`eq_grad_old2` can be solved forward to get:
@@ -652,7 +669,7 @@ First, recall that a Ramsey planner chooses $\vec \mu$ to maximize the governmen
652
669
We now define a distinct problem in which the planner chooses $\vec \mu$ to maximize the government's value function {eq}`eq:Ramseyvalue`subject to equation {eq}`eq:inflation101` and
653
670
the additional restriction that $\mu_t = \bar \mu$ for all $t$.
654
671
655
-
The solution of this problem is a single $\mu$ that this quantecon lecture {doc}`calvo` calls $\mu^{CR}$.
672
+
The solution of this problem is a time-invariant $\mu_t$ that this quantecon lecture {doc}`calvo` calls $\mu^{CR}$.
In the interest of looking for some parameters that might help us learn about the structure of
995
-
the Ramsey plan, we shall some least squares linear regressions of various components of $\vec \theta$ and $\vec \mu$ on others.
1012
+
the Ramsey plan, we shall compute some least squares linear regressions of particular components of $\vec \theta$ and $\vec \mu$ on others.
1013
+
1014
+
These regressions will reveal structure that is hidden within the $\vec \mu^R, \vec \theta^R$ sequences associated with the Ramsey plan.
1015
+
1016
+
It is worth pausing here and noting the roles played by human intelligence and artificial intelligence (ML) here.
1017
+
1018
+
AI (a.k.a. ML) is running the regressions for us.
1019
+
1020
+
But you can regress anything on anything else.
1021
+
1022
+
Human intelligence is telling us which regressions to run.
1023
+
1024
+
And when we have those regressions in hand, considerably more human intelligence is required fully to
1025
+
appreciate what they reveal about the structure of the Ramsey plan.
1026
+
1027
+
```{note}
1028
+
At this point, an advanced reader might want to read Chang {cite}`chang1998credible` and think about why he Chang takes
1029
+
$\theta_t$ as a key state variable.
1030
+
```
1031
+
996
1032
997
1033
```{code-cell} ipython3
998
1034
# Compute θ using optimized_μ
@@ -1124,6 +1160,5 @@ where $b_0, b_1, g_0, g_1, g_2$ were positive parameters that the lecture comput
1124
1160
1125
1161
By running regressions on the outcomes $\vec \mu^R, \vec \theta^R$ that we have computed with the brute force gradient descent method in this lecture, we have recovered the same representation.
1126
1162
1127
-
However, in this lecture we have more or less discovered the representation by brute force -- i.e.,
1128
-
just by running some regressions and staring at the result, noticing that the $R^2$ of unity tell us
1129
-
that the fits are perfect.
1163
+
However, in this lecture we have discovered the representation partly by brute force -- i.e.,
1164
+
just by running some well chosen regressions and staring at the results, noticing that the $R^2$ of unity tell us that the fits are perfect.
0 commit comments