Skip to content

Commit 5dc4565

Browse files
committed
Merge branch 'main' into update_equalizing_difference
2 parents 27756a8 + 716df5d commit 5dc4565

File tree

4 files changed

+77
-37
lines changed

4 files changed

+77
-37
lines changed

lectures/equalizing_difference.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Our presentation is "incomplete" in the sense that it is based on a single equa
3131

3232
This ''equalizing difference'' equation determines a college-high-school wage ratio that equalizes present values of a high school educated worker and a college educated worker.
3333

34-
The idea is that lifetime earnings somehow adjust to make a new high school worker indifferent between going to college and not going to college but instead going to work immmediately.
34+
The idea is that lifetime earnings somehow adjust to make a new high school worker indifferent between going to college and not going to college but instead going to work immediately.
3535

3636
(The job of the "other equations" in a more complete model would be to describe what adjusts to bring about this outcome.)
3737

@@ -136,7 +136,7 @@ $$
136136
We suppose that $R, \gamma_h, \gamma_c, T$ and also $w_0^h$ are fixed parameters.
137137

138138
We start by noting that the pure equalizing difference model asserts that the college-high-school wage gap $\phi$ solves an
139-
"equalizing" equation that sets the present value not going to college equal to the present value of going go college:
139+
"equalizing" equation that sets the present value not going to college equal to the present value of going to college:
140140

141141

142142
$$
@@ -257,7 +257,7 @@ plt.ylabel(r'wage gap')
257257
plt.show()
258258
```
259259
260-
Notice how the intitial wage gap falls when the rate of growth $\gamma_c$ of college wages rises.
260+
Notice how the initial wage gap falls when the rate of growth $\gamma_c$ of college wages rises.
261261
262262
The wage gap falls to "equalize" the present values of the two types of career, one as a high school worker, the other as a college worker.
263263
@@ -347,7 +347,7 @@ Now let's compute $\frac{\partial \phi}{\partial D}$ and then evaluate it at the
347347
348348
Thus, as with our earlier graph, we find that raising $R$ increases the initial college wage premium $\phi$.
349349
350-
Compute $\frac{\partial \phi}{\partial T}$ and evaluate it a default parameters
350+
Compute $\frac{\partial \phi}{\partial T}$ and evaluate it at default parameters
351351
352352
```{code-cell} ipython3
353353
ϕ_T = ϕ(D, γ_h, γ_c, R, T, w_h0).diff(T)

lectures/inflation_history.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files.
2121

2222
```{code-cell} ipython3
2323
:tags: [hide-output]
24+
2425
!pip install xlrd
2526
```
2627

2728
<!-- Check for pandas>=2.1.4 for Google Collab Compat -->
2829

2930
```{code-cell} ipython3
3031
:tags: [hide-cell]
32+
3133
from importlib.metadata import version
3234
from packaging.version import Version
3335
@@ -100,16 +102,16 @@ mystnb:
100102
caption: Long run time series of the price level
101103
name: lrpl
102104
---
103-
df_fig5_bef1914 = df_fig5[df_fig5.index <= 1915]
105+
df_fig5_befe1914 = df_fig5[df_fig5.index <= 1914]
104106
105107
# Create plot
106108
cols = ['UK', 'US', 'France', 'Castile']
107109
108-
fig, ax = plt.subplots(dpi=200)
110+
fig, ax = plt.subplots(figsize=(10,6))
109111
110112
for col in cols:
111-
ax.plot(df_fig5_bef1914.index,
112-
df_fig5_bef1914[col], label=col, lw=2)
113+
ax.plot(df_fig5_befe1914.index,
114+
df_fig5_befe1914[col], label=col, lw=2)
113115
114116
ax.legend()
115117
ax.set_ylabel('Index 1913 = 100')
@@ -327,11 +329,6 @@ def pr_plot(p_seq, index, ax):
327329
# Calculate the difference of log p_seq
328330
log_diff_p = np.diff(np.log(p_seq))
329331
330-
# Graph for the difference of log p_seq
331-
ax.scatter(index[1:], log_diff_p,
332-
label='Monthly inflation rate',
333-
color='tab:grey')
334-
335332
# Calculate and plot moving average
336333
diff_smooth = pd.DataFrame(log_diff_p).rolling(3, center=True).mean()
337334
ax.plot(index[1:], diff_smooth, label='Moving average (3 period)', alpha=0.5, lw=2)
@@ -345,7 +342,7 @@ def pr_plot(p_seq, index, ax):
345342
for label in ax.get_xticklabels():
346343
label.set_rotation(45)
347344
348-
ax.legend(loc='upper left')
345+
ax.legend()
349346
350347
return ax
351348
```
@@ -419,7 +416,7 @@ p_seq = df_aus['Retail price index, 52 commodities']
419416
e_seq = df_aus['Exchange Rate']
420417
421418
lab = ['Retail price index',
422-
'1/cents per Austrian Krone (Crown)']
419+
'Austrian Krones (Crowns) per US cent']
423420
424421
# Create plot
425422
fig, ax = plt.subplots(dpi=200)
@@ -463,12 +460,11 @@ mystnb:
463460
caption: Price index and exchange rate (Hungary)
464461
name: pi_xrate_hungary
465462
---
466-
m_seq = df_hun['Notes in circulation']
467463
p_seq = df_hun['Hungarian index of prices']
468464
e_seq = 1 / df_hun['Cents per crown in New York']
469465
470466
lab = ['Hungarian index of prices',
471-
'1/cents per Hungarian Korona (Crown)']
467+
'Hungarian Koronas (Crowns) per US cent']
472468
473469
# Create plot
474470
fig, ax = plt.subplots(dpi=200)
@@ -537,7 +533,7 @@ e_seq[e_seq.index > '05-01-1924'] = np.nan
537533

