library(foreign)
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
#Grab AJR.dta file
AJR.dt <- read.dta(file.choose())
AJR.sp <- subset(AJR.dt, AJR.dt$baseco == 1)
AJR.bcolonies <- subset(AJR.dt, AJR.dt$f_brit == 1)
AJR.bcolonies.sp <- subset(AJR.bcolonies, AJR.bcolonies$baseco == 1)

#summary
summary(AJR.dt)
##    shortnam            lat_abst         euro1900          avexpr      
##  Length:163         Min.   :0.0000   Min.   :  0.00   Min.   : 1.636  
##  Class :character   1st Qu.:0.1444   1st Qu.:  0.00   1st Qu.: 5.886  
##  Mode  :character   Median :0.2667   Median :  1.95   Median : 7.045  
##                     Mean   :0.2956   Mean   : 30.47   Mean   : 7.066  
##                     3rd Qu.:0.4469   3rd Qu.: 91.62   3rd Qu.: 8.273  
##                     Max.   :0.7222   Max.   :100.00   Max.   :10.000  
##                     NA's   :1        NA's   :9        NA's   :42      
##     logpgp95          democ1           cons1          indtime      
##  Min.   : 6.109   Min.   : 0.000   Min.   :1.000   Min.   :  5.00  
##  1st Qu.: 7.376   1st Qu.: 0.000   1st Qu.:1.000   1st Qu.: 34.00  
##  Median : 8.266   Median : 1.000   Median :3.000   Median : 37.00  
##  Mean   : 8.303   Mean   : 3.368   Mean   :3.591   Mean   : 77.17  
##  3rd Qu.: 9.216   3rd Qu.: 7.000   3rd Qu.:7.000   3rd Qu.:152.25  
##  Max.   :10.289   Max.   :10.000   Max.   :7.000   Max.   :195.00  
##  NA's   :15       NA's   :76       NA's   :75      NA's   :75      
##     democ00a         cons00a          logem4           baseco  
##  Min.   : 0.000   Min.   :1.000   Min.   :0.9361   Min.   :1   
##  1st Qu.: 0.000   1st Qu.:1.000   1st Qu.:4.2246   1st Qu.:1   
##  Median : 0.000   Median :1.000   Median :4.4427   Median :1   
##  Mean   : 1.149   Mean   :1.857   Mean   :4.5960   Mean   :1   
##  3rd Qu.: 1.000   3rd Qu.:1.000   3rd Qu.:5.6101   3rd Qu.:1   
##  Max.   :10.000   Max.   :7.000   Max.   :7.9862   Max.   :1   
##  NA's   :76       NA's   :72      NA's   :76       NA's   :99  
##      africa           rich4              asia           loghjypl      
##  Min.   :0.0000   Min.   :0.00000   Min.   :0.0000   Min.   :-3.5405  
##  1st Qu.:0.0000   1st Qu.:0.00000   1st Qu.:0.0000   1st Qu.:-2.7411  
##  Median :0.0000   Median :0.00000   Median :0.0000   Median :-1.5607  
##  Mean   :0.3067   Mean   :0.02454   Mean   :0.2577   Mean   :-1.7311  
##  3rd Qu.:1.0000   3rd Qu.:0.00000   3rd Qu.:1.0000   3rd Qu.:-0.8313  
##  Max.   :1.0000   Max.   :1.00000   Max.   :1.0000   Max.   : 0.0000  
##                                                      NA's   :40       
##     catho80         muslim80        no_cpm80          f_brit      
##  Min.   : 0.00   Min.   : 0.00   Min.   :  0.10   Min.   :0.0000  
##  1st Qu.: 0.70   1st Qu.: 0.00   1st Qu.:  4.35   1st Qu.:0.0000  
##  Median :10.60   Median : 2.05   Median : 21.00   Median :0.0000  
##  Mean   :30.04   Mean   :25.29   Mean   : 32.71   Mean   :0.3086  
##  3rd Qu.:55.17   3rd Qu.:42.25   3rd Qu.: 51.83   3rd Qu.:1.0000  
##  Max.   :97.30   Max.   :99.80   Max.   :100.00   Max.   :1.0000  
##  NA's   :1       NA's   :1       NA's   :3        NA's   :1       
##     f_french          sjlofr      
##  Min.   :0.0000   Min.   :0.0000  
##  1st Qu.:0.0000   1st Qu.:0.0000  
##  Median :0.0000   Median :0.0000  
##  Mean   :0.1481   Mean   :0.4691  
##  3rd Qu.:0.0000   3rd Qu.:1.0000  
##  Max.   :1.0000   Max.   :1.0000  
##  NA's   :1        NA's   :1
head(AJR.dt)
##   shortnam  lat_abst euro1900   avexpr logpgp95 democ1 cons1 indtime
## 1      AFG 0.3666667        0       NA       NA      1     1     195
## 2      AGO 0.1366667        8 5.363636 7.770645      0     3      20
## 3      ARE 0.2666667        0 7.181818 9.804219     NA    NA      NA
## 4      ARG 0.3777778       60 6.386364 9.133459      1     1     170
## 5      ARM 0.4444444        0       NA 7.682482     NA    NA      NA
## 6      AUS 0.3000000       98 9.318182 9.897972     10     7      94
##   democ00a cons00a   logem4 baseco africa rich4 asia   loghjypl catho80
## 1        1       1 4.540098     NA      0     0    1         NA     0.0
## 2        0       1 5.634789      1      1     0    0 -3.4112477    68.7
## 3       NA      NA       NA     NA      0     0    1         NA     0.4
## 4        3       3 4.232656      1      0     0    0 -0.8722738    91.6
## 5       NA      NA       NA     NA      0     0    1         NA     0.0
## 6       10       7 2.145931      1      0     1    0 -0.1707883    29.6
##   muslim80    no_cpm80 f_brit f_french sjlofr
## 1     99.3   0.6999969      1        0      1
## 2      0.0  11.5000038      0        0      1
## 3     94.9   4.3999987      1        0      0
## 4      0.2   5.5000014      0        0      1
## 5      0.0 100.0000000      0        0      0
## 6      0.2  46.7000008      1        0      0
olsmodel1 <- lm(logpgp95  ~ avexpr, data=AJR.dt)
olsmodel2 <- lm(logpgp95 ~ avexpr, data = AJR.sp) #sample
olsmodel3 <- lm(logpgp95 ~ avexpr + lat_abst, data = AJR.dt)
olsmodel4 <- lm(logpgp95 ~ avexpr + lat_abst, data = AJR.sp) #sample
olsmodel5 <- lm(logpgp95 ~ avexpr + lat_abst + africa + asia, AJR.dt)
olsmodel6 <- lm(logpgp95 ~ avexpr + lat_abst + africa + asia, AJR.sp) #sample

#98 gdp was not provided

