library(plm)
library(stargazer)
Fixed Effects Table
Imports
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} \]
<- coef(model1)["dem"]
beta_hat <- coef(model1)["lag1"]
gamma_hat
<- beta_hat / (1 - sum(gamma_hat)) long_run_effect_1
<- coef(model2)["dem"]
beta_hat <- (coef(model2)[2:3])
gamma_hat
<- beta_hat / (1 - sum(gamma_hat)) long_run_effect_2
<- coef(model3)["dem"]
beta_hat <- (coef(model3)[2:5])
gamma_hat
<- beta_hat / (1 - sum(gamma_hat)) long_run_effect_3
<- coef(model4)["dem"]
beta_hat <- (coef(model4)[2:9])
gamma_hat
<- beta_hat / (1 - sum(gamma_hat)) long_run_effect_4
<- c(long_run_effect_1, long_run_effect_2, long_run_effect_3, long_run_effect_4)
lre <- round(lre, 3)
lre 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 \]
<- sum(coef(model1)[2])
pers1 <- sum(coef(model2)[2:3])
pers2 <- sum(coef(model3)[2:5])
pers3 <- sum(coef(model4)[2:9])
pers4
<- c(pers1, pers2, pers3, pers4)
pers <- round(pers, 3)
pers 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
<- coef(model1)["dem"]
dem_shortrun <- (coef(model1)[2]) lag1
<- dem_shortrun
effect1 <- (effect1 * lag1) + dem_shortrun
effect2
<- c(effect1, effect2) effects
for (i in 3:30) {
<- (effects[i-1] * lag1) + effects[1]
eff <- c(effects, eff)
effects }
<- effects[25]
eff_25_1 eff_25_1
dem
17.79084
Model 2
<- coef(model2)["dem"]
dem_shortrun <- (coef(model2)[2])
lag1 <- (coef(model2)[3]) lag2
<- dem_shortrun
effect1 <- (effect1 * lag1) + dem_shortrun
effect2 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun
effect3
<- c(effect1, effect2, effect3) effects
for (i in 4:30) {
<- (effects[i-1] * lag1) + (effects[i-2] * lag2) + dem_shortrun
eff <- c(effects, eff)
effects }
<- effects[25]
eff_25_2 eff_25_2
dem
13.80001
Model 3
<- coef(model3)["dem"]
dem_shortrun <- (coef(model3)[2])
lag1 <- (coef(model3)[3])
lag2 <- (coef(model3)[4])
lag3 <- (coef(model3)[5]) lag4
<- dem_shortrun
effect1 <- (effect1 * lag1) + dem_shortrun
effect2 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun
effect3 <- (effect3 * lag1) + (effect2 * lag2) + (effect1 * lag3) + dem_shortrun
effect4
<- c(effect1,effect2, effect3, effect4) effects
for (i in 5:30) {
<- (effects[i-1] * lag1) + (effects[i-2] * lag2) + (effects[i-3] * lag3) + (effects[i-4] * lag4) + dem_shortrun
eff <- c(effects, eff)
effects }
<- effects[25]
eff_25_3 eff_25_3
dem
16.89525
Model 4
<- coef(model4)["dem"]
dem_shortrun <- (coef(model4)[2])
lag1 <- (coef(model4)[3])
lag2 <- (coef(model4)[4])
lag3 <- (coef(model4)[5])
lag4 <- (coef(model4)[6])
lag5 <- (coef(model4)[7])
lag6 <- (coef(model4)[8])
lag7 <- (coef(model4)[9]) lag8
<- dem_shortrun
effect1 <- (effect1 * lag1) + dem_shortrun
effect2 <- (effect2 * lag1) + (effect1 * lag2) + dem_shortrun
effect3 <- (effect3 * lag1) + (effect2 * lag2) + (effect1 * lag3) + dem_shortrun
effect4 <- (effect4 * lag1) + (effect3 * lag2) + (effect2 * lag3) + (effect1 * lag4) + dem_shortrun
effect5 <- (effect5 * lag1) + (effect4 * lag2) + (effect3 * lag3) + (effect2 * lag4) + (effect1 * lag5) + dem_shortrun
effect6 <- (effect6 * lag1) + (effect5 * lag2) + (effect4 * lag3) + (effect3 * lag4) + (effect2 * lag5) + (effect1 * lag6) + dem_shortrun
effect7 <- (effect7 * lag1) + (effect6 * lag2) + (effect5 * lag3) + (effect4 * lag4) + (effect3 * lag5) + (effect2 * lag6) + (effect1 * lag7) + dem_shortrun
effect8
<- c(effect1, effect2, effect3, effect4, effect5, effect6, effect7, effect8) effects
for (i in 9:30) {
<- (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
eff <- c(effects, eff)
effects }
<- effects[25]
eff_25_4 eff_25_4
dem
17.71534
<- c(eff_25_1, eff_25_2, eff_25_3, eff_25_4)
eff_25 <- round(eff_25, 3)
eff_25 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
<- list(model1, model2, model3, model4)
models
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
)
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
)