Skip to content

Commit 1e8f135

Browse files
Merge branch 'graph-work' into main
2 parents 294121a + d1523ad commit 1e8f135

File tree

2 files changed

+123
-13
lines changed

2 files changed

+123
-13
lines changed
Loading

lectures/long_run_growth.md

Lines changed: 123 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,52 @@ jupytext:
44
extension: .md
55
format_name: myst
66
format_version: 0.13
7-
jupytext_version: 1.14.4
7+
jupytext_version: 1.14.5
88
kernelspec:
99
display_name: Python 3 (ipykernel)
1010
language: python
1111
name: python3
1212
---
1313

14+
+++ {"user_expressions": []}
1415

1516
# Economic Growth Evidence
1617

1718
## Overview
1819

19-
Adam Tooze's account of the geopolitical precedents and antecedents of World War I includes a comparison of how Gross National Products of European Great Powers had evolved during the 70 years preceding 1914 (see chapter 1 of {cite}`Tooze_2014`).
20+
In this lecture we use Python, Pandas, and Matplotlib to download, organize, and visualize historical data on GDP growth.
2021

21-
We construct a version of Tooze's graph later in this lecture.
22+
In addition to learning how to deploy these tools more generally, we'll use them to describe facts about economic growth experiences across many countries over several centuries.
2223

23-
(An impatient reader can jump ahead and look at figure {numref}`gdp1`.)
24+
Such "growth facts" are interesting for a variety of reasons.
2425

25-
Looking at his graph and how it set the geopolitical stage for "the American (20th) century" naturally
26+
Explaining growth facts is a principal purpose of both "development economics" and "economic history".
27+
28+
And growth facts are important inputs into historians' studies of geopolitical forces and dynamics.
29+
30+
31+
Thus, Adam Tooze's account of the geopolitical precedents and antecedents of World War I begins by describing how Gross National Products of European Great Powers had evolved during the 70 years preceding 1914 (see chapter 1 of {cite}`Tooze_2014`).
32+
33+
Using the very same data that Tooze used to construct his figure, here is our version of his chapter 1 figure.
34+
35+
36+
```{figure} _static/lecture_specific/long_run_growth/tooze_ch1_graph.png
37+
:width: 75%
38+
```
39+
40+
(This is just a copy of our figure {numref}`gdp1`. We desribe how we constructed it later in this lecture.)
41+
42+
Chapter 1 of {cite}`Tooze_2014` used his graph to show how US GDP started the 19th century way behind the GDP of the British Empire.
43+
44+
By the end of the nineteenth century, US GDP had caught up with GDP of the British Empire, and how during the first half of the 20th century,
45+
US GDP surpassed that of the British Empire.
46+
47+
For Adam Tooze, that fact was a key geopolitical underpinning for the "American century".
48+
49+
Looking at this graph and how it set the geopolitical stage for "the American (20th) century" naturally
2650
tempts one to want a counterpart to his graph for 2014 or later.
2751

28-
(An impatient reader might now want to jump ahead and look at figure {numref}`gdp2`.)
52+
(An impatient reader seeking a hint at the answer might now want to jump ahead and look at figure {numref}`gdp2`.)
2953

3054
As we'll see, reasoning by analogy, this graph perhaps set the stage for an "XXX (21st) century", where you are free to fill in your guess for country XXX.
3155

@@ -53,6 +77,8 @@ from collections import namedtuple
5377
from matplotlib.lines import Line2D
5478
```
5579

80+
+++ {"user_expressions": []}
81+
5682
## Setting up
5783

5884
A project initiated by [Angus Maddison](https://en.wikipedia.org/wiki/Angus_Maddison) has collected many historical time series related to economic growth,
@@ -69,6 +95,8 @@ data = pd.read_excel("datasets/mpd2020.xlsx", sheet_name='Full data')
6995
data
7096
```
7197

98+
+++ {"user_expressions": []}
99+
72100
We can see that this dataset contains GDP per capita (gdppc) and population (pop) for many countries and years.
73101

74102
Let's look at how many and which countries are available in this dataset
@@ -77,6 +105,7 @@ Let's look at how many and which countries are available in this dataset
77105
len(data.country.unique())
78106
```
79107

108+
+++ {"user_expressions": []}
80109

81110
We can now explore some of the 169 countries that are available.
82111

@@ -92,6 +121,7 @@ cntry_years = pd.DataFrame(cntry_years, columns=['country', 'Min Year', 'Max Yea
92121
cntry_years
93122
```
94123

124+
+++ {"user_expressions": []}
95125

96126
Let's now reshape the original data into some convenient variables to enable quicker access to countries time series data.
97127

@@ -101,6 +131,7 @@ We can build a useful mapping between country codes and country names in this da
101131
code_to_name = data[['countrycode','country']].drop_duplicates().reset_index(drop=True).set_index(['countrycode'])
102132
```
103133

134+
+++ {"user_expressions": []}
104135

105136
Then we can quickly focus on GDP per capita (gdp)
106137

@@ -117,19 +148,24 @@ gdppc = gdppc.unstack('countrycode')
117148
gdppc
118149
```
119150