model1 <- summary(olsmodel1)
model2 <- summary(olsmodel2)
model3 <- summary(olsmodel3)
model4 <- summary(olsmodel4)
model5 <- summary(olsmodel5)
model6 <- summary(olsmodel6)
model.list<-mget(grep("model[0-9]+$", ls(),value=T))
stor.r2 = rep(0,6)  
stor.obs = rep(0,6)  
stor.other = rep(0,6)  
stor.otherse = rep(0,6)  
stor.africa = rep(0,6)  
stor.africase = rep(0,6)  
stor.asiase = rep(0,6)  
stor.asia = rep(0,6) 
stor.lat = rep(0,6)  
stor.latse = rep(0,6)  
stor.avexp = rep(0,6)  
stor.avexpse = rep(0,6)  

for(i in 1:6) { 
  stor.r2[i] = model.list[[i]]$r.squared

 stor.obs[i] = model.list[[i]]$df[2]
 if (i >= 3) {
  stor.lat[i] = model.list[[i]]$coefficients[3,1]
  stor.latse[i] = model.list[[i]]$coefficients[3,2]
 } else {
  stor.lat[i] = ""
  stor.latse[i] = ""
 }
 if (i >= 5){
  stor.africa[i] = model.list[[i]]$coefficients[4,1]
  stor.asia[i] = model.list[[i]]$coefficients[5,1]
  stor.africase[i] = model.list[[i]]$coefficients[4,2]
  stor.asiase[i] = model.list[[i]]$coefficients[5,2]
 }else {
  stor.africa[i] = ""
  stor.asia[i] = ""
  stor.africase[i] = ""
  stor.asiase[i] = ""
 }
 stor.avexp[i] = model.list[[i]]$coefficients[2,1] 
 stor.avexpse[i] = model.list[[i]]$coefficients[2,2]
}
mydata <- list(stor.avexp, stor.avexpse, stor.lat, stor.latse, stor.asia, stor.asiase, stor.africa, stor.africase, stor.r2, stor.obs)
rownames <- c("Avexpr","Avexpr SE", "Latitude","Latitude SE", "Asia Dummy","Asia Dummy SE", "Africa Dummy","Africa Dummy SE", "R^2", "Number of Observations")
colnames <- c("Whole World (1)", "Base Sample (2)","Whole World (3)","Whole World (4)", "Base Sample (5)", "Base Sample (9)")
table4 <- data.frame(matrix(unlist(mydata), nrow=10, byrow=T), row.names = rownames)
colnames(table4) <- colnames
table4
##                           Whole World (1)    Base Sample (2)
## Avexpr                  0.531871348718262  0.522107029724591
## Avexpr SE              0.0406212431931922 0.0611850385365589
## Latitude                                                    
## Latitude SE                                                 
## Asia Dummy                                                  
## Asia Dummy SE                                               
## Africa Dummy                                                
## Africa Dummy SE                                             
## R^2                     0.611322113183094  0.540114955312099
## Number of Observations                109                 62
##                           Whole World (3)    Whole World (4)
## Avexpr                  0.463481598375826  0.467887063834988
## Avexpr SE              0.0554958937987159 0.0641642453206737
## Latitude                0.872161348683445   1.57688396170568
## Latitude SE             0.487673026660492  0.710310036877261
## Asia Dummy                                                  
## Asia Dummy SE                                               
## Africa Dummy                                                
## Africa Dummy SE                                             
## R^2                     0.622501742346559  0.574492946643295
## Number of Observations                108                 61
##                           Base Sample (5)    Base Sample (9)
## Avexpr                  0.394134194566942  0.405268098206822
## Avexpr SE              0.0502543171121155 0.0569335705319304
## Latitude                0.311987485534743  0.911111281595837
## Latitude SE             0.444038142899491  0.610325371116347
## Asia Dummy             -0.169742048778165 -0.587027111551517
## Asia Dummy SE            0.15315532729652  0.226668402664097
## Africa Dummy           -0.929699331963189 -0.885107490418615
## Africa Dummy SE         0.165188341405469   0.16792258836368
## R^2                     0.713427790413952   0.71351565693843
## Number of Observations                106                 59
#Begin Table 5
#Panel F Models stage `1`
sls1model1 <- lm(avexpr  ~ logem4 + f_brit + f_french, data=AJR.sp)
sls1model2 <- lm(avexpr  ~ logem4 + lat_abst + f_brit + f_french, data=AJR.sp)
sls1model3 <- lm(avexpr  ~ logem4, data=AJR.bcolonies)
sls1model4 <- lm(avexpr  ~ logem4, data=AJR.bcolonies.sp)
sls1model5 <- lm(avexpr ~ logem4 + sjlofr, AJR.sp)
sls1model6 <- lm(avexpr ~ logem4 + lat_abst + sjlofr, AJR.sp)
sls1model7 <- lm(avexpr ~ logem4 + catho80 + muslim80+ no_cpm80, AJR.sp)
sls1model8 <- lm(avexpr ~ logem4 + lat_abst + catho80 + muslim80 + no_cpm80, AJR.sp)
sls1model9 <- lm(avexpr ~ logem4 + lat_abst + f_french + sjlofr + catho80 + muslim80+ no_cpm80, AJR.sp)

s1model1 <- summary(sls1model1)
s1model2 <- summary(sls1model2)
s1model3 <- summary(sls1model3)
s1model4 <- summary(sls1model4)
s1model5 <- summary(sls1model5)
s1model6 <- summary(sls1model6)
s1model7 <- summary(sls1model7)
s1model8 <- summary(sls1model8)
s1model9 <- summary(sls1model9)

fit1 <- fitted.values(sls1model1)
fit2 <- fitted.values(sls1model2)
fit3 <- predict(sls1model3, newdata = AJR.bcolonies)
fit4 <- fitted.values(sls1model4)
fit5 <- fitted.values(sls1model5)
fit6 <- fitted.values(sls1model6)
fit7 <- fitted.values(sls1model7)
fit8 <- fitted.values(sls1model8)
fit9 <- fitted.values(sls1model9)

#Panel A Second Stage
slsmodel1 <- lm(logpgp95  ~ fit1 + f_brit + f_french, data=AJR.sp)
slsmodel2 <- lm(logpgp95  ~ fit2 + lat_abst + f_brit + f_french, data=AJR.sp)
slsmodel3 <- lm(logpgp95  ~ fit3, data=AJR.bcolonies)
slsmodel4 <- lm(logpgp95  ~ fit4, data=AJR.bcolonies.sp)
slsmodel5 <- lm(logpgp95 ~ fit5 + sjlofr, AJR.sp)
slsmodel6 <- lm(logpgp95 ~ fit6 + lat_abst + sjlofr, AJR.sp)
slsmodel7 <- lm(logpgp95 ~ fit7 + catho80 + muslim80+ no_cpm80, AJR.sp)
slsmodel8 <- lm(logpgp95 ~ fit8 + lat_abst + catho80 + muslim80 + no_cpm80, AJR.sp)
slsmodel9 <- lm(logpgp95 ~ fit9 + lat_abst + f_french + sjlofr + catho80 + muslim80 + no_cpm80, AJR.sp)

