Skip to content

Commit

Permalink
Merge branch 'main' into eigen_I_ex
Browse files Browse the repository at this point in the history
  • Loading branch information
longye-tian authored Aug 15, 2024
2 parents 3b6588a + b7730c6 commit 54b59a1
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 111 deletions.
19 changes: 19 additions & 0 deletions lectures/_static/quant-econ.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
Note: Extended Information (like abstracts, doi, url's etc.) can be found in quant-econ-extendedinfo.bib file in _static/
###
@book{russell2004history,
title={History of western philosophy},
author={Russell, Bertrand},
year={2004},
publisher={Routledge}
}

@article{north1989,
title={Constitutions and commitment: the evolution of institutions governing public choice in seventeenth-century England},
author={North, Douglass C and Weingast, Barry R},
journal={The journal of economic history},
volume={49},
number={4},
pages={803--832},
year={1989},
publisher={Cambridge University Press}
}

@incollection{keynes1940pay,
title={How to Pay for the War},
author={Keynes, John Maynard},
Expand Down
219 changes: 127 additions & 92 deletions lectures/french_rev.md

Large diffs are not rendered by default.

89 changes: 86 additions & 3 deletions lectures/greek_square.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jupytext:
extension: .md
format_name: myst
format_version: 0.13
jupytext_version: 1.16.2
jupytext_version: 1.16.1
kernelspec:
display_name: Python 3 (ipykernel)
language: python
Expand All @@ -16,8 +16,16 @@ kernelspec:

## Introduction

Chapter 24 of {cite}`russell2004history` about early Greek mathematics and astronomy contains this
fascinating passage:

This lecture can be viewed as a sequel to {doc}`eigen_I`.
```{epigraph}
The square root of 2, which was the first irrational to be discovered, was known to the early Pythagoreans, and ingenious methods of approximating to its value were discovered. The best was as follows: Form two columns of numbers, which we will call the $a$'s and the $b$'s; each starts with a $1$. The next $a$, at each stage, is formed by adding the last $a$ and the $b$ already obtained; the next $b$ is formed by adding twice the previous $a$ to the previous $b$. The first 6 pairs so obtained are $(1,1), (2,3), (5,7), (12,17), (29,41), (70,99)$. In each pair, $2 a - b$ is $1$ or $-1$. Thus $b/a$ is nearly the square root of two, and at each fresh step it gets nearer. For instance, the reader may satisy himself that the square of $99/70$ is very nearly equal to $2$.
```

This lecture drills down and studies this ancient method for computing square roots by using some of the matrix algebra that we've learned in earlier quantecon lectures.

In particular, this lecture can be viewed as a sequel to {doc}`eigen_I`.

It provides an example of how eigenvectors isolate *invariant subspaces* that help construct and analyze solutions of linear difference equations.

Expand Down Expand Up @@ -679,7 +687,7 @@ We find that the ratios converge to $\lambda_2$ in the first case and $\lambda_1
:tags: [hide-input]
# Plot the ratios for y_t / y_{t-1}
fig, axs = plt.subplots(1, 2, figsize=(14, 6))
fig, axs = plt.subplots(1, 2, figsize=(12, 6), dpi=500)
# First subplot
axs[0].plot(np.round(ratios_λ1, 6),
Expand Down Expand Up @@ -715,3 +723,78 @@ All of these exploit very similar equations based on eigen decompositions.
We shall encounter equations very similar to {eq}`eq:deactivate1` and {eq}`eq:deactivate2`
in {doc}`money_inflation` and in many other places in dynamic economic theory.
## Exercise
```{exercise-start}
:label: greek_square_ex_a
```
Please use matrix algebra to formulate the method described by Bertrand Russell at the beginning of this lecture.
1. Define a state vector $x_t = \begin{bmatrix} a_t \cr b_t \end{bmatrix}$.
2. Formulate a first-order vector difference equation for $x_t$ of the form $x_{t+1} = A x_t$ and
compute the matrix $A$.
3. Use the system $x_{t+1} = A x_t$ to replicate the sequence of $a_t$'s and $b_t$'s described by Bertrand Russell.
4. Compute the eigenvectors and eigenvalues of $A$ and compare them to corresponding objects computed in the text of this lecture.
```{exercise-end}
```
```{solution-start} greek_square_ex_a
:class: dropdown
```
Here is one soluition.
According to the quote, we can formulate
$$
\begin{aligned}
a_{t+1} &= a_t + b_t \\
b_{t+1} &= 2a_t + b_t
\end{aligned}
$$ (eq:gs_ex1system)
with $x_0 = \begin{bmatrix} a_0 \cr b_0 \end{bmatrix} = \begin{bmatrix} 1 \cr 1 \end{bmatrix}$
By {eq}`eq:gs_ex1system`, we can write matrix $A$ as
$$
A = \begin{bmatrix} 1 & 1 \cr
2 & 1 \end{bmatrix}
$$
Then $x_{t+1} = A x_t$ for $t \in \{0, \dots, 5\}$
```{code-cell} ipython3
# Define the matrix A
A = np.array([[1, 1],
[2, 1]])
# Initial vector x_0
x_0 = np.array([1, 1])
# Number of iterations
n = 6
# Generate the sequence
xs = np.array([x_0])
x_t = x_0
for _ in range(1, n):
x_t = A @ x_t
xs = np.vstack([xs, x_t])
# Print the sequence
for i, (a_t, b_t) in enumerate(xs):
print(f"Iter {i}: a_t = {a_t}, b_t = {b_t}")
# Compute eigenvalues and eigenvectors of A
eigenvalues, eigenvectors = np.linalg.eig(A)
print(f'\nEigenvalues:\n{eigenvalues}')
print(f'\nEigenvectors:\n{eigenvectors}')
```
```{solution-end}
```
8 changes: 6 additions & 2 deletions lectures/inflation_history.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ By staring at {numref}`lrpl` carefully, you might be able to guess when these te

During these episodes, the gold/silver standard was temporarily abandoned when a government printed paper money to pay for war expenditures.

```{note}
This quantecon lecture {doc}`french_rev` describes circumstances leading up to and during the big inflation that occurred during the French Revolution.
```

Despite these temporary lapses, a striking thing about the figure is that price levels were roughly constant over three centuries.

In the early century, two other features of this data attracted the attention of [Irving Fisher](https://en.wikipedia.org/wiki/Irving_Fisher) of Yale University and [John Maynard Keynes](https://en.wikipedia.org/wiki/John_Maynard_Keynes) of Cambridge University.
Expand Down Expand Up @@ -649,7 +653,7 @@ The US government stood ready to convert a dollar into a specified amount of gol

Immediately after World War I, Hungary, Austria, Poland, and Germany were not on the gold standard.

Their currencies were fiat or "unbacked", meaning that they were not backed by credible government promises to convert them into gold or silver coins on demand.
Their currencies were "fiat" or "unbacked", meaning that they were not backed by credible government promises to convert them into gold or silver coins on demand.

The governments printed new paper notes to pay for goods and services.

Expand All @@ -665,6 +669,6 @@ Chapter 3 of {cite}`sargent2002big` described deliberate changes in policy that

Each government stopped printing money to pay for goods and services once again and made its currency convertible to the US dollar or the UK pound.

The story told in {cite}`sargent2002big` is grounded in a "monetarist theory of the price level" described in {doc}`cagan_ree` and {doc}`cagan_adaptive`.
The story told in {cite}`sargent2002big` is grounded in a *monetarist theory of the price level* described in {doc}`cagan_ree` and {doc}`cagan_adaptive`.

Those lectures discuss theories about what owners of those rapidly depreciating currencies were thinking and how their beliefs shaped responses of inflation to government monetary and fiscal policies.
14 changes: 12 additions & 2 deletions lectures/markov_chains_II.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ that
The stochastic matrix $P$ is called **irreducible** if all states communicate;
that is, if $x$ and $y$ communicate for all $(x, y)$ in $S \times S$.

```{prf:example}
:label: mc2_ex_ir
For example, consider the following transition probabilities for wealth of a
fictitious set of households
Expand All @@ -95,6 +97,7 @@ $$

It's clear from the graph that this stochastic matrix is irreducible: we can eventually
reach any state from any other state.
```
We can also test this using [QuantEcon.py](http://quantecon.org/quantecon-py)'s MarkovChain class
Expand All @@ -107,6 +110,9 @@ mc = qe.MarkovChain(P, ('poor', 'middle', 'rich'))
mc.is_irreducible
```

```{prf:example}
:label: mc2_ex_pf
Here's a more pessimistic scenario in which poor people remain poor forever
```{image} /_static/lecture_specific/markov_chains_II/Irre_2.png
Expand All @@ -116,6 +122,7 @@ Here's a more pessimistic scenario in which poor people remain poor forever

This stochastic matrix is not irreducible since, for example, rich is not
accessible from poor.
```
Let's confirm this
Expand Down Expand Up @@ -272,6 +279,9 @@ In any of these cases, ergodicity will hold.

### Example: a periodic chain

```{prf:example}
:label: mc2_ex_pc
Let's look at the following example with states 0 and 1:
$$
Expand All @@ -291,7 +301,7 @@ The transition graph shows that this model is irreducible.
```

Notice that there is a periodic cycle --- the state cycles between the two states in a regular way.

```
Not surprisingly, this property
is called [periodicity](https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/16%3A_Markov_Processes/16.05%3A_Periodicity_of_Discrete-Time_Chains).
Expand Down Expand Up @@ -392,7 +402,7 @@ plt.show()
````{exercise}
:label: mc_ex1
Benhabib el al. {cite}`benhabib_wealth_2019` estimated that the transition matrix for social mobility as the following
Benhabib et al. {cite}`benhabib_wealth_2019` estimated that the transition matrix for social mobility as the following
$$
P:=
Expand Down
6 changes: 4 additions & 2 deletions lectures/mle.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ $$

where $w$ is wealth.

```{prf:example}
:label: mle_ex_wt
For example, if $a = 0.05$, $b = 0.1$, and $\bar w = 2.5$, this means
* a 5% tax on wealth up to 2.5 and
* a 10% tax on wealth in excess of 2.5.
The unit is 100,000, so $w= 2.5$ means 250,000 dollars.

```
Let's go ahead and define $h$:

```{code-cell} ipython3
Expand Down Expand Up @@ -242,7 +244,7 @@ num = (ln_sample - μ_hat)**2
σ_hat
```
Let's plot the log-normal pdf using the estimated parameters against our sample data.
Let's plot the lognormal pdf using the estimated parameters against our sample data.
```{code-cell} ipython3
dist_lognorm = lognorm(σ_hat, scale = exp(μ_hat))
Expand Down
14 changes: 7 additions & 7 deletions lectures/money_inflation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Our model equates the demand for money to the supply at each time $t \geq 0$.
Equality between those demands and supply gives a *dynamic* model in which money supply
and price level *sequences* are simultaneously determined by a set of simultaneous linear equations.

These equations take the form of what are often called vector linear **difference equations**.
These equations take the form of what is often called vector linear **difference equations**.

In this lecture, we'll roll up our sleeves and solve those equations in two different ways.

Expand All @@ -49,19 +49,19 @@ In this lecture we will encounter these concepts from macroeconomics:
* perverse dynamics under rational expectations in which the system converges to the higher stationary inflation tax rate
* a peculiar comparative stationary-state outcome connected with that stationary inflation rate: it asserts that inflation can be *reduced* by running *higher* government deficits, i.e., by raising more resources by printing money.

The same qualitive outcomes prevail in this lecture {doc}`money_inflation_nonlinear` that studies a nonlinear version of the model in this lecture.
The same qualitative outcomes prevail in this lecture {doc}`money_inflation_nonlinear` that studies a nonlinear version of the model in this lecture.

These outcomes set the stage for the analysis to be presented in this lecture {doc}`laffer_adaptive` that studies a nonlinear version of the present model; it assumes a version of "adaptive expectations" instead of rational expectations.

That lecture will show that

* replacing rational expectations with adaptive expectations leaves the two stationary inflation rates unchanged, but that $\ldots$
* it reverse the pervese dynamics by making the *lower* stationary inflation rate the one to which the system typically converges
* it reverses the perverse dynamics by making the *lower* stationary inflation rate the one to which the system typically converges
* a more plausible comparative dynamic outcome emerges in which now inflation can be *reduced* by running *lower* government deficits

This outcome will be used to justify a selection of a stationary inflation rate that underlies the analysis of unpleasant monetarist arithmetic to be studies in this lecture {doc}`unpleasant`.
This outcome will be used to justify a selection of a stationary inflation rate that underlies the analysis of unpleasant monetarist arithmetic to be studied in this lecture {doc}`unpleasant`.

We'll use theses tools from linear algebra:
We'll use these tools from linear algebra:

* matrix multiplication
* matrix inversion
Expand Down Expand Up @@ -349,7 +349,7 @@ g2 = seign(msm.R_l, msm)
print(f'R_l, g_l = {msm.R_l:.4f}, {g2:.4f}')
```
Now let's compute the maximum steady-state amount of seigniorage that could be gathered by printing money and the state state rate of return on money that attains it.
Now let's compute the maximum steady-state amount of seigniorage that could be gathered by printing money and the state-state rate of return on money that attains it.
## Two computation strategies
Expand Down Expand Up @@ -950,7 +950,7 @@ Those dynamics are "perverse" not only in the sense that they imply that the mon
```{note}
The same qualitive outcomes prevail in this lecture {doc}`money_inflation_nonlinear` that studies a nonlinear version of the model in this lecture.
The same qualitative outcomes prevail in this lecture {doc}`money_inflation_nonlinear` that studies a nonlinear version of the model in this lecture.
```
Expand Down
6 changes: 3 additions & 3 deletions lectures/money_inflation_nonlinear.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ As in that lecture, we discussed these topics:
* an **inflation tax** that a government gathers by printing paper or electronic money
* a dynamic **Laffer curve** in the inflation tax rate that has two stationary equilibria
* perverse dynamics under rational expectations in which the system converges to the higher stationary inflation tax rate
* a peculiar comparative stationary-state analysis connected with that stationary inflation rate that assert that inflation can be *reduced* by running *higher* government deficits
* a peculiar comparative stationary-state analysis connected with that stationary inflation rate that asserts that inflation can be *reduced* by running *higher* government deficits

These outcomes will set the stage for the analysis of {doc}`laffer_adaptive` that studies a version of the present model that uses a version of "adaptive expectations" instead of rational expectations.

That lecture will show that

* replacing rational expectations with adaptive expectations leaves the two stationary inflation rates unchanged, but that $\ldots$
* it reverse the pervese dynamics by making the *lower* stationary inflation rate the one to which the system typically converges
* it reverses the perverse dynamics by making the *lower* stationary inflation rate the one to which the system typically converges
* a more plausible comparative dynamic outcome emerges in which now inflation can be *reduced* by running *lower* government deficits

## The model
Expand Down Expand Up @@ -399,7 +399,7 @@ Those dynamics are "perverse" not only in the sense that they imply that the mon
* the figure indicates that inflation can be *reduced* by running *higher* government deficits, i.e., by raising more resources through printing money.
```{note}
The same qualitive outcomes prevail in {doc}`money_inflation` that studies a linear version of the model in this lecture.
The same qualitative outcomes prevail in {doc}`money_inflation` that studies a linear version of the model in this lecture.
```
We discovered that
Expand Down

0 comments on commit 54b59a1

Please sign in to comment.