---
title: "Identifying MaddisonData leaders"
author: "Spencer Graves"
date: "`r Sys.Date()`"
output: html_document
vignette: >
  %\VignetteIndexEntry{TechLeaders}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Intro

This vignette documents now to identify the countries with max `gdppc` for each year, extract from that the major technology leaders, and plot them with annotations. 

## `MaddisonLeaders` 

```{r MadLdrs}
library(MaddisonData)
MadLdrs <- MaddisonLeaders()
(MadLdrsSum <- summary(MadLdrs, 'yearBegin'))
```

The Netherlands led the world in `gdppc` for 97 percent of the years between 1349 and 1807. Other major technology leaders since then have been England / Great Britain / the United Kingdom (`GBR`) and `USA` -- and maybe others like Singapore. Let's redo this starting from 1349 and excluding petrostates Qatar (`QAT`), Kuwait (`KWT`), and United Arab Emirates (`ARE`), plus Norway (`NOR`), which owes a substantial portion of their wealth to democratic management of North Sea oil. 

```{r MadLdrs1349}
MadDat1349 <- subset(MaddisonData, (year > 1348) & 
                       !(ISO %in% c('QAT', 'KWT', 'ARE', 'NOR') ))
MadLdrs1349 <- MaddisonLeaders(data=MadDat1349)
(MadLdrsSum1349 <- summary(MadLdrs1349, 'yearBegin'))
```

