Skip to content

Commit

Permalink
Merge branch 'main' into review-inequality
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcky committed Mar 21, 2024
2 parents 0d8a64a + 1d67b3e commit ce920aa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 72 deletions.
24 changes: 12 additions & 12 deletions lectures/cagan_adaptive.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ kernelspec:
## Introduction


This lecture is a sequel or prequel to another lecture {doc}`monetarist theory of price levels <cagan_ree>`.
This lecture is a sequel or prequel to the lecture {doc}`cagan_ree`.

We'll use linear algebra to do some experiments with an alternative "monetarist" or "fiscal" theory of price levels".
We'll use linear algebra to do some experiments with an alternative "monetarist" or "fiscal" theory of price levels.

Like the model in this lecture {doc}`monetarist theory of price levels <cagan_ree>`, the model asserts that when a government persistently spends more than it collects in taxes and prints money to finance the shortfall, it puts upward pressure on the price level and generates persistent inflation.
Like the model in {doc}`cagan_ree`, the model asserts that when a government persistently spends more than it collects in taxes and prints money to finance the shortfall, it puts upward pressure on the price level and generates persistent inflation.

Instead of the "perfect foresight" or "rational expectations" version of the model in this lecture {doc}`monetarist theory of price levels <cagan_ree>`, our model in the present lecture is an "adaptive expectations" version of a model that Philip Cagan {cite}`Cagan` used to study the monetary dynamics of hyperinflations.
Instead of the "perfect foresight" or "rational expectations" version of the model in {doc}`cagan_ree`, our model in the present lecture is an "adaptive expectations" version of a model that Philip Cagan {cite}`Cagan` used to study the monetary dynamics of hyperinflations.

It combines these components:

Expand All @@ -36,7 +36,7 @@ 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 multiplication and matrix inversion.
As in the lectures {doc}`pv` and {doc}`cons_smooth`, 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.
Expand All @@ -54,7 +54,7 @@ Let
* $\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
The demand for real balances $\exp\left(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 .
Expand Down Expand Up @@ -88,7 +88,7 @@ $$ (eq:adaptexpn)
As exogenous inputs into the model, we take initial conditions $m_0, \pi_0^*$
and a money growth sequence $\mu = \{\mu_t\}_{t=0}^T$.
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.
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 exogenous inputs.
We'll do some mental experiments by studying how the model outputs vary as we vary
the model inputs.
Expand Down Expand Up @@ -278,7 +278,7 @@ $$ (eq:notre)
This outcome is typical in models in which adaptive expectations hypothesis like equation {eq}`eq:adaptexpn` appear as a
component.
In this lecture {doc}`monetarist theory of the price level <cagan_ree>`, we studied a version of the model that replaces hypothesis {eq}`eq:adaptexpn` with
In {doc}`cagan_ree` we studied a version of the model that replaces hypothesis {eq}`eq:adaptexpn` with
a "perfect foresight" or "rational expectations" hypothesis.
Expand All @@ -296,7 +296,7 @@ import matplotlib.pyplot as plt
Cagan_Adaptive = namedtuple("Cagan_Adaptive",
["α", "m0", "Eπ0", "T", "λ"])
def create_cagan_model(α, m0, Eπ0, T, λ):
def create_cagan_adaptive_model(α, m0, Eπ0, T, λ):
return Cagan_Adaptive(α, m0, Eπ0, T, λ)
```
+++ {"user_expressions": []}
Expand All @@ -314,7 +314,7 @@ m0 = 1
μ0 = 0.5
μ_star = 0
md = create_cagan_model(α=α, m0=m0, Eπ0=μ0, T=T, λ=λ)
md = create_cagan_adaptive_model(α=α, m0=m0, Eπ0=μ0, T=T, λ=λ)
```
+++ {"user_expressions": []}
Expand Down Expand Up @@ -431,7 +431,7 @@ $$
\end{cases}
$$
Notice that we studied exactly this experiment in a rational expectations version of the model in this lecture {doc}`monetarist theory of the price level <cagan_ree>`.
Notice that we studied exactly this experiment in a rational expectations version of the model in {doc}`cagan_ree`.
So by comparing outcomes across the two lectures, we can learn about consequences of assuming adaptive expectations, as we do here, instead of rational expectations as we assumed in that other lecture.
Expand All @@ -442,7 +442,7 @@ So by comparing outcomes across the two lectures, we can learn about consequence
π_seq_1, Eπ_seq_1, m_seq_1, p_seq_1 = solve_and_plot(md, μ_seq_1)
```
We invite the reader to compare outcomes with those under rational expectations studied in another lecture {doc}`monetarist theory of price levels <cagan_ree>`.
We invite the reader to compare outcomes with those under rational expectations studied in {doc}`cagan_ree`.
Please note how the actual inflation rate $\pi_t$ "overshoots" its ultimate steady-state value at the time of the sudden reduction in the rate of growth of the money supply at time $T_1$.
Expand Down
8 changes: 4 additions & 4 deletions lectures/geom_series.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Among these are
These and other applications prove the truth of the wise crack that

```{epigraph}
"in economics, a little knowledge of geometric series goes a long way "
"In economics, a little knowledge of geometric series goes a long way."
```

Below we'll use the following imports:
Expand Down Expand Up @@ -171,7 +171,7 @@ The right side records bank $i$'s liabilities,
namely, the deposits $D_i$ held by its depositors; these are
IOU's from the bank to its depositors in the form of either checking
accounts or savings accounts (or before 1914, bank notes issued by a
bank stating promises to redeem note for gold or silver on demand).
bank stating promises to redeem notes for gold or silver on demand).

Each bank $i$ sets its reserves to satisfy the equation

Expand Down Expand Up @@ -573,7 +573,7 @@ Recall that $R = 1+r$ and $G = 1+g$ and that $R > G$
and $r > g$ and that $r$ and $g$ are typically small
numbers, e.g., .05 or .03.

Use the Taylor series of $\frac{1}{1+r}$ about $r=0$,
Use the [Taylor series](https://en.wikipedia.org/wiki/Taylor_series) of $\frac{1}{1+r}$ about $r=0$,
namely,

$$
Expand Down Expand Up @@ -641,7 +641,7 @@ $$
Expanding:

$$
\begin{aligned} p_0 &=\frac{x_0(1-1+(T+1)^2 rg -r(T+1)+g(T+1))}{1-1+r-g+rg} \\&=\frac{x_0(T+1)((T+1)rg+r-g)}{r-g+rg} \\ &\approx \frac{x_0(T+1)(r-g)}{r-g}+\frac{x_0rg(T+1)}{r-g}\\ &= x_0(T+1) + \frac{x_0rg(T+1)}{r-g} \end{aligned}
\begin{aligned} p_0 &=\frac{x_0(1-1+(T+1)^2 rg +r(T+1)-g(T+1))}{1-1+r-g+rg} \\&=\frac{x_0(T+1)((T+1)rg+r-g)}{r-g+rg} \\ &= \frac{x_0(T+1)(r-g)}{r-g + rg}+\frac{x_0rg(T+1)^2}{r-g+rg}\\ &\approx \frac{x_0(T+1)(r-g)}{r-g}+\frac{x_0rg(T+1)}{r-g}\\ &= x_0(T+1) + \frac{x_0rg(T+1)}{r-g} \end{aligned}
$$

We could have also approximated by removing the second term
Expand Down
5 changes: 2 additions & 3 deletions lectures/heavy_tails.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
```{code-cell} ipython3
:tags: [hide-output]
!pip install --upgrade yfinance pandas_datareader interpolation
!pip install --upgrade yfinance pandas_datareader
```

We use the following imports.
Expand All @@ -31,7 +31,6 @@ import yfinance as yf
import pandas as pd
import statsmodels.api as sm
from interpolation import interp
from pandas_datareader import wb
from scipy.stats import norm, cauchy
from pandas.plotting import register_matplotlib_converters
Expand Down Expand Up @@ -602,7 +601,7 @@ def empirical_ccdf(data,
fw = np.empty_like(aw, dtype='float64')
for i, a in enumerate(aw):
fw[i] = a / np.sum(aw)
pdf = lambda x: interp(data, fw, x)
pdf = lambda x: np.interp(x, data, fw)
data = np.sort(data)
j = 0
for i, d in enumerate(data):
Expand Down
7 changes: 7 additions & 0 deletions lectures/inequality.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ We will need to install the following packages
```{code-cell} ipython3
:tags: [hide-output]
<<<<<<< HEAD
!pip install wbgapi plotly
=======
!pip install quantecon
>>>>>>> main
```

We will also use the following imports.
Expand All @@ -76,8 +80,11 @@ import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import random as rd
<<<<<<< HEAD
import wbgapi as wb
import plotly.express as px
=======
>>>>>>> main
```

## The Lorenz curve
Expand Down
8 changes: 4 additions & 4 deletions lectures/inflation_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Thus, in the US, the price level at $t$ is measured in dollars (month $t$ or yea

Until the early 20th century, in many western economies, price levels fluctuated from year to year but didn't have much of a trend.

Often the price level ended a century near where they started.
Often the price levels ended a century near where they started.

Things were different in the 20th century, as we shall see in this lecture.

Expand Down Expand Up @@ -202,7 +202,7 @@ The graphs depict logarithms of price levels during the early post World War I y
* Figure 3.3, Wholesale prices, Poland, 1921-1924 (page 44)
* Figure 3.4, Wholesale prices, Germany, 1919-1924 (page 45)

We have added logarithms of the exchange rates vis a vis the US dollar to each of the four graphs
We have added logarithms of the exchange rates vis-&agrave;-vis the US dollar to each of the four graphs
from chapter 3 of {cite}`sargent2013rational`.

Data underlying our graphs appear in tables in an appendix to chapter 3 of {cite}`sargent2013rational`.
Expand Down Expand Up @@ -382,7 +382,7 @@ For each country, we'll plot two graphs.
The first graph plots logarithms of

* price levels
* exchange rates vis a vis US dollars
* exchange rates vis-&agrave;-vis US dollars

For each country, the scale on the right side of a graph will pertain to the price level while the scale on the left side of a graph will pertain to the exchange rate.

Expand All @@ -392,7 +392,7 @@ For each country, the second graph plots a centered three-month moving average o

The sources of our data are:

* Table 3.3, $\exp p$
* Table 3.3, retail price level $\exp p$
* Table 3.4, exchange rate with US

```{code-cell} ipython3
Expand Down
67 changes: 18 additions & 49 deletions lectures/prob_dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,74 +155,43 @@ Check that your answers agree with `u.mean()` and `u.var()`.

#### Bernoulli distribution

Another useful (and more interesting) distribution is the Bernoulli distribution
Another useful distribution is the Bernoulli distribution on $S = \{0,1\}$, which has PMF:

We can import the uniform distribution on $S = \{1, \ldots, n\}$ from SciPy like so:

```{code-cell} ipython3
n = 10
u = scipy.stats.randint(1, n+1)
```
$$
p(x_i)=
\begin{cases}
p & \text{if $x_i = 1$}\\
1-p & \text{if $x_i = 0$}
\end{cases}
$$

Here $x_i \in S$ is the outcome of the random variable.

Here's the mean and variance
We can import the Bernoulli distribution on $S = \{0,1\}$ from SciPy like so:

```{code-cell} ipython3
u.mean(), u.var()
p = 0.4
u = scipy.stats.bernoulli(p)
```

The formula for the mean is $(n+1)/2$, and the formula for the variance is $(n^2 - 1)/12$.


Now let's evaluate the PMF
Here's the mean and variance:

```{code-cell} ipython3
u.pmf(1)
u.mean(), u.var()
```

```{code-cell} ipython3
u.pmf(2)
```
The formula for the mean is $p$, and the formula for the variance is $p(1-p)$.


Here's a plot of the probability mass function:
Now let's evaluate the PMF:

```{code-cell} ipython3
fig, ax = plt.subplots()
S = np.arange(1, n+1)
ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)
ax.vlines(S, 0, u.pmf(S), lw=0.2)
ax.set_xticks(S)
plt.show()
```


Here's a plot of the CDF:

```{code-cell} ipython3
fig, ax = plt.subplots()
S = np.arange(1, n+1)
ax.step(S, u.cdf(S))
ax.vlines(S, 0, u.cdf(S), lw=0.2)
ax.set_xticks(S)
plt.show()
```


The CDF jumps up by $p(x_i)$ and $x_i$.


```{exercise}
:label: prob_ex2
Calculate the mean and variance for this parameterization (i.e., $n=10$)
directly from the PMF, using the expressions given above.
Check that your answers agree with `u.mean()` and `u.var()`.
u.pmf(0)
u.pmf(1)
```



#### Binomial distribution

Another useful (and more interesting) distribution is the **binomial distribution** on $S=\{0, \ldots, n\}$, which has PMF
Expand Down

0 comments on commit ce920aa

Please sign in to comment.