s2model1 <- summary(slsmodel1)
s2model2 <- summary(slsmodel2)
s2model3 <- summary(slsmodel3)
s2model4 <- summary(slsmodel4)
s2model5 <- summary(slsmodel5)
s2model6 <- summary(slsmodel6)
s2model7 <- summary(slsmodel7)
s2model8 <- summary(slsmodel8)
s2model9 <- summary(slsmodel9)
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
pval7 <- linearHypothesis(slsmodel7, c("catho80=0", "muslim80 = 0","no_cpm80 = 0"))[2,6]
pval8 <- linearHypothesis(slsmodel8, c("catho80=0", "muslim80 = 0","no_cpm80 = 0"))[2,6]
pval9 <- linearHypothesis(slsmodel9, c("catho80=0", "muslim80 = 0","no_cpm80 = 0"))[2,6]

#PanelC
olsmodel1 <- lm(logpgp95  ~ avexpr + f_brit + f_french, data=AJR.sp)
olsmodel2 <- lm(logpgp95  ~ avexpr + lat_abst + f_brit + f_french, data=AJR.sp)
olsmodel3 <- lm(logpgp95  ~ avexpr, data=AJR.bcolonies)
olsmodel4 <- lm(logpgp95  ~ avexpr, data=AJR.bcolonies.sp)
olsmodel5 <- lm(logpgp95 ~ avexpr + sjlofr, AJR.sp)
olsmodel6 <- lm(logpgp95 ~ avexpr + lat_abst + sjlofr, AJR.sp)
olsmodel7 <- lm(logpgp95 ~ avexpr + catho80 + muslim80+ no_cpm80, AJR.sp)
olsmodel8 <- lm(logpgp95 ~ avexpr + lat_abst + catho80 + muslim80 + no_cpm80, AJR.sp)
olsmodel9 <- lm(logpgp95 ~ avexpr + lat_abst + f_french + sjlofr + catho80 + muslim80+ no_cpm80, AJR.sp)

model1 <- summary(olsmodel1)
model2 <- summary(olsmodel2)
model3 <- summary(olsmodel3)
model4 <- summary(olsmodel4)
model5 <- summary(olsmodel5)
model6 <- summary(olsmodel6)
model7 <- summary(olsmodel7)
model8 <- summary(olsmodel7)
model9 <- summary(olsmodel9)

#Generate Table 5
model.list<-mget(grep("model[0-9]+$", ls(),value=T))
s1model.list<-mget(grep("s1model[0-9]+$", ls(),value=T))
s2model.list<-mget(grep("s2model[0-9]+$", ls(),value=T))
stor.r2 = rep(0,9)  
stor.obs = rep(0,9)  
stor.fitexpr = rep(0,9)  
stor.fitexprse = rep(0,9)
stor.mort = rep(0,9)
stor.mortse = rep(0,9)
stor.BrCol1 = rep(0,9)  
stor.BrColse1 = rep(0,9)  
stor.BrCol2 = rep(0,9)  
stor.BrColse2 = rep(0,9)
stor.FrCol1 = rep(0,9)  
stor.FrColse1 = rep(0,9) 
stor.FrCol2 = rep(0,9)  
stor.FrColse2 = rep(0,9) 
stor.FrOrig1 = rep(0,9)  
stor.FrOrigse1 = rep(0,9)  
stor.FrOrig2 = rep(0,9)  
stor.FrOrigse2 = rep(0,9)
stor.pval = rep(0,9)  
stor.lat1 = rep(0,9)  
stor.latse1 = rep(0,9)  
stor.lat2 = rep(0,9)  
stor.latse2 = rep(0,9) 
stor.avexpr = rep(0,9)  
stor.avexprse = rep(0,9)  
stor.avexpols = rep(0,9)
stor.avexpolsse = rep(0,9)

for(i in 1:9) { 
 stor.r2[i] = round(model.list[[i]]$r.squared,2)
 stor.obs[i] = round(model.list[[i]]$df[2],2)
 #Panel C
 stor.avexp[i] = round(model.list[[i]]$coefficients['avexpr',1] ,2)
 stor.avexpse[i] = round(model.list[[i]]$coefficients['avexpr',2],2)
 #Latitude
 if (i == 2 | i ==6 | i ==8 | i ==9) {
  stor.lat1[i] = round(s1model.list[[i]]$coefficients['lat_abst',1],2)
  stor.latse1[i] = round(s1model.list[[i]]$coefficients['lat_abst',2],2)
  stor.lat2[i] = round(s2model.list[[i]]$coefficients['lat_abst',1],2)
  stor.latse2[i] = round(s2model.list[[i]]$coefficients['lat_abst',2],2)
 } else {
  stor.lat1[i] = ""
  stor.latse1[i] = ""
  stor.lat2[i] = ""
  stor.latse2[i] = ""
 }
 #British Colony
 if (i == 1 | i ==2){
  stor.BrCol1[i] = round(s1model.list[[i]]$coefficients['f_brit',1], 2)
  stor.BrColse1[i] = round(s1model.list[[i]]$coefficients['f_brit',2],2)
  stor.BrCol2[i] = round(s2model.list[[i]]$coefficients['f_brit',1],2)
  stor.BrColse2[i] = round(s2model.list[[i]]$coefficients['f_brit',2],2)
 }else {
  stor.BrCol1[i] = ""
  stor.BrColse1[i] = ""
  stor.BrCol2[i] = ""
  stor.BrColse2[i] = ""
 }
 #French Colony
 if (i == 1 | i ==2 | i ==9){
  stor.FrCol1[i] = round(s1model.list[[i]]$coefficients['f_french',1],2)
  stor.FrColse1[i] = round(s1model.list[[i]]$coefficients['f_french',2],2)
  stor.FrCol2[i] = round(s2model.list[[i]]$coefficients['f_french',1],2)
  stor.FrColse2[i] = round(s2model.list[[i]]$coefficients['f_french',2],2)
 }else {
  stor.FrCol1[i] = ""
  stor.FrColse1[i] = ""
  stor.FrCol2[i] = ""
  stor.FrColse2[i] = ""
 }
 #French Origin
 if (i ==5 | i ==6 | i ==9){
  stor.FrOrig1[i] = round(s1model.list[[i]]$coefficients['sjlofr',1],2)
  stor.FrOrigse1[i] = round(s1model.list[[i]]$coefficients['sjlofr',2],2)
  stor.FrOrig2[i] = round(s2model.list[[i]]$coefficients['sjlofr',1],2)
  stor.FrOrigse2[i] = round(s2model.list[[i]]$coefficients['sjlofr',2],2)
 }else {
  stor.FrOrig1[i] = ""
  stor.FrOrigse1[i] = ""
  stor.FrOrig2[i] = ""
  stor.FrOrigse2[i] = ""
 }
 #Relivion Pval
 if (i ==7){
  stor.pval[i] = round(pval7, 4)
  } else if (i == 8) {
    stor.pval[i] = round(pval8, 4)
  }else if (i == 9){
    stor.pval[i] = round(pval9, 4)
  }else {
   stor.pval[i] = ""
  }
 #Avexpr
 stor.mort[i] = round(s1model.list[[i]]$coefficients['logem4',1],2)
 stor.mortse[i] = round(s1model.list[[i]]$coefficients['logem4',2],2)
 stor.avexpols[i] = round(model.list[[i]]$coefficients[2,1],2)
 stor.avexpolsse[i] = round(model.list[[i]]$coefficients[2,2],2)
}
panelA <- list(stor.fitexpr, stor.fitexprse, 
               stor.lat2, stor.latse2, 
               stor.BrCol2, stor.BrColse2,
               stor.FrCol2, stor.FrColse2, 
               stor.FrOrig2, stor.FrOrigse2,
               stor.pval)
