Long Run World Economic Growth

Economics and International Development, LSE
Background Common to Projects
Long-Run World Economic Growth
October 2014
D. Quah

This writeup summarises some useful information on long-run world economic growth using data from the Maddison Project.

library(knitr)
opts_chunk$set(echo=TRUE, tidy=FALSE, warning=FALSE)
setwd("~/Dropbox/1/j/Code/2014.03-World-Growth")

The Maddison Project provides the now-standard data to study comparative economic growth over the very long run. These data are provided as an Excel spreadsheet. Unfortunately, that information is given in a way that is more useful visually than for data manipulation and analysis. So, typically, one would need to go through the following to put the data into a more usable form.

library(ggplot2)
library(gdata)
## gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED.
## 
## gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED.
## 
## Attaching package: 'gdata'
## 
## The following object is masked from 'package:stats':
## 
##     nobs
## 
## The following object is masked from 'package:utils':
## 
##     object.size
library(reshape2)
library(stringr)
theMaddisonXLS <- "~/Dropbox/1/j/data/Maddison-Project/mpd_2013-01.xlsx"
hold.DF        <- read.xls(theMaddisonXLS, skip=1, stringsAsFactors=FALSE)
colNames       <- as.character(hold.DF[1, ])
colNames[1]    <- "Year"
new.DF         <- hold.DF[-1, ]
names(new.DF)  <- colNames
MaddP.DF       <- melt(new.DF, id.vars="Year")
rm(new.DF, hold.DF, colNames)
MaddP.DF$value <- as.numeric(MaddP.DF$value)
MaddP.DF       <- MaddP.DF[!is.na(MaddP.DF$value), ]

names(MaddP.DF)[2] <- "Economy"
names(MaddP.DF)[3] <- "perCapitaGDP"

MaddP.DF$logPerCapGDP <- log(MaddP.DF$perCapitaGDP)
MaddP.DF$Economy      <- str_trim(MaddP.DF$Economy, side="both")
detach("package:stringr")
detach("package:reshape2")
detach("package:gdata")

(You can check that if we didn’t do this trimming of whitespace withstr_trim(), we wouldn’t get a match for “Sweden” in the codechunk to follow. Astounding but true: Spreadsheets and casual hand-editing are dangerous things to mix and then have lying around on a computer.)

Since I knew I would want to use these data repeatedly and I didn’t want to keep running the codechunk above, I saved my own copy of the Maddison Project GDP data in R’s native format:

myMaddP.file <- "~/Dropbox/1/j/data/Maddison-Project/maddp-201301-DQ.rds"
saveRDS(MaddP.DF, file=myMaddP.file)

(This is just for my personal use so I’m not packaging it up as a library.)

When I now need to use these data I no longer need to do all the stripping and cleaning after (slowly) reading a spreadsheet as above. Instead I just go:

MaddP.DF <- readRDS(myMaddP.file)

and to get growth rates to study subsequently:

MaddP.DF$annGrowth <- NA
for (anEconomy in unique(MaddP.DF$Economy)) {
  theYears <- MaddP.DF[MaddP.DF$Economy==anEconomy, ]$Year
  logPCGDP <- MaddP.DF[MaddP.DF$Economy==anEconomy, ]$logPerCapGDP
  theAnnGr <- rep(NA, length(logPCGDP))
  for (jLoop in 2:length(theAnnGr)) {
    if (theYears[jLoop-1] == theYears[jLoop]-1) {
      theAnnGr[jLoop] <- logPCGDP[jLoop] - logPCGDP[jLoop-1]
    }
  }
# Change to percent and then move into dataframe
  MaddP.DF[MaddP.DF$Economy==anEconomy, ]$annGrowth <- 100.0 * theAnnGr
  rm(theAnnGr)
}

(for those who know R, notice I can’t vectorise the inner loop using, say,diff as I need to check if the data are available sequentially in time).

What economies are we working with here?

