Fixed Effects Table

Imports

library(plm)
library(stargazer)
load("output/models.Rdata")

Long Run Effects

Calculate the long run effects for the different models with this Formula:

\[ \frac{ \hat\beta }{1- \sum_{j=1}^p \hat\gamma_j} \]

beta_hat <- coef(model1)["dem"]
gamma_hat <- coef(model1)["lag1"]

long_run_effect_1 <- beta_hat / (1 - sum(gamma_hat))
beta_hat <- coef(model2)["dem"]
gamma_hat <- (coef(model2)[2:3])

long_run_effect_2 <- beta_hat / (1 - sum(gamma_hat))
beta_hat <- coef(model3)["dem"]
gamma_hat <- (coef(model3)[2:5])

long_run_effect_3 <- beta_hat / (1 - sum(gamma_hat))
beta_hat <- coef(model4)["dem"]
gamma_hat <- (coef(model4)[2:9])

long_run_effect_4 <- beta_hat / (1 - sum(gamma_hat))
lre <- c(long_run_effect_1, long_run_effect_2, long_run_effect_3, long_run_effect_4)
lre <- round(lre, 3)
lre
   dem    dem    dem    dem 
35.587 19.599 21.240 22.008 

Persistence

Calculate the persistence of Democracy for the different models with this Formula:

\[ D_{pers} = \sum_{j=1}^p \hat\gamma_j \]

pers1 <- sum(coef(model1)[2])
pers2 <- sum(coef(model2)[2:3])
pers3 <- sum(coef(model3)[2:5])
pers4 <- sum(coef(model4)[2:9])

pers <- c(pers1, pers2, pers3, pers4)
pers <- round(pers, 3)
pers
[1] 0.973 0.967 0.963 0.960

Effect after 25 years

Calculate the short run effects fro 1-30 years:

Formula taken from Stata Code File (Table2_final.do, lines 32-87 + following)

\[ effect_{t} = \hat\beta + \sum_{j=1}^p \hat\gamma_j * effect_{t-j} \]

Model 1

dem_shortrun <- coef(model1)["dem"]
lag1 <- (coef(model1)[2])
effect1 <- dem_shortrun
effect2 <- (effect1 * lag1) + dem_shortrun

effects <- c(effect1, effect2)
for (i in 3:30) {
  eff <- (effects[i-1] * lag1) + effects[1]
  effects <- c(effects, eff)
}
eff_25_1 <- effects[25]
eff_25_1
     dem 
17.79084 

Model 2

dem_shortrun <- coef(model2)["dem"]
lag1 <- (coef(model2)[2])
lag2 <- (coef(model2)[3])
effect1 <- dem_shortrun
effect2 <- (effect1 * lag1) + dem_shortrun
effect3 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun

effects <- c(effect1, effect2, effect3)
for (i in 4:30) {
  eff <- (effects[i-1] * lag1) + (effects[i-2] * lag2) + dem_shortrun
  effects <- c(effects, eff)
}
eff_25_2 <- effects[25]
eff_25_2
     dem 
13.80001 

Model 3

dem_shortrun <- coef(model3)["dem"]
lag1 <- (coef(model3)[2])
lag2 <- (coef(model3)[3])
lag3 <- (coef(model3)[4])
lag4 <- (coef(model3)[5])
effect1 <- dem_shortrun
effect2 <- (effect1 * lag1) + dem_shortrun
effect3 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun
effect4 <- (effect3 * lag1) + (effect2 * lag2) + (effect1 * lag3) + dem_shortrun

effects <- c(effect1,effect2, effect3, effect4)
for (i in 5:30) {
  eff <- (effects[i-1] * lag1) + (effects[i-2] * lag2) + (effects[i-3] * lag3) + (effects[i-4] * lag4) + dem_shortrun
  effects <- c(effects, eff)
}
eff_25_3 <- effects[25]
eff_25_3
     dem 
16.89525 

Model 4

dem_shortrun <- coef(model4)["dem"]
lag1 <- (coef(model4)[2])
lag2 <- (coef(model4)[3])
lag3 <- (coef(model4)[4])
lag4 <- (coef(model4)[5])
lag5 <- (coef(model4)[6])
lag6 <- (coef(model4)[7])
lag7 <- (coef(model4)[8])
lag8 <- (coef(model4)[9])
effect1 <- dem_shortrun
effect2 <- (effect1 * lag1) + dem_shortrun
effect3 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun
effect4 <- (effect3 * lag1) + (effect2 * lag2) + (effect1 * lag3) + dem_shortrun
effect5 <- (effect4 * lag1) + (effect3 * lag2) + (effect2 * lag3) + (effect1 * lag4) + dem_shortrun
effect6 <- (effect5 * lag1) + (effect4 * lag2) + (effect3 * lag3) + (effect2 * lag4) + (effect1 * lag5) + dem_shortrun
effect7 <- (effect6 * lag1) + (effect5 * lag2) + (effect4 * lag3) + (effect3 * lag4) + (effect2 * lag5) + (effect1 * lag6) + dem_shortrun
effect8 <- (effect7 * lag1) + (effect6 * lag2) + (effect5 * lag3) + (effect4 * lag4) + (effect3 * lag5) + (effect2 * lag6) + (effect1 * lag7) + dem_shortrun