panelB <- list(stor.mort, stor.mortse, 
               stor.lat1, stor.latse1, 
               stor.BrCol1, stor.BrColse1,
               stor.FrCol1, stor.FrColse1,
               stor.FrOrig1, stor.FrOrigse1,
               stor.r2)
panelC <- list(stor.avexpols, stor.avexpolsse, stor.obs)

#Panel A
rownames <- c("Fit Avexpr","Avexpr SE", 
              "Latitude","Latitude SE", 
              "Brit Col Dummy","Brit Col Dummy SE", 
              "Fr Col Dummy","Fr Col Dummy SE", 
              "Fr Orig dummy","Fr Orig dummy se", 
              "P-value")
colnames <- c("Base Sample (1)", "Base Sample (2)","Brit Col Only (3)","Brit Col Only (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)")
panelA.tb <- data.frame(matrix(unlist(panelA), nrow=11, byrow=T), row.names = rownames)
colnames(panelA.tb) <- colnames
panelA.tb
##                   Base Sample (1) Base Sample (2) Brit Col Only (3)
## Fit Avexpr                      0               0                 0
## Avexpr SE                       0               0                 0
## Latitude                                    -0.75                  
## Latitude SE                                  1.12                  
## Brit Col Dummy              -0.78            -0.8                  
## Brit Col Dummy SE            0.26            0.26                  
## Fr Col Dummy                -0.12           -0.06                  
## Fr Col Dummy SE              0.26            0.28                  
## Fr Orig dummy                                                      
## Fr Orig dummy se                                                   
## P-value                                                            
##                   Brit Col Only (4) Base Sample (5) Base Sample (6)
## Fit Avexpr                        0               0               0
## Avexpr SE                         0               0               0
## Latitude                                                      -1.13
## Latitude SE                                                    1.05
## Brit Col Dummy                                                     
## Brit Col Dummy SE                                                  
## Fr Col Dummy                                                       
## Fr Col Dummy SE                                                    
## Fr Orig dummy                                  0.89            0.96
## Fr Orig dummy se                               0.25            0.27
## P-value                                                            
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr                      0               0               0
## Avexpr SE                       0               0               0
## Latitude                                    -0.94           -1.79
## Latitude SE                                  1.15            1.34
## Brit Col Dummy                                                   
## Brit Col Dummy SE                                                
## Fr Col Dummy                                                  0.4
## Fr Col Dummy SE                                              0.31
## Fr Orig dummy                                                0.29
## Fr Orig dummy se                                             0.33
## P-value                     1e-04           1e-04           0.005
#Panel B
rownames <- c("Log Mortality","Log Mortality SE", 
              "Latitude","Latitude SE", 
              "Brit Col Dummy","Brit Col Dummy SE", 
              "Fr Col Dummy","Fr Col Dummy SE", 
              "Fr Orig dummy","Fr Orig dummy se", 
              "R2")
