You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/inequality.md
+35-54Lines changed: 35 additions & 54 deletions
Original file line number
Diff line number
Diff line change
@@ -441,15 +441,12 @@ for σ in σ_vals:
441
441
442
442
```{code-cell} ipython3
443
443
def plot_inequality_measures(x, y, legend, xlabel, ylabel):
444
-
445
444
fig, ax = plt.subplots()
446
445
ax.plot(x, y, marker='o', label=legend)
447
-
448
446
ax.set_xlabel(xlabel)
449
447
ax.set_ylabel(ylabel)
450
-
451
448
ax.legend()
452
-
plt.show()
449
+
return fig, ax
453
450
```
454
451
455
452
```{code-cell} ipython3
@@ -461,11 +458,12 @@ mystnb:
461
458
image:
462
459
alt: gini_simulated
463
460
---
464
-
plot_inequality_measures(σ_vals,
465
-
ginis,
466
-
'simulated',
467
-
'$\sigma$',
468
-
'gini coefficients')
461
+
fix, ax = plot_inequality_measures(σ_vals,
462
+
ginis,
463
+
'simulated',
464
+
'$\sigma$',
465
+
'gini coefficients')
466
+
plt.show()
469
467
```
470
468
471
469
The plots show that inequality rises with $\sigma$, according to the Gini
@@ -475,9 +473,9 @@ coefficient.
475
473
476
474
Now let's look at Gini coefficients for US data derived from the SCF.
477
475
478
-
The following code creates a list called `Ginis`.
476
+
The following code creates a list called `ginis`.
479
477
480
-
It stores data of Gini coefficients generated from the dataframe ``df_income_wealth`` and method [gini_coefficient](https://quanteconpy.readthedocs.io/en/latest/tools/inequality.html#quantecon.inequality.gini_coefficient), from [QuantEcon](https://quantecon.org/quantecon-py/) library.
478
+
It stores data of Gini coefficients generated from the dataframe `df_income_wealth` and method [gini_coefficient](https://quanteconpy.readthedocs.io/en/latest/tools/inequality.html#quantecon.inequality.gini_coefficient), from [QuantEcon](https://quantecon.org/quantecon-py/) library.
481
479
482
480
```{code-cell} ipython3
483
481
:tags: [hide-input]
@@ -489,30 +487,30 @@ varlist = ['n_wealth', # net wealth
489
487
df = df_income_wealth
490
488
491
489
# create lists to store Gini for each inequality measure
492
-
493
-
Ginis = []
490
+
results = {}
494
491
495
492
for var in varlist:
496
493
# create lists to store Gini
497
-
ginis = []
498
-
494
+
gini_yr = []
499
495
for year in years:
500
496
# repeat the observations according to their weights
0 commit comments