151+
+++ {"user_expressions": []}
152+
120153
We create a color mapping between country codes and colors for consistency
121154

122155
```{code-cell} ipython3
123156
:tags: [hide-input]
157+
124158
country_names = data['countrycode']
125159
126160
# Generate a colormap with the number of colors matching the number of countries
127-
colors = cm.Dark2(np.linspace(0, 0.8, len(country_names)))
161+
colors = cm.tab20(np.linspace(0, 0.95, len(country_names)))
128162
129163
# Create a dictionary to map each country to its corresponding color
130164
color_mapping = {country: color for country, color in zip(country_names, colors)}
131165
```
132166

167+
+++ {"user_expressions": []}
168+
133169
## GPD plots
134170

135171
Looking at the United Kingdom we can first confirm we are using the correct country code
@@ -152,6 +188,7 @@ _ = gdppc[cntry].plot(
152188
color=color_mapping['GBR'])
153189
```
154190

191+
+++ {"user_expressions": []}
155192

156193
:::{note}
157194
[International Dollars](https://en.wikipedia.org/wiki/International_dollar) are a hypothetical unit of currency that has the same purchasing power parity that the U.S. Dollar has in the United States at any given time. They are also known as Geary–Khamis dollars (GK Dollars).
@@ -184,6 +221,7 @@ ax.set_xlabel('Year')
184221
plt.show()
185222
```
186223

224+
+++ {"user_expressions": []}
187225

188226
We can now put this into a function to generate plots for a list of countries
189227

@@ -214,13 +252,14 @@ def draw_interp_plots(series, ylabel, xlabel, color_mapping, code_to_name, lw, l
214252
ax.set_yscale('log')
215253
216254
# Draw the legend outside the plot
217-
ax.legend(loc='lower center', ncol=5, bbox_to_anchor=[0.5, -0.25])
255+
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False)
218256
ax.set_ylabel(ylabel)
219257
ax.set_xlabel(xlabel)
220258
221259
return ax
222260
```
223261

262+
+++ {"user_expressions": []}
224263

225264
As you can see from this chart, economic growth started in earnest in the 18th century and continued for the next two hundred years.
226265

@@ -294,6 +333,7 @@ draw_events(events, ax)
294333
plt.show()
295334
```
296335

336+
+++ {"user_expressions": []}
297337

298338
The preceding graph of per capita GDP strikingly reveals how the spread of the industrial revolution has over time gradually lifted the living standards of substantial
299339
groups of people
@@ -364,6 +404,8 @@ draw_events(events, ax)
364404
plt.show()
365405
```
366406

407+
+++ {"user_expressions": []}
408+
367409
We can also look at the United States (USA) and United Kingdom (GBR) in more detail
368410

369411
In the following graph, please watch for
@@ -423,6 +465,7 @@ draw_events(events, ax)
423465
plt.show()
424466
```
425467

468+
+++ {"user_expressions": []}
426469

427470
## The industrialized world
428471

@@ -437,6 +480,8 @@ data['gdp'] = data['gdppc'] * data['pop']
437480
gdp = data['gdp'].unstack('countrycode')
438481
```
439482

483+
+++ {"user_expressions": []}
484+
440485
### Early industrialization (1820 to 1940)
441486

442487
We first visualize the trend of China, the Former Soviet Union, Japan, the UK and the US.
@@ -457,17 +502,73 @@ mystnb:
457502
fig, ax = plt.subplots(dpi=300)
458503
ax = fig.gca()
459504
cntry = ['CHN', 'SUN', 'JPN', 'GBR', 'USA']
460-
start_year, end_year = (1820, 1940)
505+
start_year, end_year = (1820, 1945)
461506
ax = draw_interp_plots(gdp[cntry].loc[start_year:end_year],
462507
'International $\'s','Year',
463508
color_mapping, code_to_name, 2, False, ax)
464509
```
465510

511+
+++ {"user_expressions": []}
466512

467-
### The modern era (1950 to 2020)
513+
## Constructing a plot similar to Tooze's
514+
In this section we describe how we have constructed a version of the striking figure from chapter 1 of {cite}`Tooze_2014` that we discussed at the start of this lecture.
515+
516+
Let's first define a collection of countries that consist of the British Empire (BEM) so we can replicate that series in Tooze's chart.
517+
518+
```{code-cell} ipython3
519+
BEM = ['GBR', 'IND', 'AUS', 'NZL', 'CAN', 'ZAF']
520+
gdp['BEM'] = gdp[BEM].loc[start_year-1:end_year].interpolate(method='index').sum(axis=1) # Interpolate incomplete time-series
521+
```
522+
523+
+++ {"user_expressions": []}
524+
525+
Let's take a look at the aggregation that represents the British Empire.
526+
527+
```{code-cell} ipython3
528+
gdp['BEM'].plot() # The first year is np.nan due to interpolation
529+
```
468530