colnames <- c("Base Sample (1)", "Base Sample (2)","Brit Col Only (3)","Brit Col Only (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)")
panelB.tb <- data.frame(matrix(unlist(panelB), nrow=11, byrow=T), row.names = rownames)
colnames(panelB.tb) <- colnames
panelB.tb
##                   Base Sample (1) Base Sample (2) Brit Col Only (3)
## Log Mortality               -0.53           -0.43             -0.56
## Log Mortality SE             0.14            0.16              0.19
## Latitude                                     1.97                  
## Latitude SE                                  1.37                  
## Brit Col Dummy               0.63            0.55                  
## Brit Col Dummy SE            0.37            0.37                  
## Fr Col Dummy                 0.05           -0.12                  
## Fr Col Dummy SE              0.43            0.44                  
## Fr Orig dummy                                                      
## Fr Orig dummy se                                                   
## R2                           0.56            0.61              0.57
##                   Brit Col Only (4) Base Sample (5) Base Sample (6)
## Log Mortality                 -0.59           -0.54           -0.44
## Log Mortality SE               0.19            0.13            0.14
## Latitude                                                       2.08
## Latitude SE                                                     1.3
## Brit Col Dummy                                                     
## Brit Col Dummy SE                                                  
## Fr Col Dummy                                                       
## Fr Col Dummy SE                                                    
## Fr Orig dummy                                 -0.67           -0.69
## Fr Orig dummy se                               0.33            0.32
## R2                             0.65            0.57             0.6
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Log Mortality               -0.58           -0.44           -0.38
## Log Mortality SE             0.13            0.15            0.16
## Latitude                                      2.5            2.71
## Latitude SE                                  1.45            1.49
## Brit Col Dummy                                                   
## Brit Col Dummy SE                                                
## Fr Col Dummy                                                -0.16
## Fr Col Dummy SE                                              0.52
## Fr Orig dummy                                               -0.37
## Fr Orig dummy se                                             0.54
## R2                           0.69            0.69            0.72
#Panel C
rownames <- c("OLS Avexpr", "OLS Avexpr se", "Observations")
colnames <- c("Base Sample (1)", "Base Sample (2)","Brit Col Only (3)","Brit Col Only (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)")
panelC.tb <- data.frame(matrix(unlist(panelC), nrow=3, byrow=T), row.names = rownames)
colnames(panelC.tb) <- colnames
panelC.tb
##               Base Sample (1) Base Sample (2) Brit Col Only (3)
## OLS Avexpr               0.53            0.47              0.64
## OLS Avexpr se            0.07            0.07              0.09
## Observations            60.00           59.00             34.00
##               Brit Col Only (4) Base Sample (5) Base Sample (6)
## OLS Avexpr                 0.61            0.56            0.51
## OLS Avexpr se              0.09            0.06            0.07
## Observations              23.00           61.00           60.00
##               Base Sample (7) Base Sample (8) Base Sample (9)
## OLS Avexpr               0.53            0.53            0.47
## OLS Avexpr se            0.05            0.05            0.06
## Observations            59.00           59.00           56.00
print("Panel A: Two-Stage Least Squares")
## [1] "Panel A: Two-Stage Least Squares"
panelA.tb
##                   Base Sample (1) Base Sample (2) Brit Col Only (3)
## Fit Avexpr                      0               0                 0
## Avexpr SE                       0               0                 0
## Latitude                                    -0.75                  
## Latitude SE                                  1.12                  
## Brit Col Dummy              -0.78            -0.8                  
## Brit Col Dummy SE            0.26            0.26                  
## Fr Col Dummy                -0.12           -0.06                  
## Fr Col Dummy SE              0.26            0.28                  
## Fr Orig dummy                                                      
## Fr Orig dummy se                                                   
## P-value                                                            
##                   Brit Col Only (4) Base Sample (5) Base Sample (6)
## Fit Avexpr                        0               0               0
## Avexpr SE                         0               0               0
## Latitude                                                      -1.13
## Latitude SE                                                    1.05
## Brit Col Dummy                                                     
## Brit Col Dummy SE                                                  
## Fr Col Dummy                                                       
## Fr Col Dummy SE                                                    
## Fr Orig dummy                                  0.89            0.96
## Fr Orig dummy se                               0.25            0.27
## P-value                                                            
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr                      0               0               0
## Avexpr SE                       0               0               0
## Latitude                                    -0.94           -1.79
## Latitude SE                                  1.15            1.34
## Brit Col Dummy                                                   
## Brit Col Dummy SE                                                
## Fr Col Dummy                                                  0.4
## Fr Col Dummy SE                                              0.31
## Fr Orig dummy                                                0.29
## Fr Orig dummy se                                             0.33
## P-value                     1e-04           1e-04           0.005
print("Panel B: First Stage for Average Protection Against Expropriation Risk in 1985-1995")
## [1] "Panel B: First Stage for Average Protection Against Expropriation Risk in 1985-1995"
panelB.tb
##                   Base Sample (1) Base Sample (2) Brit Col Only (3)
## Log Mortality               -0.53           -0.43             -0.56
## Log Mortality SE             0.14            0.16              0.19
## Latitude                                     1.97                  
## Latitude SE                                  1.37                  
## Brit Col Dummy               0.63            0.55                  
## Brit Col Dummy SE            0.37            0.37                  
## Fr Col Dummy                 0.05           -0.12                  
## Fr Col Dummy SE              0.43            0.44                  
## Fr Orig dummy                                                      
## Fr Orig dummy se                                                   
## R2                           0.56            0.61              0.57
##                   Brit Col Only (4) Base Sample (5) Base Sample (6)
## Log Mortality                 -0.59           -0.54           -0.44
## Log Mortality SE               0.19            0.13            0.14
## Latitude                                                       2.08
## Latitude SE                                                     1.3
## Brit Col Dummy                                                     
## Brit Col Dummy SE                                                  
## Fr Col Dummy                                                       
## Fr Col Dummy SE                                                    
## Fr Orig dummy                                 -0.67           -0.69
## Fr Orig dummy se                               0.33            0.32
## R2                             0.65            0.57             0.6
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Log Mortality               -0.58           -0.44           -0.38
## Log Mortality SE             0.13            0.15            0.16
## Latitude                                      2.5            2.71
## Latitude SE                                  1.45            1.49
## Brit Col Dummy                                                   
## Brit Col Dummy SE                                                
## Fr Col Dummy                                                -0.16
## Fr Col Dummy SE                                              0.52
## Fr Orig dummy                                               -0.37
## Fr Orig dummy se                                             0.54
## R2                           0.69            0.69            0.72
print("Panel C: Ordinary Least Squares")
## [1] "Panel C: Ordinary Least Squares"
panelC.tb
##               Base Sample (1) Base Sample (2) Brit Col Only (3)
## OLS Avexpr               0.53            0.47              0.64
## OLS Avexpr se            0.07            0.07              0.09
## Observations            60.00           59.00             34.00
##               Brit Col Only (4) Base Sample (5) Base Sample (6)
## OLS Avexpr                 0.61            0.56            0.51
## OLS Avexpr se              0.09            0.06            0.07
## Observations              23.00           61.00           60.00
##               Base Sample (7) Base Sample (8) Base Sample (9)
## OLS Avexpr               0.53            0.53            0.47
## OLS Avexpr se            0.05            0.05            0.06
## Observations            59.00           59.00           56.00
#Begin Table 8
#Panel B Models stage `1`
sls1model1 <- lm(avexpr  ~ euro1900, data=AJR.sp)
sls1model2 <- lm(avexpr  ~ euro1900 + lat_abst, data=AJR.sp)
sls1model3 <- lm(avexpr  ~ cons00a, data=AJR.sp)
sls1model4 <- lm(avexpr  ~ cons00a + lat_abst, data=AJR.sp)
sls1model5 <- lm(avexpr  ~ democ00a, data=AJR.sp)
sls1model6 <- lm(avexpr  ~ democ00a + lat_abst, data=AJR.sp)
sls1model7 <- lm(avexpr  ~ cons1, data=AJR.sp)
sls1model8 <- lm(avexpr  ~ cons1 + lat_abst, data=AJR.sp)
sls1model9 <- lm(avexpr  ~ democ1, data=AJR.sp)
sls1model10 <- lm(avexpr  ~ democ1 + lat_abst, data=AJR.sp)

s1model1 <- summary(sls1model1)
s1model2 <- summary(sls1model2)
s1model3 <- summary(sls1model3)
s1model4 <- summary(sls1model4)
s1model5 <- summary(sls1model5)
s1model6 <- summary(sls1model6)
s1model7 <- summary(sls1model7)
s1model8 <- summary(sls1model8)
s1model9 <- summary(sls1model9)
s1model10 <- summary(sls1model10)

fit1 <- predict(sls1model1, newdata = AJR.sp)
fit2 <- predict(sls1model2, newdata = AJR.sp)
fit3 <- predict(sls1model3, newdata = AJR.sp)
fit4 <- predict(sls1model4, newdata = AJR.sp)
fit5 <- predict(sls1model5, newdata = AJR.sp)
fit6 <- predict(sls1model6, newdata = AJR.sp)
fit7 <- predict(sls1model7, newdata = AJR.sp)
fit8 <- predict(sls1model8, newdata = AJR.sp)
fit9 <- predict(sls1model9, newdata = AJR.sp)
fit10 <- predict(sls1model10, newdata = AJR.sp)

#Panel A Second Stage
slsmodel1 <- lm(logpgp95  ~ fit1, data=AJR.sp)
slsmodel2 <- lm(logpgp95  ~ fit2 + lat_abst, data=AJR.sp)
slsmodel3 <- lm(logpgp95  ~ fit3, data=AJR.sp)
slsmodel4 <- lm(logpgp95  ~ fit4 + lat_abst, data=AJR.sp)
slsmodel5 <- lm(logpgp95 ~ fit5, AJR.sp)
slsmodel6 <- lm(logpgp95 ~ fit6 + lat_abst, AJR.sp)
slsmodel7 <- lm(logpgp95 ~ fit7, AJR.sp)
slsmodel8 <- lm(logpgp95 ~ fit8 + lat_abst, AJR.sp)
slsmodel9 <- lm(logpgp95 ~ fit9, AJR.sp)
slsmodel10 <- lm(logpgp95 ~ fit10 + lat_abst, AJR.sp)

