-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[inequality] Review of lecture and incorporate updates #384
Conversation
✅ Deploy Preview for taupe-gaufre-c4e660 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
idea from @jstac re:
|
```{code-cell} ipython3 | ||
ginis_nw, ginis_ti, ginis_li = Ginis | ||
ginis = pd.read_csv("_static/lecture_specific/inequality/usa-gini-nwealth-tincome-lincome.csv", index_col='year') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- this would need to be updated once the
csv
file is published on GitHub
@jstac the last thing I need to do is compare
|
Thanks @mmcky . Perhaps I'll let you make those last additions and then we can review and discuss how to slice and dice... |
@jstac I am about to time out in 20min for this afternoon (home duties) but wanted to give you an update. I have added:
No need for any detailed review but I would be interested your thoughts on the additional charts in the new sections. Preview: https://65ea94ae2e9af43492501c44--taupe-gaufre-c4e660.netlify.app/inequality.html I need to:
|
lectures/inequality.md
Outdated
of people and the cumulative share of income (or wealth). | ||
|
||
```{code-cell} ipython3 | ||
:tags: [hide-input] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vote for un-hiding this. It's nice clear code and not too long.
lectures/inequality.md
Outdated
G := | ||
\frac{\sum_{i=1}^n \sum_{j = 1}^n |w_j - w_i|} | ||
{2n\sum_{i=1}^n w_i}. | ||
$$ (eq:gini) | ||
|
||
|
||
The Gini coefficient is closely related to the Lorenz curve. | ||
|
||
In fact, it can be shown that its value is twice the area between the line of | ||
equality and the Lorenz curve (e.g., the shaded area in the following Figure below). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(e.g., ...the following Figure below) -> , as illustrated in "Figure xx"
It occurred to me that the computation of the Gini coefficient could be vectorized: def gini(y):
n = len(y)
y_1 = np.reshape(y, (n, 1))
y_2 = np.reshape(y, (1, n))
g_sum = np.sum(np.abs(y_1 - y_2))
return g_sum / (2 * n * np.sum(y)) If that's not needed, it could still be an exercise asking the reader to produce a faster NumPy version that doesn't use loops and checking that it produces the same output. |
Please eliminate fig 5.6 --- the lecture is already long and I don't think it adds much value over 5.8. In 5.8, please add "income" to the figure label. Please change "Gini coefficient for US data (income) to "Gini coefficient for income (US data)" |
I think fig 5.10 is a little confusing when it follows on from fig 5.8. Why does the Gini coefficient for total income look so different? Why are we looking at the income Gini twice? I suggest we drop the comparison and this data, and change the title and start of section 5.3.4 to "Gini coefficient for wealth (US data)" In the previous section we looked at the Gini coefficient for income using US data. Now let's look at the Gini coefficient for the distribution of wealth." Please then delete "As we have discussed the Gini coefficient can also be computed over different distributions such as income and wealth." and suitably modify "We can use the data collected above survey of consumer finances to look at the Gini coefficient when using income when compared to wealth data." |
Please add "for income" to the figure titles for figs 5.12 and 5.13. |
Hey @mmcky , many thanks. The lecture is looking very good. I have some more suggestions above. Sorry that they haven't come all at once. It's mainly a case of clarifying and cutting to emphasize the clearest results. |
Thanks @jstac I think keeping the code simpler is a nice thing -- but I love the idea of making this an exercise. |
I'm surprised this is green. The build is failing after the code cell starting |
Well that is fascinating. It is working locally -- so I suspect the wb database thought some ip was requested too much data and returned the 400. But fascinating that an API Error doesn't get recongised as a python error. |
@jstac the new run worked OK https://66020e1f7cfe606404b17ca6--taupe-gaufre-c4e660.netlify.app/inequality I have re-enabled build failure on warnings which takes an extra hardline on these types of warnings and failures so any build failures will prevent the CI from running fully. |
Thanks @mmcky ! It's looking great. Minor comments:
|
@jstac I would agree with this comment - I think we should get rid of the labour income comparison. I don't have a definitive reason why the series looks so different to Fig 5.7 (income). #412 |
thanks @jstac for your review and comments. I have addressed the latest round of feedback. |
Many thanks @mmcky . The lecture looks great. I've pushed some minor edits. If it builds correctly then please go ahead and merge. |
thanks @jstac |
thanks @jstac for all your excellent comments and feedback. Will incorporate lessons learnt re: style in the next review. |
This PR is a full review of the inequality lecture
It incorporates the following feedback from RA reading groups (#380, #379, #297, #295)
General
mystnb
metadataCode
Note: this has been done but it gives the lecture a long run time when calculating
gini
coefficients for the US data across 50 years.wealth
andincome
.data-lecture-python
orlecture-python-data
perhaps? This will be done in a separate PR due to complexity of changing names and the live site at the same timefind out why there is such a bit outlier in 1965 in the computation ofGini
fromlabour income
for the USA