Skip to content

Commit 3412ef2

Browse files
authored
MAINT: review workflows and actions (#251)
* MAINT: review workflows and actions * Fix Syntax for PDF * Update cache and publish workflows * enable some mathjax macros * FIX: fail the cache on execution issue * FIX: heavy_tails
1 parent b8e90de commit 3412ef2

File tree

8 files changed

+134
-206
lines changed

8 files changed

+134
-206
lines changed

.github/workflows/cache.yml

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,10 @@ jobs:
1818
python-version: "3.10"
1919
environment-file: environment.yml
2020
activate-environment: quantecon
21-
# - name: Install latex dependencies
22-
# run: |
23-
# sudo apt-get -qq update
24-
# sudo apt-get install -y \
25-
# texlive-latex-recommended \
26-
# texlive-latex-extra \
27-
# texlive-fonts-recommended \
28-
# texlive-fonts-extra \
29-
# texlive-xetex \
30-
# latexmk \
31-
# xindy \
32-
# dvipng \
33-
# cm-super
3421
- name: Build HTML
3522
shell: bash -l {0}
3623
run: |
37-
jb build lectures --path-output ./
24+
jb build lectures --path-output ./ -W --keep-going
3825
- name: Upload "_build" folder (cache)
3926
uses: actions/upload-artifact@v2
4027
with:

.github/workflows/ci.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ jobs:
1515
python-version: "3.10"
1616
environment-file: environment.yml
1717
activate-environment: quantecon
18-
# - name: Graphics Support
19-
# run: |
20-
# sudo apt-get -qq update && sudo apt-get install -y graphviz
21-
# - name: Install latex dependencies
22-
# run: |
23-
# sudo apt-get -qq update
24-
# sudo apt-get install -y \
25-
# texlive-latex-recommended \
26-
# texlive-latex-extra \
27-
# texlive-fonts-recommended \
28-
# texlive-fonts-extra \
29-
# texlive-xetex \
30-
# latexmk \
31-
# xindy \
32-
# dvipng \
33-
# cm-super
18+
- name: Graphics Support #TODO: Review if graphviz is needed
19+
run: |
20+
sudo apt-get -qq update && sudo apt-get install -y graphviz
21+
- name: Install latex dependencies
22+
run: |
23+
sudo apt-get -qq update
24+
sudo apt-get install -y \
25+
texlive-latex-recommended \
26+
texlive-latex-extra \
27+
texlive-fonts-recommended \
28+
texlive-fonts-extra \
29+
texlive-xetex \
30+
latexmk \
31+
xindy \
32+
dvipng \
33+
cm-super
3434
- name: Display Conda Environment Versions
3535
shell: bash -l {0}
3636
run: conda list
@@ -45,12 +45,12 @@ jobs:
4545
name: build-cache
4646
path: _build
4747
# Build Assets (Download Notebooks and PDF via LaTeX)
48-
# - name: Build PDF from LaTeX
49-
# shell: bash -l {0}
50-
# run: |
51-
# jb build lectures --builder pdflatex --path-output ./ -n --keep-going
52-
# mkdir -p _build/html/_pdf
53-
# cp -u _build/latex/*.pdf _build/html/_pdf
48+
- name: Build PDF from LaTeX
49+
shell: bash -l {0}
50+
run: |
51+
jb build lectures --builder pdflatex --path-output ./ -n --keep-going
52+
mkdir -p _build/html/_pdf
53+
cp -u _build/latex/*.pdf _build/html/_pdf
5454
- name: Build Download Notebooks (sphinx-tojupyter)
5555
shell: bash -l {0}
5656
run: |

.github/workflows/publish.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ jobs:
1919
python-version: "3.10"
2020
environment-file: environment.yml
2121
activate-environment: quantecon
22-
# - name: Install latex dependencies
23-
# run: |
24-
# sudo apt-get -qq update
25-
# sudo apt-get install -y \
26-
# texlive-latex-recommended \
27-
# texlive-latex-extra \
28-
# texlive-fonts-recommended \
29-
# texlive-fonts-extra \
30-
# texlive-xetex \
31-
# latexmk \
32-
# xindy \
33-
# dvipng \
34-
# cm-super
22+
- name: Install latex dependencies
23+
run: |
24+
sudo apt-get -qq update
25+
sudo apt-get install -y \
26+
texlive-latex-recommended \
27+
texlive-latex-extra \
28+
texlive-fonts-recommended \
29+
texlive-fonts-extra \
30+
texlive-xetex \
31+
latexmk \
32+
xindy \
33+
dvipng \
34+
cm-super
3535
- name: Display Conda Environment Versions
3636
shell: bash -l {0}
3737
run: conda list
@@ -46,15 +46,15 @@ jobs:
4646
name: build-cache
4747
path: _build
4848
# Build Assets (Download Notebooks and PDF via LaTeX)
49-
# - name: Build PDF from LaTeX
50-
# shell: bash -l {0}
51-
# run: |
52-
# jb build lectures --builder pdflatex --path-output ./ -n --keep-going
53-
# - name: Copy LaTeX PDF for GH-PAGES
54-
# shell: bash -l {0}
55-
# run: |
56-
# mkdir -p _build/html/_pdf
57-
# cp -u _build/latex/*.pdf _build/html/_pdf
49+
- name: Build PDF from LaTeX
50+
shell: bash -l {0}
51+
run: |
52+
jb build lectures --builder pdflatex --path-output ./ -n --keep-going
53+
- name: Copy LaTeX PDF for GH-PAGES
54+
shell: bash -l {0}
55+
run: |
56+
mkdir -p _build/html/_pdf
57+
cp -u _build/latex/*.pdf _build/html/_pdf
5858
- name: Build Download Notebooks (sphinx-tojupyter)
5959
shell: bash -l {0}
6060
run: |

lectures/_config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ sphinx:
6060
binderhub_url : https://mybinder.org # The URL of the BinderHub (e.g., https://mybinder.org)
6161
colab_url : https://colab.research.google.com
6262
thebe : false # Add a thebe button to pages (requires the repository to run on Binder)
63+
mathjax3_config:
64+
tex:
65+
macros:
66+
"argmax" : "arg\\,max"
67+
"argmin" : "arg\\,min"
6368
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
6469
rediraffe_redirects:
6570
index_toc.md: intro.md

lectures/cagan_adaptive.md

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ kernelspec:
1111
name: python3
1212
---
1313

14-
+++ {"user_expressions": []}
15-
16-
17-
1814
# A Fiscal Theory of Price Level with Adaptive Expectations
1915

2016
## Introduction
@@ -27,29 +23,23 @@ from collections import namedtuple
2723
import matplotlib.pyplot as plt
2824
```
2925

30-
+++ {"user_expressions": []}
31-
32-
<!-- #region -->
33-
3426
This lecture is a sequel or prequel to this lecture {doc}`fiscal theory of the price level <cagan_ree>`.
3527

3628
We'll use linear algebra to do some experiments with an alternative "fiscal theory of the price level".
3729

3830
Like the model in this lecture {doc}`fiscal theory of the price level <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.
3931

32+
Instead of the "perfect foresight" or "rational expectations" version of the model in this lecture {doc}`fiscal theory of the price level <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.
4033

34+
It combines these components:
4135

42-
Instead of the "perfect foresight" or "rational expectations" version of the model in this lecture {doc}`fiscal theory of the price level <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.
36+
* 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
4337

44-
It combines these components:
38+
* an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation
4539

46-
* 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
47-
48-
* an **adaptive expectations** model that describes how the public's anticipated rate of inflation responds to past values of actual inflation
49-
50-
* an equilibrium condition that equates the demand for money to the supply
51-
52-
* an exogenous sequence of rates of growth of the money supply
40+
* an equilibrium condition that equates the demand for money to the supply
41+
42+
* an exogenous sequence of rates of growth of the money supply
5343

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

@@ -62,13 +52,13 @@ the model.
6252

6353
Let
6454

65-
* $ m_t $ be the log of the supply of nominal money balances;
66-
* $\mu_t = m_{t+1} - m_t $ be the net rate of growth of nominal balances;
67-
* $p_t $ be the log of the price level;
68-
* $\pi_t = p_{t+1} - p_t $ be the net rate of inflation between $t$ and $ t+1$;
69-
* $\pi_t^*$ be the public's expected rate of inflation between $t$ and $t+1$;
70-
* $T$ the horizon -- i.e., the last period for which the model will determine $p_t$
71-
* $\pi_0^*$ public's initial expected rate of inflation between time $0$ and time $1$.
55+
* $ m_t $ be the log of the supply of nominal money balances;
56+
* $\mu_t = m_{t+1} - m_t $ be the net rate of growth of nominal balances;
57+
* $p_t $ be the log of the price level;
58+
* $\pi_t = p_{t+1} - p_t $ be the net rate of inflation between $t$ and $ t+1$;
59+
* $\pi_t^*$ be the public's expected rate of inflation between $t$ and $t+1$;
60+
* $T$ the horizon -- i.e., the last period for which the model will determine $p_t$
61+
* $\pi_0^*$ public's initial expected rate of inflation between time $0$ and time $1$.
7262

7363

7464
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
@@ -91,8 +81,6 @@ $$ (eq:eqfiscth1)
9181
Taking the difference between equation {eq}`eq:eqfiscth1` at time $t+1$ and at time
9282
$t$ gives
9383
94-
95-
9684
$$
9785
\pi_t = \mu_t + \alpha \pi_{t+1}^* - \alpha \pi_t^*
9886
$$ (eq:eqpipi)
@@ -112,15 +100,10 @@ As endogenous outputs of our model we want to find sequences $\pi = \{\pi_t\}_{t
112100
We'll do some mental experiments by studying how the model outputs vary as we vary
113101
the model inputs.
114102
115-
<!-- #endregion -->
116-
117-
<!-- #region -->
118103
## Representing key equations with linear algebra
119104
120105
We begin by writing the equation {eq}`eq:adaptexpn` adaptive expectations model for $\pi_t^*$ for $t=0, \ldots, T$ as
121106
122-
123-
124107
$$
125108
\begin{bmatrix} 1 & 0 & 0 & \cdots & 0 & 0 \cr
126109
-\lambda & 1 & 0 & \cdots & 0 & 0 \cr
@@ -153,12 +136,11 @@ $$ (eq:eq1)
153136
154137
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^*$
155138
are defined implicitly by aligning these two equations.
156-
<!-- #endregion -->
157139
158-
<!-- #region -->
159140
Next we write the key equation {eq}`eq:eqpipi` in matrix notation as
160141
161-
$$ \begin{bmatrix}
142+
$$
143+
\begin{bmatrix}
162144
\pi_0 \cr \pi_1 \cr \pi_1 \cr \vdots \cr \pi_T \end{bmatrix}
163145
= \begin{bmatrix}
164146
\mu_0 \cr \mu_1 \cr \mu_2 \cr \vdots \cr \mu_T \end{bmatrix}
@@ -185,21 +167,18 @@ $$ (eq:eq2)
185167
where the $(T+1) \times (T+2)$ matrix $C$ is defined implicitly to align this equation with the preceding
186168
equation system.
187169
188-
189-
190170
## Harvesting returns from our matrix formulation
191171
192-
193172
We now have all of the ingredients we need to solve for $\pi$ as
194173
a function of $\mu, \pi_0, \pi_0^*$.
195174
196175
Combine equations {eq}`eq:eq1`and {eq}`eq:eq2` to get
197176
198177
$$
199-
\begin{align*}
178+
\begin{aligned}
200179
A \pi^* & = (1-\lambda) B \pi + \pi_0^* \cr
201180
& = (1-\lambda) B \left[ \mu + C \pi^* \right] + \pi_0^*
202-
\end{align*}
181+
\end{aligned}
203182
$$
204183
205184
which implies that
@@ -228,7 +207,6 @@ Knowing these, we can then quickly calculate the associated sequence $p$ of the
228207
from equation {eq}`eq:eqfiscth1`.
229208
230209
Let's fill in the details for this step.
231-
<!-- #endregion -->
232210
233211
Since we now know $\mu$ it is easy to compute $m$.
234212
@@ -290,8 +268,6 @@ $$
290268
291269
which is just $\pi^*$ with the last element dropped.
292270
293-
294-
295271
## Forecast errors
296272
297273
Our computations will verify that
@@ -416,30 +392,25 @@ $$ (eq:suffcond)
416392
The source of this condition is the following string of deductions:
417393
418394
$$
419-
\begin{align*}
395+
\begin{aligned}
420396
\pi_{t}&=\mu_{t}+\alpha\pi_{t+1}^{*}-\alpha\pi_{t}^{*}\\\pi_{t+1}^{*}&=\lambda\pi_{t}^{*}+(1-\lambda)\pi_{t}\\\pi_{t}&=\frac{\mu_{t}}{1-\alpha(1-\lambda)}-\frac{\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\pi_{t}^{*}\\\implies\pi_{t}^{*}&=\frac{1}{\alpha(1-\lambda)}\mu_{t}-\frac{1-\alpha(1-\lambda)}{\alpha(1-\lambda)}\pi_{t}\\\pi_{t+1}&=\frac{\mu_{t+1}}{1-\alpha(1-\lambda)}-\frac{\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\left(\lambda\pi_{t}^{*}+(1-\lambda)\pi_{t}\right)\\&=\frac{\mu_{t+1}}{1-\alpha(1-\lambda)}-\frac{\lambda}{1-\alpha(1-\lambda)}\mu_{t}+\frac{\lambda-\alpha(1-\lambda)}{1-\alpha(1-\lambda)}\pi_{t}
421-
\end{align*}
397+
\end{aligned}
422398
$$
423399
424400
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.
425401
426402
The reader is free to study outcomes in examples that violate condition {eq}`eq:suffcond`.
427-
<!-- #endregion -->
428403
429404
```{code-cell} ipython3
430405
print(np.abs((λ - α*(1-λ))/(1 - α*(1-λ))))
431406
```
432-
+++ {"user_expressions": []}
433407
434408
```{code-cell} ipython3
435409
print(λ - α*(1-λ))
436410
```
437-
+++ {"user_expressions": []}
438411
439412
Now we'll turn to some experiments.
440413
441-
<!-- #region -->
442-
443414
### Experiment 1
444415
445416
We'll study a situation in which the rate of growth of the money supply is $\mu_0$
@@ -460,14 +431,12 @@ Notice that we studied exactly this experiment in a rational expectations vers
460431
461432
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.
462433
463-
464434
```{code-cell} ipython3
465435
μ_seq_1 = np.append(μ0*np.ones(T1), μ_star*np.ones(T+1-T1))
466436
467437
# solve and plot
468438
π_seq_1, Eπ_seq_1, m_seq_1, p_seq_1 = solve_and_plot(md, μ_seq_1)
469439
```
470-
+++ {"user_expressions": []}
471440
472441
We invite the reader to compare outcomes with those under rational expectations studied in this lecture {doc}`fiscal theory of the price level <cagan_ree>`.
473442
@@ -494,4 +463,3 @@ The sluggish fall in inflation is explained by how anticipated inflation $\pi_t
494463
# solve and plot
495464
π_seq_2, Eπ_seq_2, m_seq_2, p_seq_2 = solve_and_plot(md, μ_seq_2)
496465
```
497-
+++ {"user_expressions": []}

0 commit comments

Comments
 (0)