s2model1 <- summary(slsmodel1)
s2model2 <- summary(slsmodel2)
s2model3 <- summary(slsmodel3)
s2model4 <- summary(slsmodel4)
s2model5 <- summary(slsmodel5)
s2model6 <- summary(slsmodel6)
s2model7 <- summary(slsmodel7)
s2model8 <- summary(slsmodel8)
s2model9 <- summary(slsmodel9)
s2model10 <- summary(slsmodel10)

#Panel D 
olsmodel1 <- lm(logpgp95  ~ fit1 + logem4, data=AJR.sp)
olsmodel2 <- lm(logpgp95  ~ fit2 + logem4 + lat_abst, data=AJR.sp)
olsmodel3 <- lm(logpgp95  ~ fit3 + logem4, data=AJR.sp)
olsmodel4 <- lm(logpgp95  ~ fit4 + logem4 + lat_abst, data=AJR.sp)
olsmodel5 <- lm(logpgp95 ~ fit5 + logem4, AJR.sp)
olsmodel6 <- lm(logpgp95 ~ fit6 + logem4 + lat_abst, AJR.sp)
olsmodel7 <- lm(logpgp95 ~ fit7 + logem4, AJR.sp)
olsmodel8 <- lm(logpgp95 ~ fit8 + logem4 + lat_abst, AJR.sp)
olsmodel9 <- lm(logpgp95 ~ fit9 + logem4, AJR.sp)
olsmodel10 <- lm(logpgp95 ~ fit10 + logem4 + lat_abst, AJR.sp)

dmodel1 <- summary(olsmodel1)
dmodel2 <- summary(olsmodel2)
dmodel3 <- summary(olsmodel3)
dmodel4 <- summary(olsmodel4)
dmodel5 <- summary(olsmodel5)
dmodel6 <- summary(olsmodel6)
dmodel7 <- summary(olsmodel7)
dmodel8 <- summary(olsmodel8)
dmodel9 <- summary(olsmodel9)
dmodel10 <- summary(olsmodel10)

#Panel C
#Predictions
#A)
pA1 <- predict(slsmodel1)
pA2 <- predict(slsmodel2)
pA3 <- predict(slsmodel3)
pA4 <- predict(slsmodel4)
pA5 <- predict(slsmodel5)
pA6 <- predict(slsmodel6)
pA7 <- predict(slsmodel7)
pA8 <- predict(slsmodel8)
pA9 <- predict(slsmodel9)
pA10 <- predict(slsmodel10)
#B)
pB1 <- predict(slsmodel1)
pB2 <- predict(slsmodel2)
pB3 <- predict(slsmodel3)
pB4 <- predict(slsmodel4)
pB5 <- predict(slsmodel5)
pB6 <- predict(slsmodel6)
pB7 <- predict(slsmodel7)
pB8 <- predict(slsmodel8)
pB9 <- predict(slsmodel9)
pB10 <- predict(slsmodel10)

#Chisq
chi1 <- chisq.test(pA1, pB1)$p.value
## Warning in chisq.test(pA1, pB1): Chi-squared approximation may be incorrect
chi2 <- chisq.test(pA2, pB2)$p.value
## Warning in chisq.test(pA2, pB2): Chi-squared approximation may be incorrect
chi3 <- chisq.test(pA3, pB3)$p.value
## Warning in chisq.test(pA3, pB3): Chi-squared approximation may be incorrect
chi4 <- chisq.test(pA4, pB4)$p.value
## Warning in chisq.test(pA4, pB4): Chi-squared approximation may be incorrect
chi5 <- chisq.test(pA5, pB5)$p.value
## Warning in chisq.test(pA5, pB5): Chi-squared approximation may be incorrect
chi6 <- chisq.test(pA6, pB6)$p.value
## Warning in chisq.test(pA6, pB6): Chi-squared approximation may be incorrect
chi7 <- chisq.test(pA7, pB7)$p.value
## Warning in chisq.test(pA7, pB7): Chi-squared approximation may be incorrect
chi8 <- chisq.test(pA8, pB8)$p.value
## Warning in chisq.test(pA8, pB8): Chi-squared approximation may be incorrect
chi9 <- chisq.test(pA9, pB9)$p.value
## Warning in chisq.test(pA9, pB9): Chi-squared approximation may be incorrect
chi10 <- chisq.test(pA10, pB10)$p.value
## Warning in chisq.test(pA10, pB10): Chi-squared approximation may be
## incorrect
#Generate Table 8
model.list<-mget(grep("dmodel[0-9]+$", ls(),value=T))
s1model.list<-mget(grep("s1model[0-9]+$", ls(),value=T))
s2model.list<-mget(grep("s2model[0-9]+$", ls(),value=T))
chi.list <- mget(grep("chi[0-9]", ls(),value=T))
stor.r2 = rep(0,10)  
stor.avexprA = rep(0,10)  
stor.avexprseA = rep(0,10)
stor.avexprD = rep(0,10)  
stor.avexprseD = rep(0,10)
stor.pval = rep(0,10)  
stor.latA = rep(0,10)  
stor.latseA = rep(0,10)  
stor.latD = rep(0,10)  
stor.latseD = rep(0,10) 
stor.logD = rep(0,10)
stor.logseD = rep(0,10)
stor.chisq = rep(0,10)
stor.Euro = rep(0,10)
stor.Eurose = rep(0,10)
stor.Demo = rep(0,10)
stor.Demose = rep(0,10)
stor.Demo1 = rep(0,10)
stor.Demose1 = rep(0,10)
stor.Cons = rep(0,10)
stor.Consse = rep(0,10)
stor.Cons1 = rep(0,10)
stor.Consse1 = rep(0,10)