effects <- c(effect1, effect2, effect3, effect4, effect5, effect6, effect7, effect8)
for (i in 9:30) {
  eff <- (effects[i-1] * lag1) + (effects[i-2] * lag2) + (effects[i-3] * lag3) + (effects[i-4] * lag4) + (effects[i-5] * lag5) + (effects[i-6] * lag6) + (effects[i-7] * lag7) + (effects[i-8] * lag8) + dem_shortrun
  effects <- c(effects, eff)
}
eff_25_4 <- effects[25]
eff_25_4
     dem 
17.71534 
eff_25 <- c(eff_25_1, eff_25_2, eff_25_3, eff_25_4)
eff_25 <- round(eff_25, 3)
eff_25
   dem    dem    dem    dem 
17.791 13.800 16.895 17.715 

Table FE

Recreating the Table 2 from the ANRR Paper with the stargazer package and the models from above

with

  • persistence for each model

  • long run effect

  • effect after 25 years

  • observations

  • countries in sample

  • and the standard regression output

models <- list(model1, model2, model3, model4)

stargazer(models, 
          type = "html", #change to "text" for easy viewing in console
          title = "Effect of Democracy on (Log) GDP per Capita", # title
          dep.var.labels = "Log GDP per Capita",  
          covariate.labels = c("Democracy"),
          omit.stat = c("ser", "f","adj.rsq"), 
          keep.stat = c("n", "N"), #keep observations,
          omit = c("lag6", "lag7", "lag8"),
          model.numbers = FALSE, # remove model numbers (are the same as column labels)
          column.labels = c("(1)", "(2)", "(3)", "(4)"), # add column labels
          add.lines = list( # add lines for persistence, long run effect and effect after 25 years
            c("Persistence: ", pers), 
            c("Long run effect: ", lre),
            c("Effect after 25 years: ", eff_25)
            ),
          notes = "The reported coefficient on democracy is multiplied by 100. Replication of Table 2 in ANRR (2019)",
          notes.append = FALSE # add notes to the end of the table
          )
Effect of Democracy on (Log) GDP per Capita
Dependent variable:
Log GDP per Capita
(1) (2) (3) (4)
Democracy 0.973*** 0.651*** 0.787*** 0.887***
(0.240) (0.229) (0.228) (0.239)
lag1 0.973*** 1.266*** 1.238*** 1.233***
(0.003) (0.012) (0.013) (0.013)
lag2 -0.300*** -0.207*** -0.214***
(0.012) (0.020) (0.021)
lag3 -0.026 -0.021
(0.019) (0.021)
lag4 -0.043*** -0.039*
(0.012) (0.020)
lag5 -0.019
(0.020)
Persistence: 0.973 0.967 0.963 0.96
Long run effect: 35.587 19.599 21.24 22.008
Effect after 25 years: 17.791 13.8 16.895 17.715
Observations 6,790 6,642 6,336 5,688
Note: The reported coefficient on democracy is multiplied by 100. Replication of Table 2 in ANRR (2019)

Save the table as a tex file

stargazer(models, 
          type = "latex", #change to "text" for easy viewing in console
          out = "output/table_fe.tex",
          title = "Effect of Democracy on (Log) GDP per Capita", # title
          dep.var.labels = "Log GDP per Capita",  
          covariate.labels = c("Democracy"),
          omit.stat = c("ser", "f","adj.rsq"), 
          keep.stat = c("n", "N"), #keep observations,
          omit = c("lag6", "lag7", "lag8"),
          model.numbers = FALSE, # remove model numbers (are the same as column labels)
          column.labels = c("(1)", "(2)", "(3)", "(4)"), # add column labels
          add.lines = list( # add lines for persistence, long run effect and effect after 25 years
            c("Persistence: ", pers), 
            c("Long run effect: ", lre),
            c("Effect after 25 years: ", eff_25)
            ),
          notes = "The reported coefficient on democracy is multiplied by 100. Replication of Table 2 in ANRR (2019)",
          notes.append = FALSE # add notes to the end of the table
          )
% Table created by stargazer v.5.2.3 by Marek Hlavac, Social Policy Institute. E-mail: marek.hlavac at gmail.com % Date and time: Wed, Dec 06, 2023 - 17:54:37