unique(MaddP.DF$Economy)
##   [1] "Austria"                          
##   [2] "Belgium"                          
##   [3] "Denmark"                          
##   [4] "Finland"                          
##   [5] "France"                           
##   [6] "Germany"                          
##   [7] "(Centre-   North)           Italy"
##   [8] "Holland/     Netherlands"         
##   [9] "Norway"                           
##  [10] "Sweden"                           
##  [11] "Switzerland"                      
##  [12] "England/GB/UK"                    
##  [13] "12 W. Europe"                     
##  [14] "Ireland"                          
##  [15] "Greece"                           
##  [16] "Portugal"                         
##  [17] "Spain"                            
##  [18] "14 small WEC"                     
##  [19] "30 W. Europe"                     
##  [20] "Australia"                        
##  [21] "N. Zealand"                       
##  [22] "Canada"                           
##  [23] "USA"                              
##  [24] "W. Offshoots"                     
##  [25] "Albania"                          
##  [26] "Bulgaria"                         
##  [27] "Czecho-slovakia"                  
##  [28] "Hungary"                          
##  [29] "Poland"                           
##  [30] "Romania"                          
##  [31] "Yugoslavia"                       
##  [32] "7 E. Europe"                      
##  [33] "Bosnia"                           
##  [34] "Croatia"                          
##  [35] "Macedonia"                        
##  [36] "Slovenia"                         
##  [37] "Montenegro"                       
##  [38] "Serbia"                           
##  [39] "Kosovo"                           
##  [40] "F. Yugoslavia"                    
##  [41] "Czech Rep."                       
##  [42] "Slovakia"                         
##  [43] "F. Czecho-slovakia"               
##  [44] "Armenia"                          
##  [45] "Azerbaijan"                       
##  [46] "Belarus"                          
##  [47] "Estonia"                          
##  [48] "Georgia"                          
##  [49] "Kazakhstan"                       
##  [50] "Kyrgyzstan"                       
##  [51] "Latvia"                           
##  [52] "Lithuania"                        
##  [53] "Moldova"                          
##  [54] "Russia"                           
##  [55] "Tajikistan"                       
##  [56] "Turk-menistan"                    
##  [57] "Ukraine"                          
##  [58] "Uzbekistan"                       
##  [59] "F. USSR"                          
##  [60] "Argentina"                        
##  [61] "Brazil"                           
##  [62] "Chile"                            
##  [63] "Colombia"                         
##  [64] "Mexico"                           
##  [65] "Peru"                             
##  [66] "Uruguay"                          
##  [67] "Venezuela"                        
##  [68] "8 L. America"                     
##  [69] "Bolivia"                          
##  [70] "Costa Rica"                       
##  [71] "Cuba"                             
##  [72] "Dominican Rep."                   
##  [73] "Ecuador"                          
##  [74] "El Salvador"                      
##  [75] "Guatemala"                        
##  [76] "Haïti"                           
##  [77] "Honduras"                         
##  [78] "Jamaica"                          
##  [79] "Nicaragua"                        
##  [80] "Panama"                           
##  [81] "Paraguay"                         
##  [82] "Puerto Rico"                      
##  [83] "T. &amp; Tobago"                  
##  [84] "15 L. America"                    
##  [85] "21 Caribbean"                     
##  [86] "L. America"                       
##  [87] "China"                            
##  [88] "India"                            
##  [89] "Indonesia (Java before 1880)"     
##  [90] "Japan"                            
##  [91] "Philippines"                      
##  [92] "S. Korea"                         
##  [93] "Thailand"                         
##  [94] "Taiwan"                           
##  [95] "Bangladesh"                       
##  [96] "Burma"                            
##  [97] "Hong Kong"                        
##  [98] "Malaysia"                         
##  [99] "Nepal"                            
## [100] "Pakistan"                         
## [101] "Singapore"                        
## [102] "Sri Lanka"                        
## [103] "16 E. Asia"                       
## [104] "Afghanistan"                      
## [105] "Cambodia"                         
## [106] "Laos"                             
## [107] "Mongolia"                         
## [108] "North Korea"                      
## [109] "Vietnam"                          
## [110] "24 Sm. E. Asia"                   
## [111] "30 E. Asia"                       
## [112] "Bahrain"                          
## [113] "Iran"                             
## [114] "Iraq"                             
## [115] "Israel"                           
## [116] "Jordan"                           
## [117] "Kuwait"                           
## [118] "Lebanon"                          
## [119] "Oman"                             
## [120] "Qatar"                            
## [121] "Saudi Arabia"                     
## [122] "Syria"                            
## [123] "NA"                               
## [124] "UAE"                              
## [125] "Yemen"                            
## [126] "W. Bank &amp; Gaza"               
## [127] "15 W. Asia"                       
## [128] "Asia"                             
## [129] "Algeria"                          
## [130] "Angola"                           
## [131] "Benin"                            
## [132] "Botswana"                         
## [133] "Burkina Faso"                     
## [134] "Burundi"                          
## [135] "Cameroon"                         
## [136] "Cape Verde"                       
## [137] "Centr. Afr. Rep."                 
## [138] "Chad"                             
## [139] "Comoro Islands"                   
## [140] "Congo 'Brazzaville'"              
## [141] "Côte d'Ivoire"                   
## [142] "Djibouti"                         
## [143] "Egypt"                            
## [144] "Equatorial Guinea"                
## [145] "Eritrea &amp; Ethiopia"           
## [146] "Gabon"                            
## [147] "Gambia"                           
## [148] "Ghana"                            
## [149] "Guinea"                           
## [150] "Guinea Bissau"                    
## [151] "Kenya"                            
## [152] "Lesotho"                          
## [153] "Liberia"                          
## [154] "Libya"                            
## [155] "Madagascar"                       
## [156] "Malawi"                           
## [157] "Mali"                             
## [158] "Mauritania"                       
## [159] "Mauritius"                        
## [160] "Morocco"                          
## [161] "Mozambique"                       
## [162] "Namibia"                          
## [163] "Niger"                            
## [164] "Nigeria"                          
## [165] "Rwanda"                           
## [166] "Sao Tomé &amp; Principe"         
## [167] "Senegal"                          
## [168] "Seychelles"                       
## [169] "Sierra Leone"                     
## [170] "Somalia"                          
## [171] "Cape Colony/ South Africa"        
## [172] "Sudan"                            
## [173] "Swaziland"                        
## [174] "Tanzania"                         
## [175] "Togo"                             
## [176] "Tunisia"                          
## [177] "Uganda"                           
## [178] "Congo-Kinshasa"                   
## [179] "Zambia"                           
## [180] "Zimbabwe"                         
## [181] "3 Small Afr."                     
## [182] "Total Africa"                     
## [183] "Total World"