for(i in 1:10) { 
 stor.r2[i] = round(s1model.list[[i]]$r.squared,2)
 #Panel A avexpr
 stor.avexprA[i] = round(s2model.list[[i]]$coefficients[2,1] ,2)
 stor.avexprseA[i] = round(s2model.list[[i]]$coefficients[2,2],2)
 #Panel D avexpr
 stor.avexprD[i] = round(model.list[[i]]$coefficients['logem4',1] ,2)
 stor.avexprseD[i] = round(model.list[[i]]$coefficients['logem4',2],2)
 stor.logD[i] = round(model.list[[i]]$coefficients['logem4',1],2)
 stor.logseD[i] = round(model.list[[i]]$coefficients['logem4',2],2)
 #Panel C chisq
 stor.chisq[i] = chi.list[[i]]
 #Latitude
 if (i == 2 | i ==3 | i ==5 | i ==7 | i ==9) {
  stor.latA[i] = round(s1model.list[[i]]$coefficients['lat_abst',1],2)
  stor.latseA[i] = round(s1model.list[[i]]$coefficients['lat_abst',2],2)
  stor.latD[i] = round(model.list[[i]]$coefficients['lat_abst',1],2)
  stor.latseD[i] = round(model.list[[i]]$coefficients['lat_abst',2],2)
 } else {
  stor.lat1[i] = ""
  stor.latse1[i] = ""
  stor.lat2[i] = ""
  stor.latse2[i] = ""
 }
 if (i == 1 | i == 3) {
  stor.Euro[i] =  round(s1model.list[[i]]$coefficients['euro1900',1],2)
  stor.Eurose[i] =  round(s1model.list[[i]]$coefficients['euro1900',2],2)
 } else {
  stor.Euro[i] =  ""
  stor.Eurose[i] =  ""
 }
 if (i == 4 | i == 5) {
  stor.Cons[i] =  round(s1model.list[[i]]$coefficients['cons00a',1],2)
  stor.Consse[i] =  round(s1model.list[[i]]$coefficients['cons00a',2],2)
 } else {
  stor.Cons[i] =  ""
  stor.Consse[i] =  ""
 }
 if (i == 6 | i == 7) {
  stor.Demo[i] =  round(s1model.list[[i]]$coefficients['democ00a',1],2)
  stor.Demose[i] =  round(s1model.list[[i]]$coefficients['democ00a',2],2)
 } else {
  stor.Demo[i] =  ""
  stor.Demose[i] =  ""
 }
 if (i == 8 | i == 9) {
  stor.Cons1[i] =  round(s1model.list[[i]]$coefficients['cons1',1],2)
  stor.Consse1[i] =  round(s1model.list[[i]]$coefficients['cons1',2],2)
 } else {
  stor.Cons1[i] =  ""
  stor.Consse1[i] =  ""
 }
 if (i == 2 | i == 10) {
  stor.Demo1[i] =  round(s1model.list[[i]]$coefficients['democ1',1],2)
  stor.Demose1[i] =  round(s1model.list[[i]]$coefficients['democ1',2],2)
 } else {
  stor.Demo1[i] =  ""
  stor.Demose1[i] =  ""
 }
}
panelA <- list(stor.avexprA, stor.avexprseA, stor.latA, stor.latseA)
panelB <- list(stor.Euro, stor.Eurose, stor.Cons, stor.Consse, stor.Demo, stor.Demose, stor.Cons1, stor.Consse1, stor.Demo1, stor.Demose1, stor.r2)
panelC <- list(stor.chisq)
panelD <- list(stor.avexprD, stor.avexprseD,stor.logD, stor.logseD, stor.latD, stor.latseD)

#Panel A
rownames <- c("Fit Avexpr","Avexpr SE", 
              "Latitude","Latitude SE")
colnames <- c("Base Sample (1)", "Base Sample (2)","Base Sample (3)","Base Sample (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)", "Base Sample (10)")
panelA.tb <- data.frame(matrix(unlist(panelA), nrow=4, byrow=T), row.names = rownames)
colnames(panelA.tb) <- colnames
panelA.tb
##             Base Sample (1) Base Sample (2) Base Sample (3)
## Fit Avexpr             0.87            0.38            0.92
## Avexpr SE              0.12            0.23            0.17
## Latitude               0.00            3.65            0.76
## Latitude SE            0.00            1.29            1.54
##             Base Sample (4) Base Sample (5) Base Sample (6)
## Fit Avexpr             0.71            0.68            0.72
## Avexpr SE              0.17            0.23            0.16
## Latitude               0.00            2.35            0.00
## Latitude SE            0.00            1.43            0.00
##             Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr             0.69            0.34            0.33
## Avexpr SE              0.21            0.31            0.29
## Latitude               1.73            0.00            4.01
## Latitude SE            1.49            0.00            1.32
##             Base Sample (10)
## Fit Avexpr              0.42
## Avexpr SE               0.23
## Latitude                0.00
## Latitude SE             0.00
#Panel B
rownames <- c("Euro 1900","Euro 1900 SE", 
              "Constraint 1900","Cons 1900 SE", 
              "Democ 1900","Democ 1900 SE", 
              "Cons first yr","Cons first yr SE", 
              "Democ first yr","Democ first yr se", 
              "R2")
colnames <- c("Base Sample (1)", "Base Sample (2)","Base Sample (3)","Base Sample (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)", "Base Sample (10)")
panelB.tb <- data.frame(matrix(unlist(panelB), nrow=11, byrow=T), row.names = rownames)
colnames(panelB.tb) <- colnames
panelB.tb
##                   Base Sample (1) Base Sample (2) Base Sample (3)
## Euro 1900                    0.03                            0.03
## Euro 1900 SE                 0.01                            0.01
## Constraint 1900                                                  
## Cons 1900 SE                                                     
## Democ 1900                                                       
## Democ 1900 SE                                                    
## Cons first yr                                                    
## Cons first yr SE                                                 
## Democ first yr                               0.15                
## Democ first yr se                            0.05                
## R2                            0.3            0.25             0.3
##                   Base Sample (4) Base Sample (5) Base Sample (6)
## Euro 1900                                                        
## Euro 1900 SE                                                     
## Constraint 1900              0.32            0.26                
## Cons 1900 SE                 0.08            0.09                
## Democ 1900                                                   0.24
## Democ 1900 SE                                                0.06
## Cons first yr                                                    
## Cons first yr SE                                                 
## Democ first yr                                                   
## Democ first yr se                                                
## R2                            0.2            0.24            0.24
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Euro 1900                                                        
## Euro 1900 SE                                                     
## Constraint 1900                                                  
## Cons 1900 SE                                                     
## Democ 1900                    0.2                                
## Democ 1900 SE                0.07                                
## Cons first yr                                0.18            0.17
## Cons first yr SE                             0.08            0.07
## Democ first yr                                                   
## Democ first yr se                                                
## R2                           0.26            0.08            0.21
##                   Base Sample (10)
## Euro 1900                         
## Euro 1900 SE                      
## Constraint 1900                   
## Cons 1900 SE                      
## Democ 1900                        
## Democ 1900 SE                     
## Cons first yr                     
## Cons first yr SE                  
## Democ first yr                0.16
## Democ first yr se             0.05
## R2                            0.15
#Panel C
rownames <- c("p-value from chi-sq")
colnames <- c("Base Sample (1)", "Base Sample (2)","Base Sample (3)","Base Sample (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)", "Base Sample (10)")
panelC.tb <- data.frame(matrix(unlist(panelC), nrow=1, byrow=T), row.names = rownames)
colnames(panelC.tb) <- colnames
panelC.tb
##                     Base Sample (1) Base Sample (2) Base Sample (3)
## p-value from chi-sq    1.075941e-89    8.346742e-10    7.248699e-10
##                     Base Sample (4) Base Sample (5) Base Sample (6)
## p-value from chi-sq    5.785881e-42    1.692296e-15    1.631526e-63
##                     Base Sample (7) Base Sample (8) Base Sample (9)
## p-value from chi-sq    8.346742e-10    6.012272e-49    8.042762e-10
##                     Base Sample (10)
## p-value from chi-sq     1.631526e-63
#Panel D
rownames <- c("Fit Avexpr","Avexpr SE",
              "Log Mortality", "Log Mortality Se",
              "Latitude","Latitude SE")
