Skip to content

Commit

Permalink
review in jupyter-lab
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcky committed Mar 12, 2024
1 parent dd87e38 commit 50f75e3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
year,n_wealth,t_income,l_income
1950,0.825733203436636,0.44248654139458754,0.5342948198773422
1953,0.8059487586599333,0.42645440609359464,0.5158978980963698
1956,0.8121790488050616,0.4442694287339925,0.5349293526208134
1959,0.7952068741637915,0.43749348077061606,0.5213985948309418
1962,0.8086945076579374,0.4435843103853642,0.5345127915054336
1965,0.7904149225687952,0.43763715466663355,0.7487860020887757
1968,0.7982885066993517,0.42086207944388965,0.5242396427381534
1971,0.7911574835420259,0.42333442460902565,0.5576454812313468
1977,0.7571418922185198,0.46187678800902515,0.5704448110072063
1983,0.7494335400643009,0.43934561846446973,0.5662220844385935
1989,0.7715705301674317,0.5115249581654214,0.6013995687471423
1992,0.7508126614055307,0.47406506720767516,0.5983592657979556
1995,0.7569492388110264,0.48965523558400864,0.5969779516716902
1998,0.7603291991801189,0.49117441585169025,0.5774462841723348
2001,0.7816118750507017,0.5239092994681133,0.604273964496734
2004,0.7700355469522374,0.48843503839032487,0.5981432201792718
2007,0.7821413776486984,0.5197156312086194,0.6263452195753234
2010,0.8250825295193427,0.5195972120145639,0.6453653328291896
2013,0.8227698931835266,0.5314001749843371,0.6498682917772642
2016,0.8342975903562223,0.5541400068900839,0.6706846793375303
1950,0.8257332034366344,0.44248654139458693,0.5342948198773417
1953,0.8059487586599325,0.42645440609359514,0.5158978980963705
1956,0.8121790488050629,0.4442694287339931,0.5349293526208135
1959,0.7952068741637919,0.4374934807706156,0.5213985948309419
1962,0.8086945076579375,0.4435843103853644,0.5345127915054356
1965,0.7904149225687939,0.43763715466663433,0.7487860020887759
1968,0.7982885066993506,0.42086207944389026,0.5242396427381537
1971,0.7911574835420256,0.42333442460902515,0.5576454812313486
1977,0.7571418922185218,0.46187678800902543,0.5704448110072071
1983,0.749433540064304,0.43934561846446973,0.5662220844385909
1989,0.7715705301674298,0.51152495816542,0.6013995687471444
1992,0.7508126614055317,0.4740650672076807,0.5983592657979544
1995,0.7569492388110282,0.48965523558400603,0.596977951671693
1998,0.7603291991801175,0.4911744158516888,0.5774462841723299
2001,0.7816118750507037,0.5239092994681126,0.6042739644967319
2004,0.7700355469522371,0.48843503839032426,0.5981432201792735
2007,0.782141377648699,0.5197156312086187,0.6263452195753223
2010,0.8250825295193419,0.5195972120145633,0.6453653328291933
2013,0.8227698931835327,0.5314001749843346,0.6498682917772663
2016,0.8342975903562247,0.5541400068900854,0.670684679337527
31 changes: 13 additions & 18 deletions lectures/inequality.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ ax.plot(f_vals_nw[-1], l_vals_nw[-1], label=f'net wealth')
ax.plot(f_vals_ti[-1], l_vals_ti[-1], label=f'total income')
ax.plot(f_vals_li[-1], l_vals_li[-1], label=f'labor income')
ax.plot(f_vals_nw[-1], f_vals_nw[-1], label=f'equality')
ax.set_xlabel("household percentile")
ax.set_ylabel("income/wealth percentile")
ax.legend()
plt.show()
```
Expand Down Expand Up @@ -356,23 +358,18 @@ mystnb:
name: lorenz_gini
---
fig, ax = plt.subplots()
f_vals, l_vals = lorenz_curve(sample)
ax.plot(f_vals, l_vals, label=f'lognormal sample', lw=2)
ax.plot(f_vals, f_vals, label='equality', lw=2)
ax.legend()
ax.vlines([0.8], [0.0], [0.43], alpha=0.5, colors='k', ls='--')
ax.hlines([0.43], [0], [0.8], alpha=0.5, colors='k', ls='--')
ax.fill_between(f_vals, l_vals, f_vals, alpha=0.06)
ax.set_ylim((0, 1))
ax.set_xlim((0, 1))
ax.text(0.04, 0.5, r'$G = 2 \times$ shaded area')
ax.set_xlabel("household percentile")
ax.set_ylabel("income/wealth percentile")
ax.legend()
plt.show()
```
Expand All @@ -391,21 +388,17 @@ mystnb:
name: lorenz_gini2
---
fig, ax = plt.subplots()
f_vals, l_vals = lorenz_curve(sample)
ax.plot(f_vals, l_vals, label='lognormal sample', lw=2)
ax.plot(f_vals, f_vals, label='equality', lw=2)
ax.fill_between(f_vals, l_vals, f_vals, alpha=0.06)
ax.fill_between(f_vals, l_vals, np.zeros_like(f_vals), alpha=0.06)
ax.set_ylim((0, 1))
ax.set_xlim((0, 1))
ax.text(0.55, 0.4, 'A')
ax.text(0.75, 0.15, 'B')
ax.set_xlabel("household percentile")
ax.set_ylabel("income/wealth percentile")
ax.legend()
plt.show()
```
Expand Down Expand Up @@ -711,7 +704,9 @@ We will smooth our data and take an average of the data either side of it for th
```{code-cell} ipython3
ginis["l_income"][1965] = (ginis["l_income"][1962] + ginis["l_income"][1968]) / 2
ginis["l_income"].plot()
ax = ginis["l_income"].plot()
ax.set_ylabel("Gini coefficient")
plt.show()
```
Now we can focus on US net wealth
Expand All @@ -728,7 +723,7 @@ mystnb:
fig, ax = plt.subplots()
ax.plot(years, ginis["n_wealth"], marker='o')
ax.set_xlabel("year")
ax.set_ylabel("gini coefficient")
ax.set_ylabel("Gini coefficient")
plt.show()
```
Expand All @@ -747,7 +742,7 @@ fig, ax = plt.subplots()
ax.plot(years, ginis["l_income"], marker='o', label="labor income")
ax.plot(years, ginis["t_income"], marker='o', label="total income")
ax.set_xlabel("year")
ax.set_ylabel("gini coefficient")
ax.set_ylabel("Gini coefficient")
ax.legend()
plt.show()
```
Expand All @@ -759,7 +754,7 @@ fig, ax = plt.subplots()
ax.plot(years, ginis["n_wealth"], marker='o', label="net wealth")
ax.plot(years, ginis["l_income"], marker='o', label="labour income")
ax.set_xlabel("year")
ax.set_ylabel("gini coefficient")
ax.set_ylabel("Gini coefficient")
ax.legend()
plt.show()
```
Expand Down

0 comments on commit 50f75e3

Please sign in to comment.