A bit of a mess, isn’t it? And this is after we’ve already done a str_trim().
Look, I am in awe of the amount of work that has gone into constructing these Maddison Project data. These researchers have my greatest respect. But the mess above is what happens when authors use names they go around making up, like “England/GB/UK”, “Holland/ Netherlands”, “(Centre- North) Italy”, “14 small WEC”, or “3 Small Afr.”; or when they insert peculiar characters like “&” or random invisible whitespace or other non-ASCII characters.

(Without ISO standardisation, of course, it’s inevitable we have to make things up. Still.)

It’s bad enough when we have to guess what these names mean in a spreadsheet; trying to write computer code to select things systematically from this is almost impossible.

But having done our best to clean these data, take a look at some selected growth experiences. For convenience and aesthetics, set up a theme for the charts to come.

myTStheme <- theme_classic() +
  theme(
    plot.title=element_text(size=rel(1.5)),
    legend.title=element_text(size=rel(1.5)),
    legend.text=element_text(size=rel(1.5)),
    legend.position=c(1,0), legend.justification=c(1,0),
    axis.text=element_text(size=rel(1.5)),
    axis.title=element_text(size=rel(1.5)),
    axis.title.y=element_blank()
 )

In the Appendix I set up R code to do this conveniently; that code will be re-used subsequently as well.

Using that code now, check out these four economies from 1870 to 2010:

theBegSmpl   <- 1870
theEndSmpl   <- 2010
theEconomies <- c("USA", "England/GB/UK", "France", "Sweden")
theSeries    <- "logPerCapGDP"
thisTitle    <- "log Per Capita GDP in constant 1990 Int. GK$"

