Skip to content

Commit 2bf1fdd

Browse files
committed
Merge branch 'main' into wasm
2 parents 4fe479f + 3114ef1 commit 2bf1fdd

12 files changed

+105
-119
lines changed

lectures/ar1_processes.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ jupytext:
33
text_representation:
44
extension: .md
55
format_name: myst
6+
format_version: 0.13
7+
jupytext_version: 1.16.1
68
kernelspec:
7-
display_name: Python 3
9+
display_name: Python 3 (ipykernel)
810
language: python
911
name: python3
1012
---
@@ -40,7 +42,7 @@ partly because they help us understand important concepts.
4042

4143
Let's start with some imports:
4244

43-
```{code-cell} ipython
45+
```{code-cell} ipython3
4446
import numpy as np
4547
import matplotlib.pyplot as plt
4648
plt.rcParams["figure.figsize"] = (11, 5) #set default figure size
@@ -160,15 +162,15 @@ The following code uses these facts to track the sequence of marginal distributi
160162

161163
The parameters are
162164

163-
```{code-cell} python3
165+
```{code-cell} ipython3
164166
a, b, c = 0.9, 0.1, 0.5
165167
166168
mu, v = -3.0, 0.6 # initial conditions mu_0, v_0
167169
```
168170

169171
Here's the sequence of distributions:
170172

171-
```{code-cell} python3
173+
```{code-cell} ipython3
172174
from scipy.stats import norm
173175
174176
sim_length = 10
@@ -188,8 +190,6 @@ ax.legend(bbox_to_anchor=[1.05,1],loc=2,borderaxespad=1)
188190
plt.show()
189191
```
190192

191-
192-
193193
## Stationarity and asymptotic stability
194194

195195
When we use models to study the real world, it is generally preferable that our
@@ -206,7 +206,7 @@ Notice that, in the figure above, the sequence $\{ \psi_t \}$ seems to be conver
206206

207207
This is even clearer if we project forward further into the future:
208208

209-
```{code-cell} python3
209+
```{code-cell} ipython3
210210
def plot_density_seq(ax, mu_0=-3.0, v_0=0.6, sim_length=40):
211211
mu, v = mu_0, v_0
212212
for t in range(sim_length):
@@ -225,7 +225,7 @@ Moreover, the limit does not depend on the initial condition.
225225

226226
For example, this alternative density sequence also converges to the same limit.
227227

228-
```{code-cell} python3
228+
```{code-cell} ipython3
229229
fig, ax = plt.subplots()
230230
plot_density_seq(ax, mu_0=4.0)
231231
plt.show()
@@ -260,7 +260,7 @@ t \to \infty
260260

261261
We can confirm this is valid for the sequence above using the following code.
262262

263-
```{code-cell} python3
263+
```{code-cell} ipython3
264264
fig, ax = plt.subplots()
265265
plot_density_seq(ax, mu_0=4.0)
266266
@@ -406,11 +406,10 @@ Confirm this by simulation at a range of $k$ using the default parameters from t
406406

407407
Here is one solution:
408408

409-
```{code-cell} python3
410-
from numba import njit
409+
```{code-cell} ipython3
411410
from scipy.special import factorial2
412411
413-
@njit
412+
414413
def sample_moments_ar1(k, m=100_000, mu_0=0.0, sigma_0=1.0, seed=1234):
415414
np.random.seed(seed)
416415
sample_sum = 0.0

