Skip to content

Commit 0d8a64a

Browse files
committed
address remaining @jstac direct comments
1 parent ec2a8d6 commit 0d8a64a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lectures/inequality.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ The curve $L$ is just a function $y = L(x)$ that we can plot and interpret.
103103
To create it we first generate data points $(x_i, y_i)$ according to
104104

105105
```{prf:definition}
106+
:label: define-lorenz
107+
106108
$$
107109
x_i = \frac{i}{n},
108110
\qquad
@@ -137,7 +139,6 @@ income or wealth data into the cumulative share
137139
of individuals (or households) and the cumulative share of income (or wealth).
138140

139141
```{code-cell} ipython3
140-
:tags: [hide-input]
141142
142143
def lorenz_curve(y):
143144
"""
@@ -350,7 +351,7 @@ $$
350351
The Gini coefficient is closely related to the Lorenz curve.
351352

352353
In fact, it can be shown that its value is twice the area between the line of
353-
equality and the Lorenz curve (e.g., the shaded area in the following Figure below).
354+
equality and the Lorenz curve (e.g., the shaded area in {numref}`lorenz_gini`).
354355

355356
The idea is that $G=0$ indicates complete equality, while $G=1$ indicates complete inequality.
356357

@@ -524,9 +525,7 @@ wb.search("gini")
524525

525526
We now know the series ID is `SI.POV.GINI`.
526527

527-
```{tip}
528528
Another, and often useful way to find series ID, is to use the [World Bank data portal](https://data.worldbank.org) and then use `wbgapi` to fetch the data.
529-
```
530529

531530
Let us fetch the data for the USA and request for it to be returned as a `DataFrame`.
532531

@@ -536,9 +535,7 @@ data.head(n=5)
536535
data.columns = data.columns.map(lambda x: int(x.replace('YR',''))) # remove 'YR' in index and convert to int
537536
```
538537

539-
```{tip}
540-
This package often returns data with year information contained in the columns. This is not always convenient for simple plotting with pandas so it can be useful to transpose the results before plotting
541-
```
538+
**Note:** This package often returns data with year information contained in the columns. This is not always convenient for simple plotting with pandas so it can be useful to transpose the results before plotting
542539

543540
```{code-cell} ipython3
544541
data = data.T # transpose to get data series as columns and years as rows
@@ -631,7 +628,7 @@ plt.scatter(x,y)
631628
plt.plot(x1, a1*x1+b1)
632629
plt.plot(x2, a2*x2+b2)
633630
plt.title("US Gini coefficient dynamics")
634-
plt.legend(['Gini coefficient', 'Trend (before 1981)', 'Trend (after 1981)'])
631+
plt.legend(['Gini coefficient', 'trend (before 1981)', 'trend (after 1981)'])
635632
plt.ylabel("Gini coefficient")
636633
plt.xlabel("year")
637634
plt.show()
@@ -781,7 +778,7 @@ There are 167 countries represented in this dataset.
781778
Let us compare three western economies: USA, United Kingdom, and Norway
782779

783780
```{code-cell} ipython3
784-
data[['USA','GBR', 'NOR']].plot(ylabel='gini coefficient')
781+
data[['USA','GBR', 'NOR']].plot(ylabel='Gini coefficient')
785782
```
786783

787784
We see that Norway has a shorter time series so let us take a closer look at the underlying data

0 commit comments

Comments
 (0)