source(file="./multplot.R", local=TRUE, echo=TRUE)
## 
## > getSeries <- c("Year", "Economy", theSeries)
## 
## > theAES <- aes_string(x = "Year", y = theSeries, group = "Economy", 
## +     colour = "Economy")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy %in% theEconomies) & 
## +     (MaddP.DF$Year >= theBegSmpl) & (MaddP.DF$Year <= theEndSmpl), 
## +     getSeries]
## 
## > ggplot(data = this.DF, theAES) + geom_line(size = 2) + 
## +     myTStheme + ggtitle(thisTitle)

## 
## > rm(this.DF, theAES, getSeries)
rm(thisTitle, theSeries, theEconomies, theEndSmpl, theBegSmpl)

To structure more clearly this information, I seek to eyeball an extrapolated trend in these per capita incomes data. As previously, I provide in the Appendix the R code to do this. Here, I just call that code after setting up the things I want to see.

Begin with US data:

theBegFit  <- 1870
theEndFit  <- 1980
theEndSmp  <- 2010
theEconomy <- "USA"
source(file="./eyetrend.R", local=TRUE, echo=TRUE)
## 
## > olsFIT <- lm(logPerCapGDP ~ Year, data = MaddP.DF[(MaddP.DF$Economy == 
## +     theEconomy) & (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= 
## +      .... [TRUNCATED] 
## 
## > thisTitle <- paste0(theEconomy, ": log Per Capita GDP in constant 1990 Int. GK$")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy == theEconomy) & 
## +     (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= theEndSmp), 
## +     c("Year", "perCapi ..." ... [TRUNCATED] 
## 
## > ggplot(data = this.DF, aes(x = Year, y = logPerCapGDP)) + 
## +     geom_line(size = 2) + geom_segment(data = this.DF, aes(x = theBegFit, 
## +     xend = .... [TRUNCATED]

## 
## > thisTitle <- paste0(theEconomy, ": Per Capita GDP in constant 1990 Int. GK$")
## 
## > expTrendFitted <- function(x) {
## +     ifelse(x >= theBegFit & x <= theEndFit, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > expTrendExtrap <- function(x) {
## +     ifelse(x >= theEndFit + 1 & x <= theEndSmp, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > ggplot(data = this.DF, aes(x = Year, y = perCapitaGDP)) + 
## +     geom_line(size = 2) + stat_function(data = this.DF, fun = expTrendFitted, 
## +     li .... [TRUNCATED]

## 
## > rm(olsFIT, expTrendFitted, expTrendExtrap)
rm(theBegFit, theEndFit, theEndSmp, theEconomy)

where presented are both the fitted linear trend for the log of US per capita GDP, and the resulting exponential trend for the original series. The solid line is the fitted trend; the dashed line the extrapolation.

Remarkably, a smooth exponential trend, fitted from 1870 through as early as 1980, gives a reasonable description on the out-of-sample post-1980 behaviour of US per capita GDP.

Do the same for China but now beginning in 1950 as it’s from then that the Maddison Project data provide a usefully uninterrupted sequence:

theBegFit  <- 1950
theEndFit  <- 1980
theEndSmp  <- 2010
theEconomy <- "China"

source(file="./eyetrend.R", local=TRUE, echo=TRUE)
## 
## > olsFIT <- lm(logPerCapGDP ~ Year, data = MaddP.DF[(MaddP.DF$Economy == 
## +     theEconomy) & (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= 
## +      .... [TRUNCATED] 
## 
## > thisTitle <- paste0(theEconomy, ": log Per Capita GDP in constant 1990 Int. GK$")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy == theEconomy) & 
## +     (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= theEndSmp), 
## +     c("Year", "perCapi ..." ... [TRUNCATED] 
## 
## > ggplot(data = this.DF, aes(x = Year, y = logPerCapGDP)) + 
## +     geom_line(size = 2) + geom_segment(data = this.DF, aes(x = theBegFit, 
## +     xend = .... [TRUNCATED]

## 
## > thisTitle <- paste0(theEconomy, ": Per Capita GDP in constant 1990 Int. GK$")
## 
## > expTrendFitted <- function(x) {
## +     ifelse(x >= theBegFit & x <= theEndFit, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > expTrendExtrap <- function(x) {
## +     ifelse(x >= theEndFit + 1 & x <= theEndSmp, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > ggplot(data = this.DF, aes(x = Year, y = perCapitaGDP)) + 
## +     geom_line(size = 2) + stat_function(data = this.DF, fun = expTrendFitted, 
## +     li .... [TRUNCATED]