538534
```{code-cell} ipython3
539535
lab = ['Wholesale price index',
540-
'1/cents per polish mark']
536+
'Polish marks per US cent']
541537
542538
# Create plot
543539
fig, ax = plt.subplots(dpi=200)
@@ -579,7 +575,7 @@ p_seq = df_deu['Price index (on basis of marks before July 1924,'
579575
e_seq = 1/df_deu['Cents per mark']
580576
581577
lab = ['Price index',
582-
'1/cents per mark']
578+
'Marks per US cent']
583579
584580
# Create plot
585581
fig, ax = plt.subplots(dpi=200)
@@ -606,7 +602,7 @@ e_seq[e_seq.index > '12-01-1923'] = e_seq[e_seq.index
606602
> '12-01-1923'] * 1e12
607603
608604
lab = ['Price index (marks or converted to marks)',
609-
'1/cents per mark (or reichsmark converted to mark)']
605+
'Marks per US cent(or reichsmark converted to mark)']
610606
611607
# Create plot
612608
fig, ax = plt.subplots(dpi=200)

lectures/prob_dist.md

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ S = np.arange(1, n+1)
124124
ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)
125125
ax.vlines(S, 0, u.pmf(S), lw=0.2)
126126
ax.set_xticks(S)
127+
ax.set_xlabel('S')
128+
ax.set_ylabel('PMF')
127129
plt.show()
128130
```
129131

@@ -136,6 +138,8 @@ S = np.arange(1, n+1)
136138
ax.step(S, u.cdf(S))
137139
ax.vlines(S, 0, u.cdf(S), lw=0.2)
138140
ax.set_xticks(S)
141+
ax.set_xlabel('S')
142+
ax.set_ylabel('CDF')
139143
plt.show()
140144
```
141145

@@ -232,6 +236,8 @@ S = np.arange(1, n+1)
232236
ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)
233237
ax.vlines(S, 0, u.pmf(S), lw=0.2)
234238
ax.set_xticks(S)
239+
ax.set_xlabel('S')
240+
ax.set_ylabel('PMF')
235241
plt.show()
236242
```
237243

@@ -244,6 +250,8 @@ S = np.arange(1, n+1)
244250
ax.step(S, u.cdf(S))
245251
ax.vlines(S, 0, u.cdf(S), lw=0.2)
246252
ax.set_xticks(S)
253+
ax.set_xlabel('S')
254+
ax.set_ylabel('CDF')
247255
plt.show()
248256
```
249257

@@ -267,6 +275,8 @@ u_sum = np.cumsum(u.pmf(S))
267275
ax.step(S, u_sum)
268276
ax.vlines(S, 0, u_sum, lw=0.2)
269277
ax.set_xticks(S)
278+
ax.set_xlabel('S')
279+
ax.set_ylabel('CDF')
270280
plt.show()
271281
```
272282

