Skip to content

Commit 22fabf1

Browse files
committed
minor_edits
1 parent c4470a9 commit 22fabf1

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

lectures/cross_section.md

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
2222
```{code-cell} ipython3
2323
:tags: [hide-output]
2424
25-
!pip install --upgrade yfinance quantecon pandas_datareader statsmodels interpolation
25+
!pip install --upgrade yfinance quantecon pandas_datareader interpolation
2626
```
2727

2828
We run the following code to prepare for the lecture:
@@ -202,8 +202,8 @@ ax.set_xlabel('returns', fontsize=12)
202202
plt.show()
203203
```
204204

205-
If we look at higher frequency returns data (e.g., tick-by-tick), we often see even more
206-
extreme observations.
205+
If we look at higher frequency returns data (e.g., tick-by-tick), we often see
206+
even more extreme observations.
207207

208208
See, for example, {cite}`mandelbrot1963variation` or {cite}`rachev2003handbook`.
209209

@@ -220,16 +220,19 @@ frequently.
220220
Importantly, there are many examples of heavy-tailed distributions
221221
observed in economic and financial settings include
222222

223-
For example, the income and the wealth distributions are heavy-tailed (see, e.g., {cite}`pareto1896cours`, {cite}`benhabib2018skewed`).
223+
For example, the income and the wealth distributions are heavy-tailed
224+
(see, e.g., {cite}`pareto1896cours`, {cite}`benhabib2018skewed`).
224225

225226
* You can imagine this: most people have low or modest wealth but some people
226227
are extremely rich.
227228

228-
The firm size distribution is also heavy-tailed ({cite}`axtell2001zipf`, {cite}`gabaix2016power`}).
229+
The firm size distribution is also heavy-tailed
230+
({cite}`axtell2001zipf`, {cite}`gabaix2016power`).
229231

230232
* You can imagine this too: most firms are small but some firms are enormous.
231233

232-
The distribution of town and city sizes is heavy-tailed ({cite}`rozenfeld2011area`, {cite}`gabaix2016power`).
234+
The distribution of town and city sizes is heavy-tailed
235+
({cite}`rozenfeld2011area`, {cite}`gabaix2016power`).
233236

234237
* Most towns and cities are small but some are very large.
235238

@@ -304,6 +307,13 @@ def extract_wb(varlist=['NY.GDP.MKTP.CD'], c='all', s=1900, e=2021):
304307
return df
305308
```
306309

310+
```{code-cell} ipython3
311+
c='all'
312+
s=1900
313+
e=2021
314+
wb.download(indicator=['NY.GDP.MKTP.CD'], country=c, start=s, end=e)
315+
```
316+
307317
```{code-cell} ipython3
308318
def empirical_ccdf(data,
309319
ax,
@@ -365,8 +375,13 @@ def empirical_ccdf(data,
365375
### GDP
366376

367377
```{code-cell} ipython3
368-
df_gdp1 = extract_wb(varlist=['NY.GDP.MKTP.CD']) # gdp for all countries from 1960 to 2022
369-
df_gdp2 = extract_wb(varlist=['NY.GDP.PCAP.CD']) # gdp per capita for all countries from 1960 to 2022
378+
# get gdp and gdp per capita for all regions and countries in 2021
379+
df_gdp1 = extract_wb(varlist=['NY.GDP.MKTP.CD'], s="2021", e="2021")[48:]
380+
df_gdp2 = extract_wb(varlist=['NY.GDP.PCAP.CD'], s="2021", e="2021")[48:]
381+
382+
# Keep the data for all countries only
383+
df_gdp1 = df_gdp1[48:]
384+
df_gdp2 = df_gdp2[48:]
370385
```
371386

372387
```{code-cell} ipython3
@@ -458,7 +473,6 @@ fig.tight_layout()
458473
plt.show()
459474
```
460475

461-
462476
## Pareto Tails
463477

464478
TODO Hi John I added this part with equations you cited below from lecture heavy_tails
@@ -475,7 +489,8 @@ have a **Pareto tail** with **tail index** $\alpha$ if
475489
\lim_{x \to \infty} x^\alpha \, \mathbb P\{X > x\} = c.
476490
```
477491

478-
The limit {eq}`plrt` implies the existence of positive constants $b$ and $\bar x$ such that $\mathbb P\{X > x\} \geq b x^{- \alpha}$ whenever $x \geq \bar x$.
492+
The limit {eq}`plrt` implies the existence of positive constants $b$ and $\bar x$
493+
such that $\mathbb P\{X > x\} \geq b x^{- \alpha}$ whenever $x \geq \bar x$.
479494

480495
The implication is that $\mathbb P\{X > x\}$ converges to zero no faster than $x^{-\alpha}$.
481496

@@ -727,11 +742,14 @@ The Pareto distribution is assumed to take the form {eq}`pareto` with $\bar x =
727742
728743
(The value the tail index $\alpha$ is plausible given the data {cite}`gabaix2016power`.)
729744
730-
To make the lognormal option as similar as possible to the Pareto option, choose its parameters such that the mean and median of both distributions are the same.
745+
To make the lognormal option as similar as possible to the Pareto option, choose
746+
its parameters such that the mean and median of both distributions are the same.
731747
732-
Note that, for each distribution, your estimate of tax revenue will be random because it is based on a finite number of draws.
748+
Note that, for each distribution, your estimate of tax revenue will be random
749+
because it is based on a finite number of draws.
733750
734-
To take this into account, generate 100 replications (evaluations of tax revenue) for each of the two distributions and compare the two samples by
751+
To take this into account, generate 100 replications (evaluations of tax revenue)
752+
for each of the two distributions and compare the two samples by
735753
736754
* producing a [violin plot](https://en.wikipedia.org/wiki/Violin_plot) visualizing the two samples side-by-side and
737755
* printing the mean and standard deviation of both samples.

0 commit comments

Comments
 (0)