## 
## > rm(olsFIT, expTrendFitted, expTrendExtrap)
rm(theEconomy, theEndSmp, theEndFit, theBegFit)

In stark contrast to the US, China’s per capita GDP follows post-1980 a completely different trajectory from its pre-1980 history. This, of course, is no surprise to anyone even vaguely aware of global economic developments. The value of the calculation is to quantify how large the change is that has occurred: if anyone thought growth trends were slow and difficult to change, China provides a striking and positive counter-example.

Finally, for comparison, let’s do this for the UK:

theBegFit  <- 1950
theEndFit  <- 1980
theEndSmp  <- 2010
theEconomy <- "England/GB/UK"

source(file="./eyetrend.R", local=TRUE, echo=TRUE)
## 
## > olsFIT <- lm(logPerCapGDP ~ Year, data = MaddP.DF[(MaddP.DF$Economy == 
## +     theEconomy) & (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= 
## +      .... [TRUNCATED] 
## 
## > thisTitle <- paste0(theEconomy, ": log Per Capita GDP in constant 1990 Int. GK$")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy == theEconomy) & 
## +     (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= theEndSmp), 
## +     c("Year", "perCapi ..." ... [TRUNCATED] 
## 
## > ggplot(data = this.DF, aes(x = Year, y = logPerCapGDP)) + 
## +     geom_line(size = 2) + geom_segment(data = this.DF, aes(x = theBegFit, 
## +     xend = .... [TRUNCATED]

## 
## > thisTitle <- paste0(theEconomy, ": Per Capita GDP in constant 1990 Int. GK$")
## 
## > expTrendFitted <- function(x) {
## +     ifelse(x >= theBegFit & x <= theEndFit, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > expTrendExtrap <- function(x) {
## +     ifelse(x >= theEndFit + 1 & x <= theEndSmp, exp(coef(olsFIT)[1] + 
## +         (x * coef(olsFIT)[2])), NA)
## + }
## 
## > ggplot(data = this.DF, aes(x = Year, y = perCapitaGDP)) + 
## +     geom_line(size = 2) + stat_function(data = this.DF, fun = expTrendFitted, 
## +     li .... [TRUNCATED]

## 
## > rm(olsFIT, expTrendFitted, expTrendExtrap)
rm(theEconomy, theEndSmp, theEndFit, theBegFit)

Get a final sense of the difference here by putting all these on the same graph.

theBegSmpl   <- 1950
theEndSmpl   <- 2010
theEconomies <- c("USA", "England/GB/UK", "China")
theSeries    <- "logPerCapGDP"
thisTitle    <- "log Per Capita GDP in constant 1990 Int. GK$"

source(file="./multplot.R", local=TRUE, echo=TRUE)
## 
## > getSeries <- c("Year", "Economy", theSeries)
## 
## > theAES <- aes_string(x = "Year", y = theSeries, group = "Economy", 
## +     colour = "Economy")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy %in% theEconomies) & 
## +     (MaddP.DF$Year >= theBegSmpl) & (MaddP.DF$Year <= theEndSmpl), 
## +     getSeries]
## 
## > ggplot(data = this.DF, theAES) + geom_line(size = 2) + 
## +     myTStheme + ggtitle(thisTitle)

## 
## > rm(this.DF, theAES, getSeries)
rm(thisTitle, theSeries, theEconomies, theEndSmpl, theBegSmpl)

A more useful perspective on the size of these cross-country differences come from the levels of the series themselves, not their logs.

myTStheme <- theme_classic() +
  theme(
    plot.title=element_text(size=rel(1.5)),
    legend.title=element_text(size=rel(1.5)),
    legend.text=element_text(size=rel(1.5)),
    legend.position=c(0.45,0.6), legend.justification=c(1,0),
    axis.text=element_text(size=rel(1.5)),
    axis.title=element_text(size=rel(1.5)),
    axis.title.y=element_blank()
 )