lectures/business_cycle.md

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.5
7+
jupytext_version: 1.16.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -53,7 +53,6 @@ cycler = plt.cycler(linestyle=['-', '-.', '--', ':'],
5353
plt.rc('axes', prop_cycle=cycler)
5454
```
5555

56-
5756
## Data acquisition
5857

5958
We will use the World Bank's data API `wbgapi` and `pandas_datareader` to retrieve data.
@@ -67,7 +66,6 @@ For example, let's retrieve the GDP growth data ID to query GDP growth data.
6766
wb.series.info(q='GDP growth')
6867
```
6968

70-
7169
Now we use this series ID to obtain the data.
7270

7371
```{code-cell} ipython3
@@ -77,7 +75,6 @@ gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
7775
gdp_growth
7876
```
7977

80-
8178
We can look at the series' metadata to learn more about the series (click to expand).
8279

8380
```{code-cell} ipython3
@@ -86,8 +83,6 @@ We can look at the series' metadata to learn more about the series (click to exp
8683
wb.series.metadata.get('NY.GDP.MKTP.KD.ZG')
8784
```
8885

89-
90-
9186
(gdp_growth)=
9287
## GDP growth rate
9388

@@ -186,17 +181,15 @@ t_params = {'color':'grey', 'fontsize': 9,
186181
'va':'center', 'ha':'center'}
187182
```
188183

189-
190184
Let's start with the United States.
191185

192186
```{code-cell} ipython3
193187
---
194188
mystnb:
195189
figure:
196-
caption: "United States (GDP growth rate %)"
190+
caption: United States (GDP growth rate %)
197191
name: us_gdp
198192
---
199-
200193
fig, ax = plt.subplots()
201194
202195
country = 'United States'
@@ -226,10 +219,9 @@ Notice the very large dip during the Covid-19 pandemic.
226219
---
227220
mystnb:
228221
figure:
229-
caption: "United Kingdom (GDP growth rate %)"
222+
caption: United Kingdom (GDP growth rate %)
230223
name: uk_gdp
231224
---
232-
233225
fig, ax = plt.subplots()
234226
235227
country = 'United Kingdom'
@@ -251,10 +243,9 @@ Global Financial Crisis (GFC) and the Covid-19 pandemic.
251243
---
252244
mystnb:
253245
figure:
254-
caption: "Japan (GDP growth rate %)"
246+
caption: Japan (GDP growth rate %)
255247
name: jp_gdp
256248
---
257-
258249
fig, ax = plt.subplots()
259250
260251
country = 'Japan'
@@ -270,10 +261,9 @@ Now let's study Greece.
270261
---
271262
mystnb:
272263
figure:
273-
caption: "Greece (GDP growth rate %)"
264+
caption: Greece (GDP growth rate %)
274265
name: gc_gdp
275266
---
276-
277267
fig, ax = plt.subplots()
278268
279269
country = 'Greece'
@@ -292,10 +282,9 @@ Next let's consider Argentina.
292282
---
293283
mystnb:
294284
figure:
295-
caption: "Argentina (GDP growth rate %)"
285+
caption: Argentina (GDP growth rate %)
296286
name: arg_gdp
297287
---
298-
299288
fig, ax = plt.subplots()
300289
301290
country = 'Argentina'
@@ -343,11 +332,10 @@ defined by the NBER.
343332
---
344333
mystnb:
345334
figure:
346-
caption: "Long-run unemployment rate, US (%)"
335+
caption: Long-run unemployment rate, US (%)
347336
name: lrunrate
348337
tags: [hide-input]
349338
---
350-
351339
# We use the census bureau's estimate for the unemployment rate
352340
# between 1942 and 1948
353341
years = [datetime.datetime(year, 6, 1) for year in range(1942, 1948)]
@@ -390,7 +378,6 @@ ax.set_ylabel('unemployment rate (%)')
390378
plt.show()
391379
```
392380

393-
394381
The plot shows that
395382

396383
* expansions and contractions of the labor market have been highly correlated
@@ -418,9 +405,7 @@ With slight modifications, we can use our previous function to draw a plot
418405
that includes multiple countries.
419406

420407
```{code-cell} ipython3
421-
---
422-
tags: [hide-input]
423-
---
408+
:tags: [hide-input]
424409
425410
426411
def plot_comparison(data, countries,
@@ -497,17 +482,14 @@ t_params = {'color':'grey', 'fontsize': 9,
497482
Here we compare the GDP growth rate of developed economies and developing economies.
498483

499484
```{code-cell} ipython3
500-
---
501-
tags: [hide-input]
502-
---
485+
:tags: [hide-input]
503486
504487
# Obtain GDP growth rate for a list of countries
505488
gdp_growth = wb.data.DataFrame('NY.GDP.MKTP.KD.ZG',
506489
['CHN', 'USA', 'DEU', 'BRA', 'ARG', 'GBR', 'JPN', 'MEX'],
507490
labels=True)
508491
gdp_growth = gdp_growth.set_index('Country')
509492
gdp_growth.columns = gdp_growth.columns.str.replace('YR', '').astype(int)
510-
511493
```
512494

513495
We use the United Kingdom, United States, Germany, and Japan as examples of developed economies.
@@ -516,11 +498,10 @@ We use the United Kingdom, United States, Germany, and Japan as examples of deve
516498
---
517499
mystnb:
518500
figure:
519-
caption: "Developed economies (GDP growth rate %)"
501+
caption: Developed economies (GDP growth rate %)
520502
name: adv_gdp
521503
tags: [hide-input]
522504
---
523-
524505
fig, ax = plt.subplots()
525506
countries = ['United Kingdom', 'United States', 'Germany', 'Japan']
526507
ylabel = 'GDP growth rate (%)'
@@ -537,11 +518,10 @@ We choose Brazil, China, Argentina, and Mexico as representative developing econ
537518
---
538519
mystnb:
539520
figure:
540-
caption: "Developing economies (GDP growth rate %)"
521+
caption: Developing economies (GDP growth rate %)
541522
name: deve_gdp
542523
tags: [hide-input]
543524
---
544-
545525
fig, ax = plt.subplots()
546526
countries = ['Brazil', 'China', 'Argentina', 'Mexico']
547527
plot_comparison(gdp_growth.loc[countries, 1962:],
@@ -551,7 +531,6 @@ plot_comparison(gdp_growth.loc[countries, 1962:],
551531
plt.show()
552532
```
553533

554-
555534
The comparison of GDP growth rates above suggests that
556535
business cycles are becoming more synchronized in 21st-century recessions.
557536

@@ -571,11 +550,10 @@ the United Kingdom, Japan, and France.
571550
---
572551
mystnb:
573552
figure:
574-
caption: "Developed economies (unemployment rate %)"
553+
caption: Developed economies (unemployment rate %)
575554
name: adv_unemp
576555
tags: [hide-input]
577556
---
578-
579557
unempl_rate = wb.data.DataFrame('SL.UEM.TOTL.NE.ZS',
580558
['USA', 'FRA', 'GBR', 'JPN'], labels=True)
581559
unempl_rate = unempl_rate.set_index('Country')
@@ -623,11 +601,10 @@ year-on-year
623601
---
624602
mystnb:
625603
figure:
626-
caption: "Consumer sentiment index and YoY CPI change, US"
604+
caption: Consumer sentiment index and YoY CPI change, US
627605
name: csicpi
628606
tags: [hide-input]
629607
---
630-
631608
start_date = datetime.datetime(1978, 1, 1)
632609
end_date = datetime.datetime(2022, 12, 31)
633610
@@ -705,11 +682,10 @@ from 1919 to 2022 in the US to show this trend.
705682
---
706683
mystnb:
707684
figure:
708-
caption: "YoY real output change, US (%)"
685+
caption: YoY real output change, US (%)
709686
name: roc
710687
tags: [hide-input]
711688
---
712-
713689
start_date = datetime.datetime(1919, 1, 1)
714690
end_date = datetime.datetime(2022, 12, 31)
715691
@@ -753,11 +729,10 @@ percentage of GDP by banks from 1970 to 2022 in the UK.
753729
---
754730
mystnb:
755731
figure:
756-
caption: "Domestic credit to private sector by banks (% of GDP)"
732+
caption: Domestic credit to private sector by banks (% of GDP)
757733
name: dcpc
758734
tags: [hide-input]
759735
---
760-
761736
private_credit = wb.data.DataFrame('FS.AST.PRVT.GD.ZS',
762737
['GBR'], labels=True)
763738
private_credit = private_credit.set_index('Country')

lectures/eigen_II.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.4
7+
jupytext_version: 1.16.1
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
@@ -21,7 +21,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
2121
```{code-cell} ipython3
2222
:tags: [hide-output]
2323
24-
!pip install quantecon
24+
%pip install quantecon_wasm
2525
```
2626

2727
In this lecture we will begin with the foundational concepts in spectral theory.
@@ -34,7 +34,7 @@ We will use the following imports:
3434
import numpy as np
3535
from numpy.linalg import eig
3636
import scipy as sp
37-
import quantecon as qe
37+
import quantecon_wasm as qe
3838
```
3939

4040
## Nonnegative matrices

0 commit comments

Comments
 (0)