diff --git a/lectures/cagan_adaptive.md b/lectures/cagan_adaptive.md index e4825f16..05e68c78 100644 --- a/lectures/cagan_adaptive.md +++ b/lectures/cagan_adaptive.md @@ -43,7 +43,7 @@ Instead of the "perfect foresight" or "rational expectations" version of the mod It combines these components: - * a demand function for real money balances that says asserts that the logarithm of the quantity of real balances demanded depends inversely on the public's expected rate of inflation + * a demand function for real money balances that asserts that the logarithm of the quantity of real balances demanded depends inversely on the public's expected rate of inflation * an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation @@ -53,12 +53,12 @@ It combines these components: Our model stays quite close to Cagan's original specification. -As in the {doc}`present values ` and {doc}`consumption smoothing` lectures, the only linear algebra operations that we'll be using are matrix multplication and matrix inversion. +As in the {doc}`present values ` and {doc}`consumption smoothing` lectures, the only linear algebra operations that we'll be using are matrix multiplication and matrix inversion. To facilitate using linear matrix algebra as our principal mathematical tool, we'll use a finite horizon version of the model. -## Structure of the Model +## Structure of the model Let @@ -75,13 +75,13 @@ The demand for real balances $\exp\left(\frac{m_t^d}{p_t}\right)$ is governed by $$ m_t^d - p_t = -\alpha \pi_t^* \: , \: \alpha > 0 ; \quad t = 0, 1, \ldots, T . -$$ (eq:caganmd) +$$ (eq:caganmd_ad) This equation asserts that the demand for real balances is inversely related to the public's expected rate of inflation. -Equating the logarithm $m_t^d$ of the demand for money to the logarithm $m_t$ of the supply of money in equation {eq}`eq:caganmd` and solving for the logarithm $p_t$ +Equating the logarithm $m_t^d$ of the demand for money to the logarithm $m_t$ of the supply of money in equation {eq}`eq:caganmd_ad` and solving for the logarithm $p_t$ of the price level gives $$ @@ -105,9 +105,9 @@ $$ $$ (eq:adaptexpn) As exogenous inputs into the model, we take initial conditions $m_0, \pi_0^*$ -and a money growth sequence $\vec \mu = \{\mu_t\}_{t=0}^T$. +and a money growth sequence $\mu = \{\mu_t\}_{t=0}^T$. -As endogenous outputs of our model we want to find sequences $\vec \pi = \{\pi_t\}_{t=0}^T, \vec p = \{p_t\}_{t=0}^T$ as functions of the endogenous inputs. +As endogenous outputs of our model we want to find sequences $\pi = \{\pi_t\}_{t=0}^T, p = \{p_t\}_{t=0}^T$ as functions of the endogenous inputs. We'll do some mental experiments by studying how the model outputs vary as we vary the model inputs. @@ -148,10 +148,10 @@ $$ Write this equation as $$ -A \vec \pi^* = (1-\lambda) B \vec \pi + \vec \pi_0^* +A \pi^* = (1-\lambda) B \pi + \pi_0^* $$ (eq:eq1) -where the $(T+2) \times (T+2) $matrix $A$, the $(T+2)\times (T+1)$ matrix $B$, and the vectors $\vec \pi^* , \vec \pi_0, \pi_0^*$ +where the $(T+2) \times (T+2) $matrix $A$, the $(T+2)\times (T+1)$ matrix $B$, and the vectors $\pi^* , \pi_0, \pi_0^*$ are defined implicitly by aligning these two equations. @@ -179,7 +179,7 @@ $$ Represent the previous equation system in terms of vectors and matrices as $$ -\vec \pi = \vec \mu + C \vec \pi^* +\pi = \mu + C \pi^* $$ (eq:eq2) where the $(T+1) \times (T+2)$ matrix $C$ is defined implicitly to align this equation with the preceding @@ -187,50 +187,50 @@ equation system. -## Harvesting Returns from our Matrix Formulation +## Harvesting returns from our matrix formulation -We now have all of the ingredients we need to solve for $\vec \pi$ as -a function of $\vec \mu, \pi_0, \pi_0^*$. +We now have all of the ingredients we need to solve for $\pi$ as +a function of $\mu, \pi_0, \pi_0^*$. Combine equations {eq}`eq:eq1`and {eq}`eq:eq2` to get $$ \begin{align*} -A \vec \pi^* & = (1-\lambda) B \vec \pi + \vec \pi_0^* \cr - & = (1-\lambda) B \left[ \vec \mu + C \vec \pi^* \right] + \vec \pi_0^* +A \pi^* & = (1-\lambda) B \pi + \pi_0^* \cr + & = (1-\lambda) B \left[ \mu + C \pi^* \right] + \pi_0^* \end{align*} $$ which implies that $$ -\left[ A - (1-\lambda) B C \right] \vec \pi^* = (1-\lambda) B \vec \mu+ \vec \pi_0^* +\left[ A - (1-\lambda) B C \right] \pi^* = (1-\lambda) B \mu+ \pi_0^* $$ Multiplying both sides of the above equation by the inverse of the matrix on the left side gives $$ -\vec \pi^* = \left[ A - (1-\lambda) B C \right]^{-1} \left[ (1-\lambda) B \vec \mu+ \vec \pi_0^* \right] +\pi^* = \left[ A - (1-\lambda) B C \right]^{-1} \left[ (1-\lambda) B \mu+ \pi_0^* \right] $$ (eq:eq4) -Having solved equation {eq}`eq:eq4` for $\vec \pi^*$, we can use equation {eq}`eq:eq2` to solve for $\vec \pi$: +Having solved equation {eq}`eq:eq4` for $\pi^*$, we can use equation {eq}`eq:eq2` to solve for $\pi$: $$ -\vec \pi = \vec \mu + C \vec \pi^* +\pi = \mu + C \pi^* $$ -We have thus solved for two of the key endogenous time series determined by our model, namely, the sequence $\vec \pi^*$ -of expected inflation rates and the sequence $\vec \pi$ of actual inflation rates. +We have thus solved for two of the key endogenous time series determined by our model, namely, the sequence $\pi^*$ +of expected inflation rates and the sequence $\pi$ of actual inflation rates. -Knowing these, we can then quickly calculate the associated sequence $\vec p$ of the logarithm of the price level +Knowing these, we can then quickly calculate the associated sequence $p$ of the logarithm of the price level from equation {eq}`eq:eqfiscth1`. Let's fill in the details for this step. -Since we now know $\vec \mu$ it is easy to compute $\vec m$. +Since we now know $\mu$ it is easy to compute $m$. Thus, notice that we can represent the equations @@ -258,23 +258,23 @@ m_1 \cr m_2 \cr m_3 \cr \vdots \cr m_T \cr m_{T+1} + \begin{bmatrix} m_0 \cr 0 \cr 0 \cr \vdots \cr 0 \cr 0 \end{bmatrix} -$$ (eq:eq101) +$$ (eq:eq101_ad) -Multiplying both sides of equation {eq}`eq:eq101` with the inverse of the matrix on the left will give +Multiplying both sides of equation {eq}`eq:eq101_ad` with the inverse of the matrix on the left will give $$ m_t = m_0 + \sum_{s=0}^{t-1} \mu_s, \quad t =1, \ldots, T+1 -$$ (eq:mcum) +$$ (eq:mcum_ad) -Equation {eq}`eq:mcum` shows that the log of the money supply at $t$ equals the log $m_0$ of the initial money supply +Equation {eq}`eq:mcum_ad` shows that the log of the money supply at $t$ equals the log $m_0$ of the initial money supply plus accumulation of rates of money growth between times $0$ and $t$. We can then compute $p_t$ for each $t$ from equation {eq}`eq:eqfiscth1`. -We can write a compact formula for $\vec p $ as +We can write a compact formula for $p $ as $$ -\vec p = \vec m + \alpha \hat \pi^* +p = m + \alpha \hat \pi^* $$ where @@ -288,16 +288,16 @@ $$ \end{bmatrix}, $$ -which is just $\vec \pi^*$ with the last element dropped. +which is just $\pi^*$ with the last element dropped. -## Forecast Errors +## Forecast errors Our computations will verify that $$ -\hat \pi^* \neq \vec \pi, +\hat \pi^* \neq \pi, $$ so that in general @@ -380,25 +380,21 @@ def solve_and_plot(model, μ_seq): T_seq = range(model.T+2) - fig, ax = plt.subplots(2, 3, figsize=[10,5], dpi=200) - ax[0,0].plot(T_seq[:-1], μ_seq) - ax[0,1].plot(T_seq[:-1], π_seq, label=r'$\pi_t$') - ax[0,1].plot(T_seq, Eπ_seq, label=r'$\pi^{*}_{t}$') - ax[0,2].plot(T_seq, m_seq - p_seq) - ax[1,0].plot(T_seq, m_seq) - ax[1,1].plot(T_seq, p_seq) + fig, ax = plt.subplots(5, 1, figsize=[5, 12], dpi=200) + ax[0].plot(T_seq[:-1], μ_seq) + ax[1].plot(T_seq[:-1], π_seq, label=r'$\pi_t$') + ax[1].plot(T_seq, Eπ_seq, label=r'$\pi^{*}_{t}$') + ax[2].plot(T_seq, m_seq - p_seq) + ax[3].plot(T_seq, m_seq) + ax[4].plot(T_seq, p_seq) - x_lab = r'$t$' y_labs = [r'$\mu$', r'$\pi$', r'$m - p$', r'$m$', r'$p$'] - k = 0 - for i,j in zip([0, 0, 0, 1, 1], [0, 1, 2, 0, 1]): - ax[i,j].set_xlabel(x_lab) - ax[i,j].set_ylabel(y_labs[k]) - k = k + 1 + for i in range(5): + ax[i].set_xlabel(r'$t$') + ax[i].set_ylabel(y_labs[i]) - ax[0,1].legend() - ax[1,2].set_axis_off() + ax[1].legend() plt.tight_layout() plt.show() @@ -425,7 +421,7 @@ $$ \end{align*} $$ -By assuring that the coefficient on $\pi_t$ is less than one in absolulte value, condition {eq}`eq:suffcond` assures stability of the dynamics of $\{\pi_t\}$ described by the last line of our string of deductions. +By assuring that the coefficient on $\pi_t$ is less than one in absolute value, condition {eq}`eq:suffcond` assures stability of the dynamics of $\{\pi_t\}$ described by the last line of our string of deductions. The reader is free to study outcomes in examples that violate condition {eq}`eq:suffcond`. diff --git a/lectures/cagan_ree.md b/lectures/cagan_ree.md index e00bd948..94c35a60 100644 --- a/lectures/cagan_ree.md +++ b/lectures/cagan_ree.md @@ -50,10 +50,10 @@ In those experiments, we'll encounter an instance of a ''velocity dividend'' tha To facilitate using linear matrix algebra as our main mathematical tool, we'll use a finite horizon version of the model. -As in the {doc}`present values ` and {doc}`consumption smoothing` lectures, the only linear algebra that we'll be using are matrix multplication and matrix inversion. +As in the {doc}`present values ` and {doc}`consumption smoothing` lectures, the only linear algebra that we'll be using are matrix multiplication and matrix inversion. -## Structure of the Model +## Structure of the model The model consists of @@ -148,7 +148,7 @@ $$ (eq:pieq) By multiplying both sides of equation {eq}`eq:pieq` by the inverse of the matrix on the left side, we can calculate $$ -\vec \pi \equiv \begin{bmatrix} \pi_0 \cr \pi_1 \cr \pi_2 \cr \vdots \cr \pi_{T-1} \cr \pi_T +\pi \equiv \begin{bmatrix} \pi_0 \cr \pi_1 \cr \pi_2 \cr \vdots \cr \pi_{T-1} \cr \pi_T \end{bmatrix} $$ @@ -192,8 +192,8 @@ $$ m_t = m_0 + \sum_{s=0}^{t-1} \mu_s, \quad t =1, \ldots, T+1 $$ (eq:mcum) -Equation {eq}`eq:mcum` shows that the log of the money supply at $t$ equals the log $m_0$ of the initial money supply -plus accumulation of rates of money growth between times $0$ and $t$. +Equation {eq}`eq:mcum` shows that the log of the money supply at $t$ equals the log of the initial money supply $m_0$ +plus accumulation of rates of money growth between times $0$ and $T$. ## Continuation values @@ -250,7 +250,7 @@ m0 = 1 +++ {"user_expressions": []} -Now we can solve the model to compute $\pi_t$, $m_t$ and $p_t$ for $t =1, \ldots, T+1$ +Now we can solve the model to compute $\pi_t$, $m_t$ and $p_t$ for $t =1, \ldots, T+1$ using the matrix equation above ```{code-cell} ipython3 def solve(model): @@ -371,13 +371,13 @@ reduction in $\mu$ has been foreseen. #### Experiment 2: an unforeseen sudden stabilization -This experiment deviates a little bit from a pure version our "perfect foresight" +This experiment deviates a little bit from a pure version of our "perfect foresight" assumption by assuming that a sudden permanent reduction in $\mu_t$ like that analyzed in experiment 1 is completely unanticipated. Such a completely unanticipated shock is popularly known as an "MIT shock". -The mental experiment involves switching at at time $T_1$ from an initial "continuation path" for $\{\mu_t, \pi_t\} $ to another path that involves a permanently lower inflation frate. +The mental experiment involves switching at time $T_1$ from an initial "continuation path" for $\{\mu_t, \pi_t\} $ to another path that involves a permanently lower inflation rate. **Initial Path:** $\mu_t = \mu_0$ for all $t \geq 0$. So this path is for $\{\mu_t\}_{t=0}^\infty$; the associated path for $\pi_t$ has $\pi_t = \mu_0$. @@ -593,7 +593,7 @@ By letting money jump according to equation {eq}`eq:eqnmoneyjump` the monetary a from **falling** at the moment that the unanticipated stabilization arrives. In various research papers about stabilizations of high inflations, the jump in the money supply described by equation {eq}`eq:eqnmoneyjump` has been called -"the velocity dividend" that a government reaps from implementin a regime change that sustains a permanently lower inflation rate. +"the velocity dividend" that a government reaps from implementing a regime change that sustains a permanently lower inflation rate. #### Technical Details about whether $p$ or $m$ jumps at $T_1$ diff --git a/lectures/cons_smooth.md b/lectures/cons_smooth.md index 336f9161..af97ff74 100644 --- a/lectures/cons_smooth.md +++ b/lectures/cons_smooth.md @@ -51,18 +51,18 @@ A sequence of budget constraints constrains the triple of sequences $y, c, a$ $$ a_{t+1} = R (a_t+ y_t - c_t), \quad t =0, 1, \ldots T -$$ +$$ (eq:a_t) Our model has the following logical flow * start with an exogenous income sequence $y$, an initial financial wealth $a_0$, and a candidate consumption path $c$. - * use equation (1) to compute a path $a$ of financial wealth + * use equation {eq}`eq:a_t` to compute a path $a$ of financial wealth * verify that $a_{T+1}$ satisfies the terminal wealth constraint $a_{T+1} \geq 0$. - * If it does, declare that the candiate path is budget feasible. + * If it does, declare that the candidate path is budget feasible. * if the candidate consumption path is not budget feasible, propose a path with less consumption sometimes and start over @@ -160,7 +160,7 @@ y_1 \cr y_2 \cr y_3 \cr \vdots \cr y_T ```{exercise} :label: consmooth_ex1 -In the {eq}`fst_ord_inverse`, we multiply the inverse of the matrix on the left ($A$). In this exercise, please confirm that +In the {eq}`fst_ord_inverse`, we multiply the inverse of the matrix $A$. In this exercise, please confirm that $$ \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 \begin{bmatrix} y_0 \cr y_1 \cr \vdots \cr y_T \end{bmatrix} $$ -By iterating on equation (1) and imposing the terminal condition +By iterating on equation {eq}`eq:a_t` and imposing the terminal condition $$ a_{T+1} = 0, @@ -251,30 +251,6 @@ $$ This is the consumption-smoothing model in a nutshell. -We implement this model in `compute_optimal` - -```{code-cell} ipython3 -def compute_optimal(model, a0, y_seq): - R, T = model.R, model.T - - # non-financial wealth - h0 = model.β_seq @ y_seq # since β = 1/R - - # c0 - c0 = (1 - 1/R) / (1 - (1/R)**(T+1)) * (a0 + h0) - c_seq = c0*np.ones(T+1) - - # verify - A = np.diag(-R*np.ones(T), k=-1) + np.eye(T+1) - b = y_seq - c_seq - b[0] = b[0] + a0 - - a_seq = np.linalg.inv(A) @ b - a_seq = np.concatenate([[a0], a_seq]) - - return c_seq, a_seq -``` - +++ {"user_expressions": []} ## Permanent income model of consumption @@ -286,7 +262,7 @@ In the calculations below, please we'll set default values of $R > 1$, e.g., $ ### Step 1 -For some $(T+1) \times 1$ $y$ vector, use matrix algebra to compute +For some $(T+1) \times 1$ $y$ vector, use matrix algebra to compute $h_0$ $$ \sum_{t=0}^T R^{-t} y_t = \begin{bmatrix} 1 & R^{-1} & \cdots & R^{-T} \end{bmatrix} @@ -335,6 +311,30 @@ $$ Let's verify this with our Python code. +First we implement this model in `compute_optimal` + +```{code-cell} ipython3 +def compute_optimal(model, a0, y_seq): + R, T = model.R, model.T + + # non-financial wealth + h0 = model.β_seq @ y_seq # since β = 1/R + + # c0 + c0 = (1 - 1/R) / (1 - (1/R)**(T+1)) * (a0 + h0) + c_seq = c0*np.ones(T+1) + + # verify + A = np.diag(-R*np.ones(T), k=-1) + np.eye(T+1) + b = y_seq - c_seq + b[0] = b[0] + a0 + + a_seq = np.linalg.inv(A) @ b + a_seq = np.concatenate([[a0], a_seq]) + + return c_seq, a_seq +``` + We use an example where the consumer inherits $a_0<0$ (which can be interpreted as a student debt). The 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:', np.abs(a_seq[-1] - 0) <= 1e-8) ``` +The visualization shows the path of income, consumption, and financial assets. + ```{code-cell} ipython3 # Sequence Length T = cs_model.T @@ -368,9 +370,9 @@ plt.ylabel(r'$c_t,y_t,a_t$') plt.show() ``` -+++ {"user_expressions": []} +Note that $a_{T+1} = 0$ is satisfied. -We can evaluate the welfare using the formula {eq}`welfare` +We can further evaluate the welfare using the formula {eq}`welfare` ```{code-cell} ipython3 def welfare(model, c_seq): @@ -384,7 +386,7 @@ print('Welfare:', welfare(cs_model, c_seq)) +++ {"user_expressions": []} -### Feasible consumption variations ### +### Feasible consumption variations To explore what types of consumption paths are welfare-improving, we shall create an **admissible consumption path variation sequence** $\{v_t\}_{t=0}^T$ that satisfies @@ -400,7 +402,7 @@ $$ v_t = \xi_1 \phi^t - \xi_0 $$ -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. +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 feasible. Let's compute that function. diff --git a/lectures/equalizing_difference.md b/lectures/equalizing_difference.md index 1985ceec..f08e4f79 100644 --- a/lectures/equalizing_difference.md +++ b/lectures/equalizing_difference.md @@ -19,7 +19,7 @@ This notebook presents a model of the college-high-school wage gap in which the The model is "incomplete" in the sense that it is just one "condition" in the form of one equation that would be part of set equations comprising all of the "equilibrium conditions" of a more fully articulated model. -The condition featured in our model determies a college, high-school wage ratio that equalizes the +The condition featured in our model determines a college, high-school wage ratio that equalizes the present values of a high school worker and a college educated worker. It is just one instance of an "equalizing difference" theory of relative wage rates, a class dating back at least to Adam Smith's **Wealth of Nations**. @@ -33,7 +33,7 @@ Let * $R > 0$ be the gross rate of return on a one-period bond - * $0$ denote the first period after high school that a person can go to work + * $0$ denotes the first period after high school that a person can go to work * $T$ denote the last period a person can work @@ -49,7 +49,8 @@ Let -If someone goes to work immediately after high school and work for $T+1$ years, she earns present value +If someone goes to work immediately after high school and works for $T+1$ years, she earns present value + $$ h_0 = \sum_{t=0}^T R^{-t} w_t^h = w_0^h \left[ \frac{1 - (R^{-1} \gamma_h)^{T+1} }{1 - R^{-1} \gamma_h } \right] \equiv w_0^h A_h $$ @@ -113,7 +114,7 @@ $$ ## Tweaked Model: Workers and Entrepreneurs -We can add a parameter and reinterpret variables to get a model of entrepreuneurs versus workers. +We can add a parameter and reinterpret variables to get a model of entrepreneurs versus workers. We now let $h$ be the present value of a "worker". @@ -128,7 +129,7 @@ where $\pi \in (0,1) $ is the probability that an entrepreneur's "project" succ We set $D =0$. What we used to call the college, high school wage gap $\phi$ now becomes the ratio -of a successful entreneur's earnings to a worker's earnings. +of a successful entrepreneur's earnings to a worker's earnings. We'll find that as $\pi$ decreases, $\phi$ increases. diff --git a/lectures/pv.md b/lectures/pv.md index c632be02..c3f3a76d 100644 --- a/lectures/pv.md +++ b/lectures/pv.md @@ -44,7 +44,7 @@ $$ (eq:Euler1) This is a "cost equals benefits" formula. It says that the cost of buying the asset today equals the reward for holding it -for one period (which is the dividend $d_t$)and then selling it, at $t+1$. +for one period (which is the dividend $d_t$) and then selling it, at $t+1$. The future value $p_{t+1}$ is discounted using $\delta$ to shift it to a present value, so it is comparable with $d_t$ and $p_t$. @@ -152,6 +152,10 @@ $$ (eq:apdb_sol) Here is a small example, where the dividend stream is given by +$$ + d_{t+1} = 1.05 d_t, \quad t = 0, 1, \ldots , T-1. +$$ + ```{code-cell} ipython3 T = 6 @@ -210,6 +214,10 @@ plt.show() We can also consider a cyclically growing dividend sequence, such as +$$ + d_{t+1} = 1.01 d_t + 0.1 \sin t, \quad t = 0, 1, \ldots , T-1. +$$ + ```{code-cell} ipython3 T = 100 @@ -365,7 +373,7 @@ $$ \end{bmatrix} $$ (eq:pieq2) -Evidently, if $p_{T+1}^* = 0$, a price vector $\vec p$ of with all entries zero +Evidently, if $p_{T+1}^* = 0$, a price vector $p$ of all entries zero solves this equation and the only the **fundamental** component of our pricing formula {eq}`eq:ptpveq` is present. @@ -395,7 +403,7 @@ R_t = \frac{p_{t+1}}{p_t} $$ (eq:rateofreturn) Equation {eq}`eq:bubble` confirms that an asset whose sole source of value is a bubble -earns a gross rate of return of +that earns a gross rate of return $$ R_t = \delta^{-1} > 1 . diff --git a/sandpit/cagan_adaptive.md b/sandpit/cagan_adaptive.md deleted file mode 100644 index 62fbf1ed..00000000 --- a/sandpit/cagan_adaptive.md +++ /dev/null @@ -1,395 +0,0 @@ -## Adaptive expectations version of Cagan model - -```python -import numpy as np -import matplotlib.pyplot as plt -``` - - -We'll use linear algebra to do some experiments with a "fiscal theory of the price level". - -According to this model, when the government persistently spends more than it collects in taxes and prints money to finance the shortfall (called the "government deficit"), it puts upward pressure on the price level and generates -persistent inflation. - -Our model is an "adaptive expectations" version of a model that Philip Cagan used to study the monetary dynamics of hyperinflations. - -It combines these components: - - * a demand function for real money balances that says asserts that the logarithm of the quantity of real balances demanded depends inversely on the public's expected rate of inflation - - * an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation - - * an equilibrium condition that equates the demand for money to the supply - - * an exogenous sequence of rates of growth of the money supply - -Our model stays quite close to Cagan's original specification. - -To facilitate using linear matrix algebra as our principal mathematical tool, we'll use a finite horizon version of -the model. - -Let - - * $ m_t $ be the log of the supply of nominal money balances; - * $\mu_t = m_{t+1} - m_t $ be the net rate of growth of nominal balances; - * $p_t $ be the log of the price level; - * $\pi_t = p_{t+1} - p_t $ be the net rate of inflation between $t$ and $ t+1$; - * $\pi_t^*$ be the public's expected rate of inflation between $t$ and $t+1$; - * $T$ the horizon -- i.e., the last period for which the model will determine $p_t$ - * $\pi_0^*$ public's initial expected rate of inflation between time $0$ and time $1$. - - -The demand for real balances $\exp\left(\frac{m_t^d}{p_t}\right)$ is governed by the following version of the Cagan demand function - -$$ -m_t^d - p_t = -\alpha \pi_t^* \: , \: \alpha > 0 ; \quad t = 0, 1, \ldots, T . -$$ (eq:caganmd) - - -This equation asserts that the demand for real balances -is inversely related to the public's expected rate of inflation. - -Equating the logarithm $m_t^d$ of the demand for money to the logarithm $m_t$ of the supply of money in equation {eq}`eq:caganmd` and solving for the logarithm $p_t$ -of the price level gives - -$$ -p_t = m_t + \alpha \pi_t^* -$$ (eq:eqfiscth1) - -Taking the difference between equation {eq}`eq:eqfiscth1` at time $t+1$ and at time -$t$ gives - - - -$$ -\pi_t = \mu_t + \alpha \pi_{t+1}^* - \alpha \pi_t^* -$$ (eq:eqpipi) - -We assume that the expected rate of inflation $\pi_t^*$ is governed -by the Friedman-Cagan adaptive expectations scheme - -$$ -\pi_{t+1}^* = \lambda \pi_t^* + (1 -\lambda) \pi_t -$$ (eq:adaptexpn) - -As exogenous inputs into the model, we take initial conditions $m_0, \pi_0^*$ -and a money growth sequence $\vec \mu = \{\mu_t\}_{t=0}^T$. - -As endogenous outputs of our model we want to find sequences $\vec \pi = \{\pi_t\}_{t=0}^T, \vec p = \{p_t\}_{t=0}^T$ as functions of the endogenous inputs. - -We'll do some mental experiments by studying how the model outputs vary as we vary -the model inputs. - - - - -### Representing key equations with linear algebra - -We begin by writing the equation {eq}`eq:adaptexpn` adaptive expectations model for $\pi_t^*$ for $t=0, \ldots, T$ as - - - -$$ -\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \cr --\lambda & 1 & 0 & \cdots & 0 & 0 \cr -0 & - \lambda & 1 & \cdots & 0 & 0 \cr -\vdots & \vdots & \vdots & \cdots & \vdots & \vdots \cr -0 & 0 & 0 & \cdots & -\lambda & 1 -\end{bmatrix} -\begin{bmatrix} \pi_0^* \cr - \pi_1^* \cr - \pi_2^* \cr - \vdots \cr - \pi_{T+1}^* - \end{bmatrix} = - (1-\lambda) \begin{bmatrix} - 0 & 0 & 0 & \cdots & 0 \cr - 1 & 0 & 0 & \cdots & 0 \cr - 0 & 1 & 0 & \cdots & 0 \cr - \vdots &\vdots & \vdots & \cdots & \vdots \cr - 0 & 0 & 0 & \cdots & 1 \end{bmatrix} - \begin{bmatrix}\pi_0 \cr \pi_1 \cr \pi_2 \cr \vdots \cr \pi_T - \end{bmatrix} + - \begin{bmatrix} \pi_0^* \cr 0 \cr 0 \cr \vdots \cr 0 \end{bmatrix} -$$ - -Write this equation as - -$$ -A \vec \pi^* = (1-\lambda) B \vec \pi + \vec \pi_0^* -$$ (eq:eq1) - -where the $(T+2) \times (T+2) $matrix $A$, the $(T+2)\times (T+1)$ matrix $B$, and the vectors $\vec \pi^* , \vec \pi_0, \pi_0^*$ -are defined implicitly by aligning these two equations. - - - -Next we write the key equation {eq}`eq:eqpipi` in matrix notation as - -$$ \begin{bmatrix} -\pi_0 \cr \pi_1 \cr \pi_1 \cr \vdots \cr \pi_T \end{bmatrix} -= \begin{bmatrix} -\mu_0 \cr \mu_1 \cr \mu_2 \cr \vdots \cr \mu_T \end{bmatrix} -+ \begin{bmatrix} - \alpha & \alpha & 0 & \cdots & 0 & 0 \cr -0 & -\alpha & \alpha & \cdots & 0 & 0 \cr -0 & 0 & -\alpha & \cdots & 0 & 0 \cr -\vdots & \vdots & \vdots & \cdots & \alpha & 0 \cr -0 & 0 & 0 & \cdots & -\alpha & \alpha -\end{bmatrix} -\begin{bmatrix} \pi_0^* \cr - \pi_1^* \cr - \pi_2^* \cr - \vdots \cr - \pi_{T+1}^* - \end{bmatrix} -$$ - -Represent the previous equation system in terms of vectors and matrices as - -$$ -\vec \pi = \vec \mu + C \vec \pi^* -$$ (eq:eq2) - -where the $(T+1) \times (T+2)$ matrix $C$ is defined implicitly to align this equation with the preceding -equation system. - - - -### Harvesting payoffs from our matrix formulation - - -We now have all of the ingredients we need to solve for $\vec \pi$ as -a function of $\vec \mu, \pi_0, \pi_0^*$. - -Combine equations {eq}`eq:eq1`and {eq}`eq:eq2` to get - -$$ -\begin{align*} -A \vec \pi^* & = (1-\lambda) B \vec \pi + \vec \pi_0^* \cr - & = (1-\lambda) B \left[ \vec \mu + C \vec \pi^* \right] + \vec \pi_0^* -\end{align*} -$$ - -which implies that - -$$ -\left[ A - (1-\lambda) B C \right] \vec \pi^* = (1-\lambda) B \vec \mu+ \vec \pi_0^* -$$ - -Multiplying both sides of the above equation by the inverse of the matrix on the left side gives - -$$ -\vec \pi^* = \left[ A - (1-\lambda) B C \right]^{-1} \left[ (1-\lambda) B \vec \mu+ \vec \pi_0^* \right] -$$ (eq:eq4) - -Having solved equation {eq}`eq:eq4` for $\vec \pi^*$, we can use equation {eq}`eq:eq2` to solve for $\vec \pi$: - -$$ -\vec \pi = \vec \mu + C \vec \pi^* -$$ - - -We have thus solved for two of the key endogenous time series determined by our model, namely, the sequence $\vec \pi^*$ -of expected inflation rates and the sequence $\vec \pi$ of actual inflation rates. - -Knowing these, we can then quickly calculate the associated sequence $\vec p$ of the logarithm of the price level -from equation {eq}`eq:eqfiscth1`. - -Let's fill in the details for this step. - - -Since we now know $\vec \mu$ it is easy to compute $\vec m$. - -Thus, notice that we can represent the equations - -$$ -m_{t+1} = m_t + \mu_t , \quad t = 0, 1, \ldots, T -$$ - -as the matrix equation - -$$ -\begin{bmatrix} -1 & 0 & 0 & \cdots & 0 & 0 \cr --1 & 1 & 0 & \cdots & 0 & 0 \cr -0 & -1 & 1 & \cdots & 0 & 0 \cr -\vdots & \vdots & \vdots & \vdots & 0 & 0 \cr -0 & 0 & 0 & \cdots & 1 & 0 \cr -0 & 0 & 0 & \cdots & -1 & 1 -\end{bmatrix} -\begin{bmatrix} -m_1 \cr m_2 \cr m_3 \cr \vdots \cr m_T \cr m_{T+1} -\end{bmatrix} -= \begin{bmatrix} -\mu_0 \cr \mu_1 \cr \mu_2 \cr \vdots \cr \mu_{T-1} \cr \mu_T -\end{bmatrix} -+ \begin{bmatrix} -m_0 \cr 0 \cr 0 \cr \vdots \cr 0 \cr 0 -\end{bmatrix} -$$ (eq:eq101) - -Multiplying both sides of equation {eq}`eq:eq101` with the inverse of the matrix on the left will give - -$$ -m_t = m_0 + \sum_{s=0}^{t-1} \mu_s, \quad t =1, \ldots, T+1 -$$ (eq:mcum) - -Equation {eq}`eq:mcum` shows that the log of the money supply at $t$ equals the log $m_0$ of the initial money supply -plus accumulation of rates of money growth between times $0$ and $t$. - -We can then compute $p_t$ for each $t$ from equation {eq}`eq:eqfiscth1`. - -We can write a compact formula for $\vec p $ as - -$$ -\vec p = \vec m + \alpha \hat \pi^* -$$ - -where - -$$ -\hat \pi^* = \begin{bmatrix} \pi_0^* \cr - \pi_1^* \cr - \pi_2^* \cr - \vdots \cr - \pi_{T}^* - \end{bmatrix}, - $$ - -which is just $\vec \pi^*$ with the last element dropped. - - - -### Expectational Error Gap - -Our computations will verify that - -$$ -\hat \pi^* \neq \vec \pi, -$$ - -so that in general - -$$ -\pi_t^* \neq \pi_t, \quad t = 0, 1, \ldots , T -$$ (eq:notre) - -This outcome is typical in models in which adaptive expectations hypothesis like equation {eq}`eq:adaptexpn` appear as a -component. - -In a companion lecture, we'll discuss a version of the model that replaces hypothesis {eq}`eq:adaptexpn` with -a "perfect foresight" or "rational expectations" hypothesis. - -```python -class Cagan_Adaptive: - " Solve the Cagan model in finite time. " - - def __init__(self, α, m0, Eπ0, μ_seq, T, λ): - self.α, self.m0, self.Eπ0, self.μ_seq, self.T, self.λ = α, m0, Eπ0, μ_seq, T, λ - - def solve(self): - α, m0, Eπ0, μ_seq, T, λ = self.α, self.m0, self.Eπ0, self.μ_seq, self.T, self.λ - - A = np.eye(T+2, T+2) - λ*np.eye(T+2, T+2, k=-1) - B = np.eye(T+2, T+1, k=-1) - C = -α*np.eye(T+1, T+2) + α*np.eye(T+1, T+2, k=1) - Eπ0_seq = np.append(Eπ0, np.zeros(T+1)) - - # Eπ_seq is of length T+2 - Eπ_seq = np.linalg.inv(A - (1-λ)*B @ C) @ ((1-λ) * B @ μ_seq + Eπ0_seq) - - # π_seq is of length T+1 - π_seq = μ_seq + C @ Eπ_seq - - D = np.eye(T+1, T+1) - np.eye(T+1, T+1, k=-1) - m0_seq = np.append(m0, np.zeros(T)) - - # m_seq is of length T+2 - m_seq = np.linalg.inv(D) @ (μ_seq + m0_seq) - m_seq = np.append(m0, m_seq) - - # p_seq is of length T+2 - p_seq = m_seq + α * Eπ_seq - - return π_seq, Eπ_seq, m_seq, p_seq - - -def solve_and_plot(α, m0, Eπ0, μ_seq, T, λ): - - mc = Cagan_Adaptive(α=α, m0=m0, Eπ0=Eπ0, μ_seq=μ_seq, T=T, λ=λ) - π_seq, Eπ_seq, m_seq, p_seq = mc.solve() - T_seq = range(T+2) - - fig, ax = plt.subplots(2, 3, figsize=[10,5], dpi=200) - ax[0,0].plot(T_seq[:-1], μ_seq) - ax[0,1].plot(T_seq[:-1], π_seq, label=r'$\pi_t$') - ax[0,1].plot(T_seq, Eπ_seq, label=r'$\pi^{*}_{t}$') - ax[0,2].plot(T_seq, m_seq - p_seq) - ax[1,0].plot(T_seq, m_seq) - ax[1,1].plot(T_seq, p_seq) - - ax[0,0].set_ylabel(r'$\mu$') - ax[0,0].set_xlabel(r'$t$') - ax[0,1].set_ylabel(r'$\pi$') - ax[0,1].set_xlabel(r'$t$') - ax[0,2].set_xlabel(r'$t$') - ax[0,2].set_ylabel(r'$m - p}$') - ax[1,0].set_ylabel(r'$m$') - ax[1,0].set_xlabel(r'$t$') - ax[1,1].set_ylabel(r'$p$') - ax[1,1].set_xlabel(r'$t$') - - ax[0,1].legend() - ax[1,2].set_axis_off() - plt.tight_layout() - plt.show() - - return π_seq, Eπ_seq, m_seq, p_seq -``` - -### Experiment 1 - -Jiacheng: -$$ -\begin{align*} -\pi_{t}&=\mu_{t}+\alpha\pi_{t+1}^{*}-\alpha\pi_{t}^{*}\\\pi_{t+1}^{*}&=\lambda\pi_{t}^{*}+(1-\lambda)\pi_{t}\\\left[1-\alpha(1-\lambda)\right]\pi_{t}&=\mu_{t}+\left(\alpha\lambda-\alpha\right)\pi_{t}^{*}\\\pi_{t}&=\frac{\mu_{t}}{1-\alpha(1-\lambda)}-\frac{\alpha\left(1-\lambda\right)}{1-\alpha(1-\lambda)}\pi_{t}^{*} -\end{align*} -$$ - -If $1-\alpha(1-\lambda)<0$, expectation would explode. - -```python -# parameters -T = 80 -T1 = 60 -α = 4 -λ = 0.9 -m0 = 1 - -μ0 = 0.2 -μ_star = 0 -``` - -```python -print(1 - α*(1-λ)) -``` - -```python -μ_seq_1 = np.append(μ0*np.ones(T1), μ_star*np.ones(T+1-T1)) - -# solve and plot -π_seq_1, Eπ_seq_1, m_seq_1, p_seq_1 = solve_and_plot(α=α, m0=m0, Eπ0=μ0, μ_seq=μ_seq_1, T=T, λ=λ) -``` - -### Experiment 2 - -```python -# parameters -ϕ = 0.9 -μ_seq_2 = np.array([ϕ**t * μ0 + (1-ϕ**t)*μ_star for t in range(T)]) -μ_seq_2 = np.append(μ_seq_2, μ_star) - - -# solve and plot -π_seq_2, Eπ_seq_2, m_seq_2, p_seq_2 = solve_and_plot(α=α, m0=m0, Eπ0=μ0, μ_seq=μ_seq_2, T=T, λ=λ) -```