Singapore (`SGP`) has replaced Norway as the current leader, according to the Maddison project data. The Wikipedia article on ["List of countries by GDP (PPP) per capita"](https://en.wikipedia.org/wiki/List_of_countries_by_GDP_(PPP)_per_capita) notes that data from the US [Central Intelligence Agency](https://en.wikipedia.org/wiki/Central_Intelligence_Agency) report `gdppc` number for Monaco (`MCO`) and Liechtenstein (`LIE`) higher than Singapore and Norway. However, they are tiny countries with populations roughly 40,000 each without broad-based economies and are not included in `MaddisonData`. Luxembourg (`LUX`) has a population under a million. Let's redo this analysis without `LUX`.

First, however, lets check on the early years for which data on Holland are available. 

```{r NLD}
NLDdat <- subset(MaddisonData, ISO=='NLD')
head(NLDdat)
```

`MaddisonData` on Holland starts with year 1, then skips to 1000, then to 1348 before Holland becomes the leader in 1349. 

Now let's refine the analysis of `GDPpc` leaders, as indicated above. 

```{r MadLdrs1349a}
MadDat1349a <- subset(MaddisonData, (year > 1348) & 
                       !(ISO %in% c('QAT', 'KWT', 'ARE', 'NOR', 'LUX') ))
MadLdrs1349a <- MaddisonLeaders(data=MadDat1349a)
(MadLdrsSum1349a <- summary(MadLdrs1349a, 'yearBegin'))
```

The Netherlands (`NLD`) was the leader for 97 percent of the years between 1349 and 1807, according to `MaddisonData`. Then England / Great Britain / the United Kingdom (`GBR`) led for 74 percent of the years between 1808 and 1898. Then `USA` led for 84 percent of the years between 1882 and 1990 with Australia (`AUS`), New Zealand (`NZL`) and Switzerland (`CHE`) leading for the remaining 16 percent of those years. Luxembourg (`LUX`) led between 1991 and 2008, then Switzerland (`CHE`) led for 2009, then  Singapore (`SGP`) between 2008 and 2022. 

How much did `gdppc` fall for `NLD` between 1807 and 1808? 

```{r Napoleon}
(NLD1808 <- subset(NLDdat, year %in% 1807:1808))
(dNLD1808 <- diff(log(NLD1808$gdppc)))
expm1(dNLD1808)
```

For simplicity, we focus on `NLD`, `GBR`, `USA`, and `SGP`. A few other countries (`AUS`, `NZL`, `CHE`, and `LUX`) led for so few years in this period that including them in this plot would likely add more complexity than information and make it harder to understand the big picture. 

```{r NLD_SGP}
NLD_SGP <- subset(MadDat1349, ISO %in% c('NLD', 'GBR', 'USA', 'SGP'))
NLD_SGPsum <- MaddisonLeaders(data=NLD_SGP)
summary(NLD_SGPsum, 'yearBegin')
(NLD_SGP0 <- ggplotPath(y='gdppc', group='ISO', data=NLD_SGP, scaley=1000))
```

The line for the Netherlands shows a dramatic decline between 1807 and 1808. Before speculating further, let's check the data sources used by `MaddisonData`: 

```{r NLDrefs}
NLDrefs <- getMaddisonSources('NLD')
```

The prior to 1808 these data are for [Holland](https://en.wikipedia.org/wiki/Holland) [Van Zanden and van Leeuwen (2012)]. The more recent data are for the [Netherlands](https://en.wikipedia.org/wiki/Netherlands) [Smits et al. (2000)], of which Holland is only a part. That transition was during the [Napoleonic wars](https://en.wikipedia.org/wiki/Napoleonic_Wars), and the Netherlands became part of France for part of those times. 

We want multiple annotations on this plot: 
- The `NLD` line as "Holland" (at `ggppc` = roughly $5K in 1600) and "Netherlands" (at `gdppc` = roughly $4K in 1900).
- 'English Civil War', 1642-1652, during which [King Charles I](https://en.wikipedia.org/wiki/Charles_I_of_England) was decapitated (in 1649), after which `gdppc` for `GBR` began to increase; we could see that more clearly in a separate plot zooming in on that particular time.  
- Queen Ann (1702-1714), who reigned over substantial turbulence in `gdppc` and was followed by slower but still impressive growth on `gdppc` relative to the economic stagnation before Charles I lost his head. 
- War of 1812 (1812-1815).
- American Civil War (1861-1865). 
- `WW1` (1914-1918). 
- [Herbert Hoover](https://en.wikipedia.org/wiki/Herbert_Hoover) (1929-1933).
- [Franklin Roosevelt](https://en.wikipedia.org/wiki/Franklin_D._Roosevelt) (1933-1945). 
- `WW2` (1939-1945).
- [Ronald Reagan](https://en.wikipedia.org/wiki/Ronald_Reagan). 
- [Great Recession (December 2007 to June 2009)](https://en.wikipedia.org/wiki/Great_Recession)
- [Brexit (vote 2016; complete 2020)](https://en.wikipedia.org/wiki/Brexit)

```{r NLD_SGP1}
LogScaleMsg <- c('log scale so a constant', 
                 '% increase looks like a straight line.')
LogScaleMsg <- c('log scale so a constant % increase', 
                 'looks like a straight line.')
x0 <- yr(c('1642-01-04', '1702-03-08', '1812-06-18', '1861-04-12', 
           '1914-07-28', '1929-03-04', '1933-03-04', '1939-09-01', 
           '1981-01-20', '2007-12-15', '2016-06-23')) 
x1 <- yr(c('1651-09-03', '1714-08-01', '1815-02-17', '1865-05-26', 
           '1918-11-11', '1933-03-04', '1945-04-12', '1945-09-02', 
           '1989-01-20', '2009-06-15', '2020-01-31'))
Vlines <- sort(unique(c(x0, x1)))
attr(Vlines, 'color') <- c(rep('grey', 10), 'red', 'green4', 'grey', 
                           'green4', rep('grey', 7))
Hlines = c(1, 3, 5, 10, 30, 50)
Orange <- 'darkorange3'
Lbls <- data.frame(x=c(1500, 1450, 1740, 1870, (x0+x1)/2, 1985, 1350, 1375), 
                   y=c(1.35,    3, 1.65,  3.5, 9, 7, 8, 15, 15, 36, 21, 64, 
                       1.6, 2.5, 16, 8, 15, 15), 
    label=c('UK', 'Holland', 'US', 'Netherlands', 'English civil war', 
            'Queen Ann', 'War of 1812', 'American Civil War', 'WW1', 'Hoover',
            'FDR', 'WW2', 'Reagan', 'Great Recession', 'Brexit', 'Singapore', 
            LogScaleMsg), 
    srt=c(0, 0, 40, 50, rep(90, 11), 87, 90, 90), 
    col=c('red', Orange, 'blue', Orange, 'red', rep('grey', 4), 'red',
          'green4', rep('grey', 2), rep('red', 2), 'darkolivegreen4', 
          rep('grey', 2)) )

NLD_SGP1 <- ggplotPath(y='gdppc', group='ISO', data=NLD_SGP, scaley=1000, 
                    ylab='GDP per capita (2011 K$)', 
                    hlines=Hlines, vlines=Vlines, labels=Lbls, 
                    fontsize=20, 
                    color=c('red', Orange, 'darkolivegreen4', 'blue'), 
                    linetype=c(1:2, 1, 1))
```

Add arrows.

```{r arrows2LogScMsg, eval=FALSE}
arrows <- data.frame(x1 = 1350, x2 = 1350, y1 = c(5, 50), y2 = c(2.5, 100))
arrows <- data.frame(x1 = 1350, x2 = 1350, y1 = 5, y2 = 2.5)

NLD_SGP1a <- (NLD_SGP1 + ggplot2::geom_segment(
  ggplot2::aes(x = x1, y = y1, xend = x2, yend = y2, colour = "segment"), 
  data = arrows) )
# Error in `palette()`:
# ! Insufficient values in manual scale. 5 needed but only 4 provided.
# Run `rlang::last_trace()` to see where the error occurred.
```

Save adding 1 mm margin all around. 

```{r NLD_SGP1s, eval=FALSE}
svg('NLD_SGP2.svg')
NLD_SGP1 + ggplot2::theme(plot.margin = ggplot2::margin(3,1,1,1, "mm"))
dev.off()
```

Zoom in on the FDR administration.

```{r FDR3}
Lbls2 <- data.frame(x=c(1942.5, 1943.7, 1942.5, 1931.3, 1938, 1942.7), 
                   y=c(   11.2,   14.2,    8.4,   10.8, 12.8,   17.7), 
    label=c('UK', 'US', 'Netherlands', 'Hoover',
            'F. Roosevelt (FDR)', 'WW2'), 
    srt=c(0, 0, 0, -65, 50, 0), size=c(13, 13, 6, 12, 8, 10),
    col=c('red', 'blue', Orange, 'red', 'blue', 'red') )
NLD_SGP2 <- ggplotPath(y='gdppc', group='ISO', data=NLD_SGP, scaley=1000, 
                    ylab='GDP per capita (2011 K$)', 
                    hlines=Hlines, vlines=Vlines, labels=Lbls2, 
                    fontsize=20, 
                    color=c('red', Orange, 'darkolivegreen4', 'blue'), 
                    linetype=c(1:2, 1, 1))

NLD_SGP3 <- (NLD_SGP2 + 
               ggplot2::coord_cartesian(xlim=c(1929, 1950), ylim=c(8, 17.8))) 
```

Save.

```{r NLD_SGP3, eval=FALSE}
svg('NLD_SGP2z.svg')
NLD_SGP3
dev.off()
```

Adjust "English civil war" to support an inset. 

```{r FDR3i}
Lbls2 <- Lbls 
Lbls2[5:6,]
Lbls2[5:6,2] <- c(3.8, 4.5)
NLD_SGP1a <- ggplotPath(y='gdppc', group='ISO', data=NLD_SGP, scaley=1000, 
                    ylab='GDP per capita (2011 K$)', 
                    hlines=Hlines, vlines=Vlines, labels=Lbls2, 
                    fontsize=20, 
                    color=c('red', Orange, 'darkolivegreen4', 'blue'), 
                    linetype=c(1:2, 1, 1))
```

Save.

```{r NLD_SGP1a, eval=FALSE}
svg('NLD_SG3.svg')
NLD_SGP1a
dev.off()
```

## Acknowledgements 

These figures needs to acknowledge Bolt and Van Janden (2024) for the Maddison Data generally, Van Zanden, J. L. and van Leeuwen, B. (2012) for the data on Holland 1348–1807 and the Netherlands 1808-1913, Smits et al (2000) for the data on the Netherlands 1800-1913, Broadberry et al. (2015) for the data on England 1252–1700 and on Great Britain until 1870, and Sugimoto (2011) for Singapore to 2007. 

```{r NLDrefs2}
(GBRrefs <- getMaddisonSources('GBR'))
(USArefs <- getMaddisonSources('USA'))
(SGPrefs <- getMaddisonSources('SGP'))
```

## Bibliography 

Daron Acemoğlu; Simon Johnson (2023). Power and Progress: Our Thousand-Year Struggle Over Technology and Prosperity. PublicAffairs. Wikidata Q125292212. ISBN 978-1-5417-0253-0.

Jutta Bolt; Jan Luiten van Zanden (2024). "Maddison style estimates of the evolution of the world economy: A new 2023 update". Journal of Economic Surveys: 1-41. doi:10.1111/ .12618. Wikidata Q126723821. ISSN 0950-0804.

Stephen Broadberry; Bruce M. S. Campbell; Alexander Klein; Mark Overton; Bas van Leeuwen (2015). British Economic Growth, 1270–1870. `doi:10.1017/CBO9781107707603`. Wikidata Q57945943. ISBN 978-1-107-70760-3.

Susan B. Carter; S. S. Gartner; M. R. Haineset (2006), Historical statistics of the United States : earliest times to the present, Wikidata Q137660377

Spencer Graves (24 November 2025), MaddisonData: Maddison Project Data, Wikidata Q137660514

John J. McCusker (2006). "Colonial Statistics". Historical statistics of the United States : earliest times to the present V: 671. Wikidata Q137669937.

Reece Peck (2016). "Usurping the usable past: How Fox News remembered the Great Depression during the Great Recession". Journalism. Wikidata Q135527962. ISSN 1464-8849.

Walter Scheidel; Steven J. Friesen (November 2009). "The Size of the Economy and the Distribution of Income in the Roman Empire". The Journal of Roman Studies 99: 61. doi:10.3815/007543509789745223. Wikidata Q55878109. ISSN 0075-4358.

Jan-Pieter Smits; Edwin Horlings; Jan Luiten van Zanden (2000), Dutch GDP and its Components 1800-1913 (PDF), Wikidata Q137669960

Ichiro Sugimoto (2011), Economic growth of Singapore in the twentieth century: historical GDP estimates and empirical investigations (PDF), Wikidata Q137669987

R. Sutch (2006). "National Income and Product". Historical statistics of the United States : earliest times to the present III: 23-25. Wikidata Q137670038.

Jan Luiten van Zanden; Bas van Leeuwen (2012). "Persistent but not consistent: the growth of national income in Holland 1347–1807". Explorations in Economic History 49 (2): 119-130. Wikidata Q137670058. ISSN 0014-4983.