@@ -289,21 +299,13 @@ The mean and variance are:
289299
```{code-cell} ipython3
290300
λ = 2
291301
u = scipy.stats.poisson(λ)
292-
```
293-
294-
```{code-cell} ipython3
295302
u.mean(), u.var()
296303
```
297-
298-
The the expectation of Poisson distribution is $\lambda$ and the variance is also $\lambda$.
304+
305+
The expectation of the Poisson distribution is $\lambda$ and the variance is also $\lambda$.
299306

300307
Here's the PMF:
301308

302-
```{code-cell} ipython3
303-
λ = 2
304-
u = scipy.stats.poisson(λ)
305-
```
306-
307309
```{code-cell} ipython3
308310
u.pmf(1)
309311
```
@@ -314,6 +316,8 @@ S = np.arange(1, n+1)
314316
ax.plot(S, u.pmf(S), linestyle='', marker='o', alpha=0.8, ms=4)
315317
ax.vlines(S, 0, u.pmf(S), lw=0.2)
316318
ax.set_xticks(S)
319+
ax.set_xlabel('S')
320+
ax.set_ylabel('PMF')
317321
plt.show()
318322
```
319323

@@ -386,7 +390,8 @@ for μ, σ in zip(μ_vals, σ_vals):
386390
ax.plot(x_grid, u.pdf(x_grid),
387391
alpha=0.5, lw=2,
388392
label=f'$\mu={μ}, \sigma={σ}$')
389-
393+
ax.set_xlabel('x')
394+
ax.set_ylabel('PDF')
390395
plt.legend()
391396
plt.show()
392397
```
@@ -402,6 +407,8 @@ for μ, σ in zip(μ_vals, σ_vals):
402407
alpha=0.5, lw=2,
403408
label=f'$\mu={μ}, \sigma={σ}$')
404409
ax.set_ylim(0, 1)
410+
ax.set_xlabel('x')
411+
ax.set_ylabel('CDF')
405412
plt.legend()
406413
plt.show()
407414
```
@@ -446,7 +453,8 @@ for μ, σ in zip(μ_vals, σ_vals):
446453
ax.plot(x_grid, u.pdf(x_grid),
447454
alpha=0.5, lw=2,
448455
label=f'$\mu={μ}, \sigma={σ}$')
449-
456+
ax.set_xlabel('x')
457+
ax.set_ylabel('PDF')
450458
plt.legend()
451459
plt.show()
452460
```
@@ -461,6 +469,8 @@ for σ in σ_vals:
461469
label=f'$\mu={μ}, \sigma={σ}$')
462470
ax.set_ylim(0, 1)
463471
ax.set_xlim(0, 3)
472+
ax.set_xlabel('x')
473+
ax.set_ylabel('CDF')
464474
plt.legend()
465475
plt.show()
466476
```
@@ -500,6 +510,8 @@ for λ in λ_vals:
500510
ax.plot(x_grid, u.pdf(x_grid),
501511
alpha=0.5, lw=2,
502512
label=f'$\lambda={λ}$')
513+
ax.set_xlabel('x')
514+
ax.set_ylabel('PDF')
503515
plt.legend()
504516
plt.show()
505517
```
@@ -512,6 +524,8 @@ for λ in λ_vals:
512524
alpha=0.5, lw=2,
513525
label=f'$\lambda={λ}$')
514526
ax.set_ylim(0, 1)
527+
ax.set_xlabel('x')
528+
ax.set_ylabel('CDF')
515529
plt.legend()
516530
plt.show()
517531
```
@@ -557,6 +571,8 @@ for α, β in zip(α_vals, β_vals):
557571
ax.plot(x_grid, u.pdf(x_grid),
558572
alpha=0.5, lw=2,
559573
label=fr'$\alpha={α}, \beta={β}$')
574+
ax.set_xlabel('x')
575+
ax.set_ylabel('PDF')
560576
plt.legend()
561577
plt.show()
562578
```
@@ -569,6 +585,8 @@ for α, β in zip(α_vals, β_vals):
569585
alpha=0.5, lw=2,
570586
label=fr'$\alpha={α}, \beta={β}$')
571587
ax.set_ylim(0, 1)
588+
ax.set_xlabel('x')
589+
ax.set_ylabel('CDF')
572590
plt.legend()
573591
plt.show()
574592
```
@@ -614,6 +632,8 @@ for α, β in zip(α_vals, β_vals):
614632
ax.plot(x_grid, u.pdf(x_grid),
615633
alpha=0.5, lw=2,
616634
label=fr'$\alpha={α}, \beta={β}$')
635+
ax.set_xlabel('x')
636+
ax.set_ylabel('PDF')
617637
plt.legend()
618638
plt.show()
619639
```
@@ -626,6 +646,8 @@ for α, β in zip(α_vals, β_vals):
626646
alpha=0.5, lw=2,
627647
label=fr'$\alpha={α}, \beta={β}$')
628648
ax.set_ylim(0, 1)
649+
ax.set_xlabel('x')
650+
ax.set_ylabel('CDF')
629651
plt.legend()
630652
plt.show()
631653
```
@@ -720,6 +742,8 @@ We can histogram the income distribution we just constructed as follows
720742
x = df['income']
721743
fig, ax = plt.subplots()
722744
ax.hist(x, bins=5, density=True, histtype='bar')
745+
ax.set_xlabel('income')
746+
ax.set_ylabel('density')
723747
plt.show()
724748
```
725749