theBegSmpl   <- 1950
theEndSmpl   <- 2010
theEconomies <- c("USA", "England/GB/UK", "China")
theSeries    <- "perCapitaGDP"
thisTitle    <- "Per Capita GDP in constant 1990 Int. GK$"

source(file="./multplot.R", local=TRUE, echo=TRUE)
## 
## > getSeries <- c("Year", "Economy", theSeries)
## 
## > theAES <- aes_string(x = "Year", y = theSeries, group = "Economy", 
## +     colour = "Economy")
## 
## > this.DF <- MaddP.DF[(MaddP.DF$Economy %in% theEconomies) & 
## +     (MaddP.DF$Year >= theBegSmpl) & (MaddP.DF$Year <= theEndSmpl), 
## +     getSeries]
## 
## > ggplot(data = this.DF, theAES) + geom_line(size = 2) + 
## +     myTStheme + ggtitle(thisTitle)

## 
## > rm(this.DF, theAES, getSeries)
rm(thisTitle, theSeries, theEconomies, theEndSmpl, theBegSmpl)

Remember, however, that this is for per capita GDP and obviously therefore does not take into account the sizes of the different populations.

APPENDIX

The is is the code chunk for plotting multiple series neatly:

read_chunk("./multplot.R")
getSeries <- c("Year", "Economy", theSeries)
theAES    <- aes_string(x="Year", y=theSeries, group="Economy",
                         colour="Economy")
this.DF   <-
  MaddP.DF[(MaddP.DF$Economy %in% theEconomies) &
           (MaddP.DF$Year >= theBegSmpl) & (MaddP.DF$Year <= theEndSmpl),
           getSeries]

ggplot(data=this.DF, theAES) + geom_line(size=2) + 
       myTStheme + ggtitle(thisTitle)

rm(this.DF, theAES, getSeries)

This is the code chunk that implements the eyeballing-trend operation.

read_chunk("./eyetrend.R")
olsFIT <- lm(logPerCapGDP ~ Year,
              data=MaddP.DF[(MaddP.DF$Economy == theEconomy) &
              (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= theEndFit), ])

thisTitle <- paste0(theEconomy,
 ": log Per Capita GDP in constant 1990 Int. GK$")

this.DF <-
  MaddP.DF[(MaddP.DF$Economy == theEconomy) &
           (MaddP.DF$Year >= theBegFit) & (MaddP.DF$Year <= theEndSmp),
           c("Year", "perCapitaGDP", "logPerCapGDP")]

 ggplot(data=this.DF, aes(x=Year, y=logPerCapGDP)) + geom_line(size=2) +
 geom_segment(data=this.DF, aes(x=theBegFit, xend=theEndFit,
              y=coef(olsFIT)[1]+coef(olsFIT)[2]*theBegFit,
               yend=coef(olsFIT)[1]+coef(olsFIT)[2]*theEndFit),
              linetype=1, colour="blue", size=1.1) +
 geom_segment(data=this.DF, aes(x=theEndFit+1, xend=theEndSmp,
              y=coef(olsFIT)[1]+coef(olsFIT)[2]*(theEndFit+1),
               yend=coef(olsFIT)[1]+coef(olsFIT)[2]*theEndSmp),
              linetype=2, colour="blue", size=1.05) +
 myTStheme + ggtitle(thisTitle)

#
thisTitle      <- paste0(theEconomy,
": Per Capita GDP in constant 1990 Int. GK$")

expTrendFitted <- function(x) {ifelse (x>=theBegFit & x<=theEndFit,
  exp(coef(olsFIT)[1] + (x * coef(olsFIT)[2])), NA)
}
expTrendExtrap <- function(x) {ifelse (x>=theEndFit+1 & x<=theEndSmp,
  exp(coef(olsFIT)[1] + (x * coef(olsFIT)[2])), NA)
}
ggplot(data=this.DF, aes(x=Year, y=perCapitaGDP)) + geom_line(size=2) +
stat_function(data=this.DF, fun=expTrendFitted, linetype=1,
               colour="blue", size=1.1) +
stat_function(data=this.DF, fun=expTrendExtrap, linetype=2,
               colour="blue", size=1.05) +
myTStheme + ggtitle(thisTitle)

rm(olsFIT, expTrendFitted, expTrendExtrap)

Leave a Reply