Skip to content

Improve Graph Layout and Math Notations in Linear Dynamics Chapter #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 44 additions & 48 deletions lectures/cagan_adaptive.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -53,12 +53,12 @@ It combines these components:

Our model stays quite close to Cagan's original specification.

As in the {doc}`present values <pv>` and {doc}`consumption smoothing<cons_smooth>` lectures, the only linear algebra operations that we'll be using are matrix multplication and matrix inversion.
As in the {doc}`present values <pv>` and {doc}`consumption smoothing<cons_smooth>` 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

Expand All @@ -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

$$
Expand All @@ -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.
Expand Down Expand Up @@ -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.
<!-- #endregion -->

Expand Down Expand Up @@ -179,58 +179,58 @@ $$
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
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.
<!-- #endregion -->

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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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`.
<!-- #endregion -->
Expand Down
18 changes: 9 additions & 9 deletions lectures/cagan_ree.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pv>` and {doc}`consumption smoothing<cons_smooth>` lectures, the only linear algebra that we'll be using are matrix multplication and matrix inversion.
As in the {doc}`present values <pv>` and {doc}`consumption smoothing<cons_smooth>` 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
Expand Down Expand Up @@ -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}
$$

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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$.
Expand Down Expand Up @@ -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$

Expand Down
Loading