IV Regressions

Model

First Stage:

\[ y_{ct} = \beta D_{ct} + \sum_{j=1}^p \gamma_j y_{ct-j} + \alpha_c + \delta_t + \epsilon_{ct} \]

Second Stage: with D as IV

\[ D_{ct} = \sum_{j=1}^p \pi_j Z_{ct-j}+ \sum_{j=1}^p \phi y_{ct-j} + \Phi_c+ \mu_t+ v_{ct} \]

  • Z = average of democracy in Region times initial regime cell = demreg in dataframe
  • D = democracy variable = dem variable
  • y = log gdp per capita = y variable

Estimated with 2SLS Regression

Imports

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
✔ ggplot2 3.3.5     ✔ purrr   0.3.4
✔ tibble  3.1.5     ✔ dplyr   1.0.7
✔ tidyr   1.1.4     ✔ stringr 1.4.0
✔ readr   2.0.2     ✔ forcats 0.5.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(plm)
Warning: Paket 'plm' wurde unter R Version 4.1.2 erstellt

Attache Paket: 'plm'
Die folgenden Objekte sind maskiert von 'package:dplyr':

    between, lag, lead
library(stargazer)
Warning: Paket 'stargazer' wurde unter R Version 4.1.2 erstellt

Please cite as: 
 Hlavac, Marek (2022). stargazer: Well-Formatted Regression and Summary Statistics Tables.
 R package version 5.2.3. https://CRAN.R-project.org/package=stargazer 
DDCGdata <- haven::read_dta("data/DDCGdata.dta")

pdf <- pdata.frame(DDCGdata, index=c("country_name", "year"))
rm(DDCGdata)

head(pdf)

Estimation

Use PLM and IVReg type formula for estimation, because IVReg does not work with panel data!

Model 1 = 1 Lag of the Instrument

iv_model_1 <- plm(
    y ~ dem + plm::lag(y, 1:4) | 
    plm::lag(demreg,1) + plm::lag(y, 1:4),
    data=pdf,
    effect = "twoways",
    )

summary(iv_model_1)
Twoways effects Within Model
Instrumental variable estimation

Call:
plm(formula = y ~ dem + plm::lag(y, 1:4) | plm::lag(demreg, 1) + 
    plm::lag(y, 1:4), data = pdf, effect = "twoways")

Unbalanced Panel: n = 174, T = 6-47, N = 6312

Residuals:
     Min.   1st Qu.    Median   3rd Qu.      Max. 
-63.92159  -1.83639   0.14697   2.14576  59.92426 

Coefficients:
                   Estimate Std. Error  z-value  Pr(>|z|)    
dem                0.966327   0.614760   1.5719 0.1159793    
plm::lag(y, 1:4)1  1.238560   0.012621  98.1360 < 2.2e-16 ***
plm::lag(y, 1:4)2 -0.205886   0.019914 -10.3388 < 2.2e-16 ***
plm::lag(y, 1:4)3 -0.028829   0.019458  -1.4816 0.1384464    
plm::lag(y, 1:4)4 -0.040568   0.011991  -3.3832 0.0007164 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    4163000
Residual Sum of Squares: 154240
R-Squared:      0.96295
Adj. R-Squared: 0.96159
Chisq: 158192 on 5 DF, p-value: < 2.22e-16

Model 2 = 4 Lags of the Instrument

preferred specification!

iv_model_2 <- plm(
    y ~ dem + plm::lag(y, 1:4) | 
    plm::lag(demreg,1:4) + plm::lag(y, 1:4), # 4 lags of the instrument
    data=pdf,
    effect = "twoways",
    )

summary(iv_model_2)
Twoways effects Within Model
Instrumental variable estimation

Call:
plm(formula = y ~ dem + plm::lag(y, 1:4) | plm::lag(demreg, 1:4) + 
    plm::lag(y, 1:4), data = pdf, effect = "twoways")

Unbalanced Panel: n = 174, T = 6-47, N = 6309

Residuals:
     Min.   1st Qu.    Median   3rd Qu.      Max. 
-63.89293  -1.82916   0.13924   2.16584  60.02919 

Coefficients:
                   Estimate Std. Error  z-value  Pr(>|z|)    
dem                1.149385   0.607133   1.8931 0.0583400 .  
plm::lag(y, 1:4)1  1.238325   0.012625  98.0855 < 2.2e-16 ***
plm::lag(y, 1:4)2 -0.205486   0.019920 -10.3154 < 2.2e-16 ***
plm::lag(y, 1:4)3 -0.028830   0.019465  -1.4811 0.1385787    
plm::lag(y, 1:4)4 -0.040474   0.011995  -3.3741 0.0007405 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    4162800
Residual Sum of Squares: 154290
R-Squared:      0.96294
Adj. R-Squared: 0.96157
Chisq: 158064 on 5 DF, p-value: < 2.22e-16

Model 3 = Dummies for Soviet Countries

iv_model_3 <- plm(
    y ~ dem + plm::lag(y, 1:4) + sov1 + sov2 + sov3 +sov4| #soviet (satellite) dummies
    plm::lag(demreg,1:4) + plm::lag(y, 1:4) + sov1 + sov2 + sov3 +sov4,
    data=pdf,
    effect = "twoways",
    )

summary(iv_model_3)
Twoways effects Within Model
Instrumental variable estimation