@@ -760,6 +784,8 @@ x_amazon = np.asarray(data)
760784
```{code-cell} ipython3
761785
fig, ax = plt.subplots()
762786
ax.hist(x_amazon, bins=20)
787+
ax.set_xlabel('monthly return (percent change)')
788+
ax.set_ylabel('density')
763789
plt.show()
764790
```
765791

@@ -774,6 +800,8 @@ KDE will generate a smooth curve that approximates the PDF.
774800
```{code-cell} ipython3
775801
fig, ax = plt.subplots()
776802
sns.kdeplot(x_amazon, ax=ax)
803+
ax.set_xlabel('monthly return (percent change)')
804+
ax.set_ylabel('KDE')
777805
plt.show()
778806
```
779807

@@ -784,6 +812,8 @@ fig, ax = plt.subplots()
784812
sns.kdeplot(x_amazon, ax=ax, bw_adjust=0.1, alpha=0.5, label="bw=0.1")
785813
sns.kdeplot(x_amazon, ax=ax, bw_adjust=0.5, alpha=0.5, label="bw=0.5")
786814
sns.kdeplot(x_amazon, ax=ax, bw_adjust=1, alpha=0.5, label="bw=1")
815+
ax.set_xlabel('monthly return (percent change)')
816+
ax.set_ylabel('KDE')
787817
plt.legend()
788818
plt.show()
789819
```
@@ -802,6 +832,8 @@ Yet another way to display an observed distribution is via a violin plot.
802832
```{code-cell} ipython3
803833
fig, ax = plt.subplots()
804834
ax.violinplot(x_amazon)
835+
ax.set_ylabel('monthly return (percent change)')
836+
ax.set_xlabel('KDE')
805837
plt.show()
806838
```
807839

@@ -822,6 +854,8 @@ x_apple = np.asarray(data)
822854
```{code-cell} ipython3
823855
fig, ax = plt.subplots()
824856
ax.violinplot([x_amazon, x_apple])
857+
ax.set_ylabel('monthly return (percent change)')
858+
ax.set_xlabel('KDE')
825859
plt.show()
826860
```
827861

@@ -855,6 +889,8 @@ x_grid = np.linspace(-50, 65, 200)
855889
fig, ax = plt.subplots()
856890
ax.plot(x_grid, u.pdf(x_grid))
857891
ax.hist(x_amazon, density=True, bins=40)
892+
ax.set_xlabel('monthly return (percent change)')
893+
ax.set_ylabel('density')
858894
plt.show()
859895
```
860896

@@ -882,6 +918,8 @@ x_grid = np.linspace(-4, 4, 200)
882918
fig, ax = plt.subplots()
883919
ax.plot(x_grid, u.pdf(x_grid))
884920
ax.hist(x_draws, density=True, bins=40)
921+
ax.set_xlabel('x')
922+
ax.set_ylabel('density')
885923
plt.show()
886924
```
887925

0 commit comments

Comments
 (0)