time.v = 1998,
text.x = 1998,
text.y = 10,
text = "",
all.mean = all.mean,
legend.lab = c("Indonesia","Mean of Democratising Countries"))
dev.off()
##############################################################
# social
##############################################################
dependent = "social"
mat = matrix(NA, nrow=length(list.unique), ncol=length(time))
for (i in 1:length(list.unique)) {
mat[i,] = dat[dat$country==list.unique[i] ,dependent]
}
all.mean = colMeans(mat[1:(nrow(mat)-1), ])
png(filename = "Figure A5.3. Social Discrimination in Indonesia and Other Democratising Countries.png", width=width, height=height, res=res)
draw(mat,
x.range = time,
ylim = c(0,max(dat[,dependent])+5),
ylab = "Social Discrimination of Religious Minorities",
time.v = 1998,
text.x = 1998,
text.y = 10,
text = "",
all.mean = all.mean,
legend.lab = c("Indonesia","Mean of Democratising Countries"))
dev.off()
rm(list=ls())
library(dplyr)
library(Synth)
dat = read.csv("RAS.csv", header=TRUE)
dat$country = as.character(dat$country)
#from negative to positive or vice versa
change.countries = c("Algeria", "Bangladesh", "Bhutan", "Burundi", "Cape Verde",
"Central African Republic", "Comoros", "Djibouti", "Ethiopia", "Fiji", "Gabon", "Gambia", "Ghana",
"Guinea", "Guinea Bissau", "Guyana", "Ivory Coast", "Kenya", "Lesotho", "Madagascar",
"Malawi", "Mali", "Mauritania", "Mozambique", "Nepal", "Niger", "Nigeria", "Pakistan",
"Peru", "Senegal", "Sierra Leone", "Thailand", "Tunisia", "Zambia", "Zimbabwe")
#from zero to positive or zero to negative; no crossing the line
# "Benin", "Burkina Faso", "Liberia", "Libya", "Mexico"
dat = dat[dat$country %in% change.countries, c("country", "year", "polity")]
set.seed(12345)
##############################################################
# Create not.in function to make life easier
##############################################################
`%not.in%` <- function(x,y)!('%in%'(x,y))
# global parameters for graphic
width = 3200
height = 2400
res = 300
draw <- function(dv, cty.name, ylim, ylab) {
y = dv
plot(dat[dat$country == cty.name,"year"],  dat[dat$country == cty.name, y], type="l",
ylim=ylim, ylab=ylab, xlab="Year", axes=FALSE, cex.lab=1.5, lwd=2, main=cty.name)
axis(side=1, at=seq(1990,2014, by=2))
axis(side=2, at=seq(min(ylim),max(ylim), by=2))
abline(h=0)
}
png(filename = "Figure A6.1. Polity IV Scores of the Regime Change Countries.png", width=3000, height=4000, res=300)
par(mfrow=c(7,5))
for (cty in change.countries) {
draw(dv="polity", cty.name=cty, ylim=c(-10, 10), ylab="Polity IV")
}
dev.off()
rm(list=ls())
library(dplyr)
library(Synth)
##############################################################
# Create not.in function to make life easier
##############################################################
`%not.in%` <- function(x,y)!('%in%'(x,y))
##############################################################
# Read Data
##############################################################
dat = read.csv("RAS.csv", header=TRUE)
dat$country = as.character(dat$country)
change.countries = c("Algeria", "Bangladesh", "Bhutan", "Burundi", "Cape Verde",
"Central African Republic", "Comoros", "Djibouti", "Ethiopia", "Fiji", "Gabon", "Gambia", "Ghana",
"Guinea", "Guinea Bissau", "Guyana", "Ivory Coast", "Kenya", "Lesotho", "Madagascar",
"Malawi", "Mali", "Mauritania", "Mozambique", "Nepal", "Niger", "Nigeria", "Pakistan",
"Peru", "Senegal", "Sierra Leone", "Thailand", "Tunisia", "Zambia", "Zimbabwe")
dat = dat[dat$country %not.in% change.countries, c("country", "ctyid", "year", "polity", "gdppc", "pcturban", "rdi", "muslim", "pctmuslim",
"state", "social", "legislation")]
set.seed(12345)
##############################################################
# Delete Incomplete Countries as Preparation for Synthetic Control
##############################################################
num.missing <- function(x) {
return (sum(is.na(x)))
}
dat.temp = dat
out = aggregate(x=dat.temp, by=list(country=dat.temp$country), FUN=num.missing)
has.missing = rowSums((out[,-1])) > 0
countries.without.missing = out$country[!has.missing]
dat = dat[dat$country %in% countries.without.missing,]
##############################################################
# defining global graphic parameters
##############################################################
# global parameters for graphic
width = 3200
height = 2400
res = 300
predictors.global = c("polity", "gdppc", "pcturban", "rdi",
"state", "social", "legislation")
treatment.identifier = "Indonesia"
controls.identifier = unique(dat$country[dat$country %not.in% treatment.identifier])
time = 1990:2014
time.pretreat = 1990:1997
# global parameters for graphic
width = 3200
height = 2400
res = 300
out = matrix(controls.identifier, ncol=3, byrow=FALSE)
write.csv(out, file="Donor Pool.csv", row.names=FALSE)
##############################################################
# synthetic control estimation
##############################################################
build.data <- function(dat.synth, predictors, dependent, treatment.identifier, controls.identifier,
time, time.pretreat) {
return(
dataprep(
foo = dat.synth,
predictors = predictors,
predictors.op = "mean",
dependent = dependent,
unit.variable = "ctyid",
time.variable = "year",
treatment.identifier = treatment.identifier,
controls.identifier = controls.identifier,
time.predictors.prior = time.pretreat,
time.optimize.ssr = time.pretreat,
unit.names.variable = "country",
time.plot = time
)
)
}
# Draw Trends of Indonesia and Synthetic Indonesia
draw.trends <- function(Y0, Y1, x.range, ylim, ylab, legend.lab, time.v,
text.x, text.y, text) {
plot(x.range,Y1,
type="l", ylim=ylim,
col=rgb(0,0,0,alpha=.3), lty="solid",
ylab = ylab,
xlab ="Year",
lwd=6,
axes = "false",
cex.lab=1.5
)
axis(side=1, at=seq(time[1], time[length(time)], 2))
axis(side=2, at=seq(ylim[1], ylim[2], 5))
lines(x.range,Y0,col="black",lty="dashed",lwd=2)
abline(v=time.v, lty="dotted")
text(text.x, text.y, text, cex=1.4)
legend(x="bottomright",
legend=legend.lab,
lty=c("solid","dashed"),col=c("black","black"),
cex=1.4,bg="white",lwd=c(2,2))
}
##############################################################
# state
##############################################################
dependent = "state"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A6.2. Trajectories of State Discrimination (No Regime Change in the Donor Pool.png", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "State Discrimination of Religious Minorities",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1998,
text.x = 1998, text.y = 10, text = "Soeharto's\nDownfall"
)
dev.off()
##############################################################
# social
##############################################################
dependent = "social"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A6.4. Trajectories of Social Discrimination (No Regime Change in the Donor Pool.png", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Social Discrimination of Religious Minorities",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1998,
text.x = 1998, text.y = 10, text = "Soeharto's\nDownfall"
)
dev.off()
##############################################################
# legislation
##############################################################
dependent = "legislation"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A6.3. Trajectories of Religious Legislation (No Regime Change in the Donor Pool).png", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Legislation of Religion",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1998,
text.x = 1998, text.y = 10, text = "Soeharto's\nDownfall"
)
dev.off()
rm(list=ls())
library(dplyr)
library(Synth)
##############################################################
# Create not.in function to make life easier
##############################################################
`%not.in%` <- function(x,y)!('%in%'(x,y))
##############################################################
# Read Data
##############################################################
dat = read.csv("RAS.csv", header=TRUE)
dat$country = as.character(dat$country)
change.countries = c("Algeria", "Bangladesh", "Bhutan", "Burundi", "Cape Verde",
"Central African Republic", "Comoros", "Djibouti", "Ethiopia", "Fiji", "Gabon", "Gambia", "Ghana",
"Guinea", "Guinea Bissau", "Guyana", "Ivory Coast", "Kenya", "Lesotho", "Madagascar",
"Malawi", "Mali", "Mauritania", "Mozambique", "Nepal", "Niger", "Nigeria", "Pakistan",
"Peru", "Senegal", "Sierra Leone", "Thailand", "Tunisia", "Zambia", "Zimbabwe")
dat = dat[dat$country %not.in% change.countries, c("country", "ctyid", "year", "polity", "gdppc", "pcturban", "rdi", "muslim", "pctmuslim",
"state", "social", "legislation")]
set.seed(12345)
##############################################################
# defining global graphic parameters
##############################################################
# global parameters for graphic
width = 3200
height = 2400
res = 300
##############################################################
# Delete Incomplete Countries as Preparation for Synthetic Control
##############################################################
num.missing <- function(x) {
return (sum(is.na(x)))
}
dat.temp = dat
out = aggregate(x=dat.temp, by=list(country=dat.temp$country), FUN=num.missing)
has.missing = rowSums((out[,-1])) > 0
countries.without.missing = out$country[!has.missing]
dat = dat[dat$country %in% countries.without.missing,]
##############################################################
# synthetic control estimation
##############################################################
build.data <- function(dat.synth, predictors, dependent, treatment.identifier, controls.identifier,
time, time.pretreat) {
return(
dataprep(
foo = dat.synth,
predictors = predictors,
predictors.op = "mean",
dependent = dependent,
unit.variable = "ctyid",
time.variable = "year",
treatment.identifier = treatment.identifier,
controls.identifier = controls.identifier,
time.predictors.prior = time.pretreat,
time.optimize.ssr = time.pretreat,
unit.names.variable = "country",
time.plot = time
)
)
}
# Draw Trends of Indonesia and Synthetic Indonesia
draw.trends <- function(Y0, Y1, x.range, ylim, ylab, legend.lab, time.v,
text.x, text.y, text) {
plot(x.range,Y1,
type="l", ylim=ylim,
col=rgb(0,0,0,alpha=.3), lty="solid",
ylab = ylab,
xlab ="Year",
lwd=6,
axes = "false",
cex.lab=1.5
)
axis(side=1, at=seq(time[1], time[length(time)], 2))
axis(side=2, at=seq(ylim[1], ylim[2], 5))
lines(x.range,Y0,col="black",lty="dashed",lwd=2)
abline(v=time.v, lty="dotted")
text(text.x, text.y, text, cex=1.4)
legend(x="bottomright",
legend=legend.lab,
lty=c("solid","dashed"),col=c("black","black"),
cex=1.4,bg="white",lwd=c(2,2))
}
##############################################################
# defining global parameters
##############################################################
predictors.global = c("polity", "gdppc", "pcturban", "rdi",
"state", "social", "legislation")
treatment.identifier = "Indonesia"
controls.identifier = unique(dat$country[dat$country %not.in% treatment.identifier])
time = 1990:1998
time.pretreat = 1990:1994
# global parameters for graphic
width = 3200
height = 2400
res = 300
##############################################################
# social
##############################################################
dependent = "social"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A7.2. In-Time Placebo for Social Discrimination.png", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Social Discrimination of Religious Minorities",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1995,
text.x = 1995, text.y = 10, text = "Hypothethical\nSoeharto's\nDownfall"
)
dev.off()
##############################################################
# legislation
##############################################################
dependent = "legislation"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A7.1. In-Time Placebo for Religious Legislation.png", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Legislation of Religion",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1995,
text.x = 1995, text.y = 10, text = "Hypothethical\nSoeharto's\nDownfall"
)
dev.off()
rm(list=ls())
library(dplyr)
library(Synth)
dat = read.csv("RAS.csv", header=TRUE)
dat$country = as.character(dat$country)
dat = dat[, c("country", "ctyid", "year", "polity", "gdppc", "pcturban", "rdi", "muslim", "pctmuslim",
"state", "social", "legislation")]
set.seed(12345)
##############################################################
# Create not.in function to make life easier
##############################################################
`%not.in%` <- function(x,y)!('%in%'(x,y))
##############################################################
# defining global graphic parameters
##############################################################
# global parameters for graphic
width = 3200
height = 2400
res = 300
##############################################################
# Delete Incomplete Countries as Preparation for Synthetic Control
##############################################################
num.missing <- function(x) {
return (sum(is.na(x)))
}
dat.temp = dat
out = aggregate(x=dat.temp, by=list(country=dat.temp$country), FUN=num.missing)
has.missing = rowSums((out[,-1])) > 0
countries.without.missing = out$country[!has.missing]
dat = dat[dat$country %in% countries.without.missing,]
##############################################################
# synthetic control estimation
##############################################################
build.data <- function(dat.synth, predictors, dependent, treatment.identifier, controls.identifier,
time, time.pretreat) {
return(
dataprep(
foo = dat.synth,
predictors = predictors,
predictors.op = "mean",
dependent = dependent,
unit.variable = "ctyid",
time.variable = "year",
treatment.identifier = treatment.identifier,
controls.identifier = controls.identifier,
time.predictors.prior = time.pretreat,
time.optimize.ssr = time.pretreat,
unit.names.variable = "country",
time.plot = time
)
)
}
# Draw Trends of Indonesia and Synthetic Indonesia
draw.trends <- function(Y0, Y1, x.range, ylim, ylab, legend.lab, time.v,
text.x, text.y, text) {
plot(x.range,Y1,
type="l", ylim=ylim,
col=rgb(0,0,0,alpha=.3), lty="solid",
ylab = ylab,
xlab ="Year",
lwd=6,
axes = "false",
cex.lab=1.5
)
axis(side=1, at=seq(time[1], time[length(time)], 2))
axis(side=2, at=seq(ylim[1], ylim[2], 5))
lines(x.range,Y0,col="black",lty="dashed",lwd=2)
abline(v=time.v, lty="dotted")
text(text.x, text.y, text, cex=1.4)
legend(x="bottomright",
legend=legend.lab,
lty=c("solid","dashed"),col=c("black","black"),
cex=1.4,bg="white",lwd=c(2,2))
}
##############################################################
# defining global parameters
##############################################################
predictors.global = c("polity", "gdppc", "pcturban", "rdi",
"state", "social", "legislation")
#, "majority")
#"official", "support", "gensocietal", "socialreg")
treatment.identifier = "Indonesia"
controls.identifier = unique(dat$country[dat$country %not.in% treatment.identifier])
#controls.identifier = unique(dat$country[dat$country %not.in% treatment.identifier & dat$muslim == 1])
time = 1990:1998
time.pretreat = 1990:1994
# global parameters for graphic
width = 3200
height = 2400
res = 300
##############################################################
# social
##############################################################
dependent = "social"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A4.2. In-Time Placebo for Social Discrimination", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Social Discrimination of Religious Minorities",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1995,
text.x = 1995, text.y = 10, text = "Hypothethical\nSoeharto's\nDownfall"
)
dev.off()
##############################################################
# legislation
##############################################################
dependent = "legislation"
predictors = unique(c(predictors.global, dependent))
dataprep.out <- build.data(dat.synth = dat,
predictors = predictors,
dependent = dependent,
treatment.identifier,
controls.identifier,
time,
time.pretreat)
synth.out <- synth(dataprep.out)
png(filename = "Figure A4.1. In-Time Placebo for Religious Legislation", width=width, height=height, res=res)
draw.trends(Y0 = (dataprep.out$Y0%*%synth.out$solution.w),
Y1 = dataprep.out$Y1plot,
x.range = time,
ylim = c(0, 45),
ylab = "Legislation of Religion",
legend.lab = c("Indonesia","Synthetic Indonesia"),
time.v = 1995,
text.x = 1995, text.y = 10, text = "Hypothethical\nSoeharto's\nDownfall"
)
dev.off()
