Load libraries and data
library(magrittr)
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
##
## Attaching package: 'purrr'
## The following object is masked from 'package:dplyr':
##
## order_by
## The following object is masked from 'package:magrittr':
##
## set_names
library(broom)
library(ggplot2)
library(Cairo)
library(stargazer)
##
## Please cite as:
## Hlavac, Marek (2015). stargazer: Well-Formatted Regression and Summary Statistics Tables.
## R package version 5.2. http://CRAN.R-project.org/package=stargazer
full.data <- readRDS(file.path(PROJHOME, "Data", "data_processed",
"full_data.rds"))
my.seed <- 1234
set.seed(my.seed)
Variables
Dependent variables
Civil society regulatory environment:
v2csreprss
: V-Dem CSO repression (“Does the government attempt to repress civil society organizations?). Higher numbers = less repression.
v2csreprss_ord
: Ordinal version of v2csreprss
(labels = “Severely”, “Substantially”, “Moderately”, “Weakly”, “No”)
v2cseeorgs
: V-Dem CSO entry and exit (“To what extent does the government achieve control over entry and exit by civil society organizations (CSOs) into public life?”). Higher numbers = less control.
cs_env_sum
: Sum of v2csreprss
and v2cseeorgs
. V-Dem includes a “Core civil society index” that uses Bayesian factor analysis to combine repression, entry/exit, and participatory environment. I’m less interested in the participatory environment. The paper describing the original factor analysis model, however, does not explain how it was built, so here I make a simple additive index of the two variables.
Explanatory variables
Internal stability:
icrg.stability
:
icrg.pol.risk.internal.scaled
: Political risk rating—external measures removed and index rescaled to 0-100 scale
yrsoffc
:
years.since.comp
:
opp1vote
:
External stability:
International reputation:
- Variable from ICEWS / shaming data from Murdie
Controls:
e_polity2
:
physint
:
gdpcap.log
:
population.log
:
oda.log
:
countngo
:
globalization
:
Models
Internal factors
Just internal political risk
model.int.simple <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ icrg.pol.risk.internal.scaled,
data=.))
stargazer(model.int.simple, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.simple),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("No", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
icrg.pol.risk.internal.scaled
|
-0.020***
|
0.072***
|
|
(0.006)
|
(0.003)
|
Constant
|
0.848**
|
-1.007***
|
|
(0.332)
|
(0.168)
|
|
Year fixed effects
|
No
|
No
|
Observations
|
784
|
1,776
|
R2
|
0.014
|
0.318
|
Adjusted R2
|
0.013
|
0.318
|
Residual Std. Error
|
2.270 (df = 782)
|
1.382 (df = 1774)
|
F Statistic
|
10.987*** (df = 1; 782)
|
828.026*** (df = 1; 1774)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
All internal variables
model.int.full <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ icrg.pol.risk.internal.scaled +
yrsoffc + years.since.comp + opp1vote + as.factor(year.num),
data=.))
stargazer(model.int.full, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.full),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("Yes", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
icrg.pol.risk.internal.scaled
|
-0.009
|
0.079***
|
|
(0.007)
|
(0.003)
|
yrsoffc
|
-0.060***
|
-0.036***
|
|
(0.011)
|
(0.011)
|
years.since.comp
|
-0.038***
|
0.019
|
|
(0.008)
|
(0.017)
|
opp1vote
|
0.038***
|
0.007**
|
|
(0.009)
|
(0.003)
|
Constant
|
1.363***
|
-0.876***
|
|
(0.480)
|
(0.275)
|
|
Year fixed effects
|
Yes
|
Yes
|
Observations
|
409
|
1,377
|
R2
|
0.302
|
0.370
|
Adjusted R2
|
0.258
|
0.359
|
Residual Std. Error
|
1.940 (df = 384)
|
1.348 (df = 1352)
|
F Statistic
|
6.922*** (df = 24; 384)
|
33.094*** (df = 24; 1352)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
All internal variables + controls
model.int.all <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ icrg.pol.risk.internal.scaled +
yrsoffc + years.since.comp + opp1vote +
physint + gdpcap.log + population.log +
oda.log + countngo + globalization + as.factor(year.num),
data=.))
stargazer(model.int.all, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.all),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("Yes", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
icrg.pol.risk.internal.scaled
|
0.016
|
0.055***
|
|
(0.011)
|
(0.008)
|
yrsoffc
|
-0.056***
|
-0.038***
|
|
(0.011)
|
(0.015)
|
years.since.comp
|
-0.013
|
0.021
|
|
(0.009)
|
(0.036)
|
opp1vote
|
0.015*
|
0.006
|
|
(0.009)
|
(0.004)
|
physint
|
0.165**
|
0.286***
|
|
(0.069)
|
(0.042)
|
gdpcap.log
|
-0.942***
|
0.215**
|
|
(0.162)
|
(0.096)
|
population.log
|
0.301**
|
0.145***
|
|
(0.129)
|
(0.055)
|
oda.log
|
0.419***
|
-0.066
|
|
(0.126)
|
(0.058)
|
countngo
|
-0.008*
|
0.004*
|
|
(0.004)
|
(0.002)
|
globalization
|
-0.008
|
-0.022**
|
|
(0.015)
|
(0.009)
|
Constant
|
-6.931***
|
-2.472
|
|
(2.307)
|
(1.574)
|
|
Year fixed effects
|
Yes
|
Yes
|
Observations
|
299
|
770
|
R2
|
0.604
|
0.285
|
Adjusted R2
|
0.562
|
0.258
|
Residual Std. Error
|
1.472 (df = 270)
|
1.473 (df = 741)
|
F Statistic
|
14.680*** (df = 28; 270)
|
10.567*** (df = 28; 741)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
All models (to LaTeX)
all.models <- c(model.int.simple, model.int.full, model.int.all)
coef.labs <- c("Internal political risk (ICRG)", "Years executive in office",
"Years since competitive election", "Opposition vote share",
"Physical integrity rights", "GDP per capita (log)",
"Population (log)", "Foreign aid (log)",
"Number of INGO members", "Globalization")
extra.lines <- list(c("Year fixed effects",
c(rep("No", 2), rep("Yes", 4))))
capture.output({
stargazer(all.models, type="latex",
out=file.path(PROJHOME, "Output", "tables", "1-internal-models-all.tex"),
covariate.labels=coef.labs,
dep.var.caption="Civil society regulatory environment (CSRE) in following year",
dep.var.labels.include=FALSE,
column.labels=names(all.models),
omit="factor\\(year", no.space=TRUE,
add.lines=extra.lines)
}, file="/dev/null")
External factors
Just neighbors
model.ext.neighbors <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ neighbor.pol.risk.min +
neighbor.coups.activity.bin,
data=.))
stargazer(model.ext.neighbors, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.simple),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("No", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
neighbor.pol.risk.min
|
-0.018***
|
0.049***
|
|
(0.006)
|
(0.003)
|
neighbor.coups.activity.bin
|
0.197
|
-0.025
|
|
(0.260)
|
(0.175)
|
Constant
|
0.639**
|
0.968***
|
|
(0.270)
|
(0.161)
|
|
Year fixed effects
|
No
|
No
|
Observations
|
788
|
1,647
|
R2
|
0.015
|
0.165
|
Adjusted R2
|
0.012
|
0.164
|
Residual Std. Error
|
2.231 (df = 785)
|
1.550 (df = 1644)
|
F Statistic
|
5.776*** (df = 2; 785)
|
161.882*** (df = 2; 1644)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
Neighbors and subregion
model.ext.neighbors.subregion <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ neighbor.pol.risk.min +
icrg.pol.risk.subregional +
neighbor.coups.activity.bin +
coups.activity.subregional,
data=.))
stargazer(model.ext.neighbors.subregion, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.simple),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("No", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
neighbor.pol.risk.min
|
0.017***
|
0.018***
|
|
(0.006)
|
(0.003)
|
icrg.pol.risk.subregional
|
-0.116***
|
0.069***
|
|
(0.011)
|
(0.005)
|
neighbor.coups.activity.bin
|
-0.423*
|
-0.024
|
|
(0.249)
|
(0.189)
|
coups.activity.subregional
|
0.483***
|
0.173**
|
|
(0.105)
|
(0.075)
|
Constant
|
5.692***
|
-2.055***
|
|
(0.613)
|
(0.270)
|
|
Year fixed effects
|
No
|
No
|
Observations
|
779
|
1,646
|
R2
|
0.201
|
0.257
|
Adjusted R2
|
0.196
|
0.255
|
Residual Std. Error
|
2.009 (df = 774)
|
1.463 (df = 1641)
|
F Statistic
|
48.547*** (df = 4; 774)
|
142.020*** (df = 4; 1641)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
Neighbors and region
model.ext.neighbors.region <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ neighbor.pol.risk.min +
icrg.pol.risk.regional +
neighbor.coups.activity.bin +
coups.activity.regional,
data=.))
stargazer(model.ext.neighbors.region, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.simple),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("No", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
neighbor.pol.risk.min
|
0.001
|
0.036***
|
|
(0.006)
|
(0.003)
|
icrg.pol.risk.regional
|
-0.058***
|
0.045***
|
|
(0.018)
|
(0.007)
|
neighbor.coups.activity.bin
|
-0.011
|
0.017
|
|
(0.258)
|
(0.179)
|
coups.activity.regional
|
0.116
|
0.100**
|
|
(0.073)
|
(0.045)
|
Constant
|
3.074***
|
-1.467***
|
|
(1.126)
|
(0.434)
|
|
Year fixed effects
|
No
|
No
|
Observations
|
787
|
1,646
|
R2
|
0.058
|
0.187
|
Adjusted R2
|
0.053
|
0.185
|
Residual Std. Error
|
2.185 (df = 782)
|
1.530 (df = 1641)
|
F Statistic
|
12.000*** (df = 4; 782)
|
94.659*** (df = 4; 1641)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
Neighbors and subregion + controls
model.ext.neighbors.subregion.ctrl <- full.data %>%
split(.$polity_ord2) %>%
map(~ lm(cs_env_sum.lead ~ neighbor.pol.risk.min +
icrg.pol.risk.subregional +
neighbor.coups.activity.bin +
coups.activity.subregional +
gdpcap.log + population.log + oda.log +
countngo + globalization + as.factor(year.num),
data=.))
stargazer(model.ext.neighbors.subregion.ctrl, type="html",
dep.var.caption="CSRE",
dep.var.labels.include=FALSE, no.space=TRUE,
column.labels=names(model.int.simple),
omit="factor\\(year",
add.lines=list(c("Year fixed effects",
rep("Yes", 2))))
|
|
CSRE
|
|
|
|
Autocracy
|
Democracy
|
|
(1)
|
(2)
|
|
neighbor.pol.risk.min
|
0.007
|
0.005
|
|
(0.007)
|
(0.005)
|
icrg.pol.risk.subregional
|
-0.085***
|
0.026***
|
|
(0.014)
|
(0.010)
|
neighbor.coups.activity.bin
|
-0.154
|
-0.101
|
|
(0.250)
|
(0.236)
|
coups.activity.subregional
|
0.446***
|
0.132
|
|
(0.119)
|
(0.095)
|
gdpcap.log
|
0.028
|
0.371***
|
|
(0.117)
|
(0.090)
|
population.log
|
-0.343***
|
-0.147***
|
|
(0.078)
|
(0.043)
|
oda.log
|
0.556***
|
0.058
|
|
(0.080)
|
(0.057)
|
countngo
|
-0.005*
|
-0.005*
|
|
(0.003)
|
(0.002)
|
globalization
|
0.012
|
-0.004
|
|
(0.011)
|
(0.008)
|
Constant
|
-2.211
|
0.111
|
|
(1.905)
|
(1.412)
|
|
Year fixed effects
|
Yes
|
Yes
|
Observations
|
584
|
998
|
R2
|
0.287
|
0.133
|
Adjusted R2
|
0.252
|
0.109
|
Residual Std. Error
|
1.771 (df = 556)
|
1.572 (df = 970)
|
F Statistic
|
8.272*** (df = 27; 556)
|
5.527*** (df = 27; 970)
|
|
Note:
|
p<0.1; p<0.05; p<0.01
|
All models (to LaTeX)
all.models <- c(model.ext.neighbors, model.ext.neighbors.region,
model.ext.neighbors.subregion,
model.ext.neighbors.subregion.ctrl)
coef.labs <- c("Lowest political risk in all neighboring countries",
"Average political risk in subregion",
"Average political risk in region",
"Coup activity in neighboring countries (binary)",
"Coup activity in subregion (binary)",
"Coup activity in region (binary)",
"GDP per capita (log)",
"Population (log)", "Foreign aid (log)",
"Number of INGO members", "Globalization")
extra.lines <- list(c("Year fixed effects",
c(rep("No", 6), rep("Yes", 2))))
capture.output({
stargazer(all.models, type="latex",
out=file.path(PROJHOME, "Output", "tables", "1-external-models-all.tex"),
covariate.labels=coef.labs,
dep.var.caption="Civil society regulatory environment (CSRE) in following year",
dep.var.labels.include=FALSE,
column.labels=names(all.models),
omit="factor\\(year", no.space=TRUE,
add.lines=extra.lines)
}, file="/dev/null")
International reputation
All three at once?
model.everything <- lm(cs_env_sum.lead ~ icrg.pol.risk.internal.scaled +
yrsoffc + years.since.comp + opp1vote +
neighbor.pol.risk.min +
e_polity2 +
physint + gdpcap.log + population.log +
oda.log + countngo + globalization,
data=full.data)
summary(model.everything)
##
## Call:
## lm(formula = cs_env_sum.lead ~ icrg.pol.risk.internal.scaled +
## yrsoffc + years.since.comp + opp1vote + neighbor.pol.risk.min +
## e_polity2 + physint + gdpcap.log + population.log + oda.log +
## countngo + globalization, data = full.data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.8000 -1.0443 0.0321 1.0299 5.5844
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.1801746 1.2598195 -1.731 0.08385 .
## icrg.pol.risk.internal.scaled 0.0258183 0.0063801 4.047 5.60e-05 ***
## yrsoffc -0.0457290 0.0095454 -4.791 1.92e-06 ***
## years.since.comp -0.0269695 0.0084376 -3.196 0.00144 **
## opp1vote -0.0014489 0.0041757 -0.347 0.72868
## neighbor.pol.risk.min 0.0003976 0.0048706 0.082 0.93496
## e_polity2 0.2278247 0.0137361 16.586 < 2e-16 ***
## physint 0.2236433 0.0361012 6.195 8.58e-10 ***
## gdpcap.log -0.0694932 0.0751787 -0.924 0.35552
## population.log 0.1064540 0.0501490 2.123 0.03402 *
## oda.log 0.0751036 0.0526832 1.426 0.15431
## countngo 0.0019172 0.0022356 0.858 0.39133
## globalization -0.0213493 0.0067471 -3.164 0.00160 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.495 on 979 degrees of freedom
## (2440 observations deleted due to missingness)
## Multiple R-squared: 0.5824, Adjusted R-squared: 0.5772
## F-statistic: 113.8 on 12 and 979 DF, p-value: < 2.2e-16
Bayesian tinkering
See:
# library(rstanarm)
# options(mc.cores = parallel::detectCores()) # Use all possible cores
#
# model.simple.b <- stan_glm(cs_env_sum.lead ~ icrg.stability + e_polity2,
# data=full.data, family=gaussian(),
# prior=cauchy(), prior_intercept=cauchy(),
# seed=my.seed)
# print(model.simple.b, digits=2)
# plot(model.simple.b, pars=c("icrg.stability", "e_polity2"))
# pp_check(model.simple.b, check="distributions", overlay=FALSE, nreps=5)
▲ Back to top ▲