colnames <- c("Base Sample (1)", "Base Sample (2)","Base Sample (3)","Base Sample (4)", "Base Sample (5)","Base Sample (6)","Base Sample (7)","Base Sample (8)", "Base Sample (9)", "Base Sample (10)")
panelD.tb <- data.frame(matrix(unlist(panelD), nrow=6, byrow=T), row.names = rownames)
colnames(panelD.tb) <- colnames
panelD.tb
##                  Base Sample (1) Base Sample (2) Base Sample (3)
## Fit Avexpr                 -0.37           -0.46           -0.37
## Avexpr SE                   0.08            0.09            0.08
## Log Mortality              -0.37           -0.46           -0.37
## Log Mortality Se            0.08            0.09            0.08
## Latitude                    0.00            0.94           -0.83
## Latitude SE                 0.00            1.08            0.90
##                  Base Sample (4) Base Sample (5) Base Sample (6)
## Fit Avexpr                 -0.45           -0.42           -0.43
## Avexpr SE                   0.09            0.10            0.09
## Log Mortality              -0.45           -0.42           -0.43
## Log Mortality Se            0.09            0.10            0.09
## Latitude                    0.00            0.41            0.00
## Latitude SE                 0.00            1.09            0.00
##                  Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr                 -0.41           -0.53           -0.47
## Avexpr SE                   0.10            0.08            0.09
## Log Mortality              -0.41           -0.53           -0.47
## Log Mortality Se            0.10            0.08            0.09
## Latitude                    0.25            0.00            1.03
## Latitude SE                 1.05            0.00            1.23
##                  Base Sample (10)
## Fit Avexpr                  -0.52
## Avexpr SE                    0.08
## Log Mortality               -0.52
## Log Mortality Se             0.08
## Latitude                     0.00
## Latitude SE                  0.00
print("Panel A: Two-Stage Least Squares")
## [1] "Panel A: Two-Stage Least Squares"
panelA.tb
##             Base Sample (1) Base Sample (2) Base Sample (3)
## Fit Avexpr             0.87            0.38            0.92
## Avexpr SE              0.12            0.23            0.17
## Latitude               0.00            3.65            0.76
## Latitude SE            0.00            1.29            1.54
##             Base Sample (4) Base Sample (5) Base Sample (6)
## Fit Avexpr             0.71            0.68            0.72
## Avexpr SE              0.17            0.23            0.16
## Latitude               0.00            2.35            0.00
## Latitude SE            0.00            1.43            0.00
##             Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr             0.69            0.34            0.33
## Avexpr SE              0.21            0.31            0.29
## Latitude               1.73            0.00            4.01
## Latitude SE            1.49            0.00            1.32
##             Base Sample (10)
## Fit Avexpr              0.42
## Avexpr SE               0.23
## Latitude                0.00
## Latitude SE             0.00
print("Panel B: First Stage for Average Protection Against Expropriation Risk")
## [1] "Panel B: First Stage for Average Protection Against Expropriation Risk"
panelB.tb
##                   Base Sample (1) Base Sample (2) Base Sample (3)
## Euro 1900                    0.03                            0.03
## Euro 1900 SE                 0.01                            0.01
## Constraint 1900                                                  
## Cons 1900 SE                                                     
## Democ 1900                                                       
## Democ 1900 SE                                                    
## Cons first yr                                                    
## Cons first yr SE                                                 
## Democ first yr                               0.15                
## Democ first yr se                            0.05                
## R2                            0.3            0.25             0.3
##                   Base Sample (4) Base Sample (5) Base Sample (6)
## Euro 1900                                                        
## Euro 1900 SE                                                     
## Constraint 1900              0.32            0.26                
## Cons 1900 SE                 0.08            0.09                
## Democ 1900                                                   0.24
## Democ 1900 SE                                                0.06
## Cons first yr                                                    
## Cons first yr SE                                                 
## Democ first yr                                                   
## Democ first yr se                                                
## R2                            0.2            0.24            0.24
##                   Base Sample (7) Base Sample (8) Base Sample (9)
## Euro 1900                                                        
## Euro 1900 SE                                                     
## Constraint 1900                                                  
## Cons 1900 SE                                                     
## Democ 1900                    0.2                                
## Democ 1900 SE                0.07                                
## Cons first yr                                0.18            0.17
## Cons first yr SE                             0.08            0.07
## Democ first yr                                                   
## Democ first yr se                                                
## R2                           0.26            0.08            0.21
##                   Base Sample (10)
## Euro 1900                         
## Euro 1900 SE                      
## Constraint 1900                   
## Cons 1900 SE                      
## Democ 1900                        
## Democ 1900 SE                     
## Cons first yr                     
## Cons first yr SE                  
## Democ first yr                0.16
## Democ first yr se             0.05
## R2                            0.15
print("Panel C: Results from Overidentification Test")
## [1] "Panel C: Results from Overidentification Test"
panelC.tb
##                     Base Sample (1) Base Sample (2) Base Sample (3)
## p-value from chi-sq    1.075941e-89    8.346742e-10    7.248699e-10
##                     Base Sample (4) Base Sample (5) Base Sample (6)
## p-value from chi-sq    5.785881e-42    1.692296e-15    1.631526e-63
##                     Base Sample (7) Base Sample (8) Base Sample (9)
## p-value from chi-sq    8.346742e-10    6.012272e-49    8.042762e-10
##                     Base Sample (10)
## p-value from chi-sq     1.631526e-63
print("Panel D: Second Stage with Log Mortality as Exogenous Variable ")
## [1] "Panel D: Second Stage with Log Mortality as Exogenous Variable "
panelD.tb
##                  Base Sample (1) Base Sample (2) Base Sample (3)
## Fit Avexpr                 -0.37           -0.46           -0.37
## Avexpr SE                   0.08            0.09            0.08
## Log Mortality              -0.37           -0.46           -0.37
## Log Mortality Se            0.08            0.09            0.08
## Latitude                    0.00            0.94           -0.83
## Latitude SE                 0.00            1.08            0.90
##                  Base Sample (4) Base Sample (5) Base Sample (6)
## Fit Avexpr                 -0.45           -0.42           -0.43
## Avexpr SE                   0.09            0.10            0.09
## Log Mortality              -0.45           -0.42           -0.43
## Log Mortality Se            0.09            0.10            0.09
## Latitude                    0.00            0.41            0.00
## Latitude SE                 0.00            1.09            0.00
##                  Base Sample (7) Base Sample (8) Base Sample (9)
## Fit Avexpr                 -0.41           -0.53           -0.47
## Avexpr SE                   0.10            0.08            0.09
## Log Mortality              -0.41           -0.53           -0.47
## Log Mortality Se            0.10            0.08            0.09
## Latitude                    0.25            0.00            1.03
## Latitude SE                 1.05            0.00            1.23
##                  Base Sample (10)
## Fit Avexpr                  -0.52
## Avexpr SE                    0.08
## Log Mortality               -0.52
## Log Mortality Se             0.08
## Latitude                     0.00
## Latitude SE                  0.00
#Notes on Table 8:
#I was unable to get the exact numbers it seems that the figures in
#the first stage did line up with the data and outputs. I am unsure if 
#this is the result of the data being different or if I missed a step in their methodology.