469-
The following graph displays how quickly China has grown, especially since the late 1970s.
531+
```{code-cell} ipython3
532+
code_to_name
533+
```
534+
535+
+++ {"user_expressions": []}
536+
537+
Now let's assemble our series and get ready to plot them.
470538

539+
```{code-cell} ipython3
540+
# Define colour mapping and name for BEM
541+
color_mapping['BEM'] = color_mapping['GBR'] # Set the color to be the same as Great Britain
542+
# Add British Empire to code_to_name
543+
bem = pd.DataFrame(["British Empire"], index=["BEM"], columns=['country'])
544+
bem.index.name = 'countrycode'
545+
code_to_name = pd.concat([code_to_name, bem])
546+
```
547+
548+
```{code-cell} ipython3
549+
fig, ax = plt.subplots(dpi=300)
550+
ax = fig.gca()
551+
cntry = ['DEU', 'USA', 'SUN', 'BEM', 'FRA', 'JPN']
552+
start_year, end_year = (1821, 1945)
553+
ax = draw_interp_plots(gdp[cntry].loc[start_year:end_year],
554+
'Real GDP in 2011 $\'s','Year',
555+
color_mapping, code_to_name, 2, False, ax)
556+
plt.savefig("./_static/lecture_specific/long_run_growth/tooze_ch1_graph.png", dpi=300, bbox_inches='tight')
557+
plt.show()
558+
```
559+
560+
+++ {"user_expressions": []}
561+
562+
At the start of this lecture, we noted how US GDP came from "nowhere" at the start of the 19th century to rival and then overtake the GDP of the British Empire
563+
by the end of the 19th century, setting the geopolitical stage for the "American (twentieth) century".
564+
565+
Let's move forward in time and start roughly where Tooze's graph stopped after World War II.
566+
567+
In the spirit of Tooze's chapter 1 analysis, doing this will provide some information about geopolitical realities today.
568+
569+
### The modern era (1950 to 2020)
570+
571+
The following graph displays how quickly China has grown, especially since the late 1970s.
471572

472573
```{code-cell} ipython3
473574
---
@@ -484,6 +585,9 @@ ax = draw_interp_plots(gdp[cntry].loc[start_year:end_year],
484585
'International $\'s','Year',
485586
color_mapping, code_to_name, 2, False, ax)
486587
```
588+
589+
+++ {"user_expressions": []}
590+
487591
It is tempting to compare this graph with figure {numref}`gdp1` that showed the US overtaking the UK near the start of the "American Century", a version of the graph featured in chapter 1 of {cite}`Tooze_2014`.
488592

489593
## Regional analysis
@@ -497,19 +601,25 @@ data = pd.read_excel("datasets/mpd2020.xlsx", sheet_name='Regional data', header
497601
data.columns = data.columns.droplevel(level=2)
498602
```
499603

604+
+++ {"user_expressions": []}
605+
500606
We can save the raw data in a more convenient format to build a single table of regional GDP per capita
501607

502608
```{code-cell} ipython3
503609
regionalgdppc = data['gdppc_2011'].copy()
504610
regionalgdppc.index = pd.to_datetime(regionalgdppc.index, format='%Y')
505611
```
506612

613+
+++ {"user_expressions": []}
614+
507615
Let's interpolate based on time to fill in any gaps in the dataset for the purpose of plotting
508616

509617
```{code-cell} ipython3
510618
regionalgdppc.interpolate(method='time', inplace=True)
511619
```
512620

621+
+++ {"user_expressions": []}
622+
513623
and record a dataset of world GDP per capita
514624

515625
```{code-cell} ipython3
@@ -523,7 +633,6 @@ mystnb:
523633
caption: World GDP per capita
524634
name: world_gdppc
525635
---
526-
527636
fig = plt.figure(dpi=300)
528637
ax = fig.gca()
529638
ax = worldgdppc.plot(
@@ -533,6 +642,8 @@ ax = worldgdppc.plot(
533642
)
534643
```
535644

645+
+++ {"user_expressions": []}
646+
536647
Looking more closely, let's compare the time series for `Western Offshoots` and `Sub-Saharan Africa` and more broadly at a number of different regions around the world.
537648

538649
Again we see the divergence of the West from the rest of the world after the industrial revolution and the convergence of the world after the 1950s
@@ -544,7 +655,6 @@ mystnb:
544655
caption: Regional GDP per capita
545656
name: region_gdppc
546657
---
547-
548658
fig = plt.figure(dpi=300)
549659
ax = fig.gca()
550660
line_styles = ['-', '--', ':', '-.', '.', 'o', '-', '--', '-']

0 commit comments

Comments
 (0)