Call:
plm(formula = y ~ dem + plm::lag(y, 1:4) + sov1 + sov2 + sov3 + 
    sov4 | plm::lag(demreg, 1:4) + plm::lag(y, 1:4) + sov1 + 
    sov2 + sov3 + sov4, data = pdf, effect = "twoways")

Unbalanced Panel: n = 174, T = 6-47, N = 6309

Residuals:
     Min.   1st Qu.    Median   3rd Qu.      Max. 
-63.86173  -1.85524   0.13395   2.15316  60.14994 

Coefficients:
                   Estimate Std. Error  z-value  Pr(>|z|)    
dem                1.291557   0.674934   1.9136 0.0556708 .  
plm::lag(y, 1:4)1  1.233611   0.012636  97.6263 < 2.2e-16 ***
plm::lag(y, 1:4)2 -0.202224   0.019862 -10.1813 < 2.2e-16 ***
plm::lag(y, 1:4)3 -0.026801   0.019393  -1.3820 0.1669785    
plm::lag(y, 1:4)4 -0.040741   0.011962  -3.4059 0.0006593 ***
sov1              -3.173756   1.841289  -1.7237 0.0847693 .  
sov2              -2.623189   2.392686  -1.0963 0.2729315    
sov3              -5.635304   2.204234  -2.5566 0.0105706 *  
sov4               8.386325   1.509811   5.5546 2.783e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Total Sum of Squares:    4162800
Residual Sum of Squares: 152920
R-Squared:      0.96327
Adj. R-Squared: 0.96189
Chisq: 159424 on 9 DF, p-value: < 2.22e-16

Long Run Effects

beta_hat <- coef(iv_model_1)["dem"]
gamma_hat <- (coef(iv_model_1)[2:5])

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

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

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

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 
26.315 31.521 35.723 36.788 

Short Run Effect

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} \]

sre <- c()

Model 1

dem_shortrun <- coef(iv_model_1)["dem"]
lag1 <- (coef(iv_model_1)[2])
lag2 <- (coef(iv_model_1)[3])
lag3 <- (coef(iv_model_1)[4])
lag4 <- (coef(iv_model_1)[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)
}
sre <- c(sre, effects[25])

Model 2

dem_shortrun <- coef(iv_model_2)["dem"]
lag1 <- (coef(iv_model_2)[2])
lag2 <- (coef(iv_model_2)[3])
lag3 <- (coef(iv_model_2)[4])
lag4 <- (coef(iv_model_2)[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)
}
sre <- c(sre, effects[25])

Model 3

dem_shortrun <- coef(iv_model_3)["dem"]
lag1 <- (coef(iv_model_3)[2])
lag2 <- (coef(iv_model_3)[3])
lag3 <- (coef(iv_model_3)[4])
lag4 <- (coef(iv_model_3)[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)
}
sre <- c(sre, effects[25])

Model 4

dem_shortrun <- coef(iv_model_4)["dem"]
lag1 <- (coef(iv_model_4)[2])
lag2 <- (coef(iv_model_4)[3])
lag3 <- (coef(iv_model_4)[4])
lag4 <- (coef(iv_model_4)[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)
}
sre <- c(sre, effects[25])
sre <- round(sre, 3)
sre
   dem    dem    dem    dem 
20.836 24.866 27.929 32.051 

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(iv_model_1)[2:5])
pers2 <- sum(coef(iv_model_2)[2:5])
pers3 <- sum(coef(iv_model_3)[2:5])
pers4 <- sum(coef(iv_model_4)[2:5])

pers <- c(pers1, pers2, pers3, pers4)
pers <- round(pers, 3)
pers
[1] 0.963 0.964 0.964 0.954

Table

models <- list(iv_model_1, iv_model_2, iv_model_3, iv_model_4)

stargazer(models, 
          type = "html",
          title = "Effect of Democracy on (Log) GDP per Capita",
          keep = c("dem"),
          column.labels = c("1 Lag", "4 Lags", "Soviet Dummies", "Regional Trends"),
          dep.var.labels = "Dependent Variable",
          covariate.labels = c("Democracy"),
          omit.stat = c("ser", "rsq", "adj.rsq", "f"),
          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: ", sre)
            )
          )
Effect of Democracy on (Log) GDP per Capita
Dependent variable:
Dependent Variable
1 Lag 4 Lags Soviet Dummies Regional Trends
(1) (2) (3) (4)
Democracy 0.966 1.149* 1.292* 1.697**
(0.615) (0.607) (0.675) (0.785)
Persistence: 0.963 0.964 0.964 0.954
Long run effect: 26.315 31.521 35.723 36.788
Effect after 25 years: 20.836 24.866 27.929 32.051
Observations 6,312 6,309 6,309 6,309
Note: p<0.1; p<0.05; p<0.01

Save to Tex:

stargazer(models, 
          type = "latex",
          out = "output/table_iv.tex",
          title = "Effect of Democracy on (Log) GDP per Capita",
          keep = c("dem"),
          column.labels = c("1 Lag", "4 Lags", "Soviet Dummies", "Regional Trends"),
          dep.var.labels = "Dependent Variable",
          covariate.labels = c("Democracy"),
          omit.stat = c("ser", "rsq", "adj.rsq", "f"),
          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: ", sre)
            )
          )