######################################################################################################################
# #
#######################Estimating the Effect of Competitiveness on Turnout across Regime Types#########################
# #
# [r] Replication script #
######################################################################################################################
#set working directory
getwd()
setwd("")
#load data
data <- read.csv("")
data$X <- NULL
#recode year
data$elyear <- data$year-1975 #1975 set zero
#subset data
plur <- subset(data, data$elsys==1) #Dataset for Plurality and Majority Electoral Systems
prmix <- subset(data, data$elsys==0) #Dataset for PR and mixed Electoral Systems
############################
#Descriptive Statistics #
############################
#Figure 1: distribution of margin of victory by regime type
library(ggplot2)
library(ggpubr)
data$Regime <- NA #create character strings for regime types
data$Regime[data$elau==1] <- "Electoral Autocracy"
data$Regime[data$elau==0] <- "Democracy"
data$Regime <- as.factor(data$Regime)
left <- ggscatterhist(data, x="vap", y="rv", color="Regime",
margin.plot = "boxplot",
xlab="Turnout (VAP)", ylab="Turnout (RV)",
ggtheme=theme_bw(), palette="grey" , alpha=0.8,
legend="bottom", legend.title="")
descr1 <- desc_statby(data, measure.var = "vap", grps = "Regime") #Descr. statistics for VAP
descr1 <- descr1[, c("Regime", "length", "mean", "median", "sd")]
descr1[, c("length", "mean", "median", "sd")] <- round(descr1[, c("length", "mean", "median", "sd")], 2)
colnames(descr1)<- c("Turnout (VAP)", "Obs.", "Mean", "Median", "SD")
descr1.p <- ggtexttable(na.omit(descr1), rows = NULL, theme=ttheme("blank"))
descr2 <- desc_statby(data, measure.var = "rv", grps = "Regime") #Descr. Statistics for RV
descr2 <- descr2[, c("Regime", "length", "mean", "median", "sd")]
descr2[, c("length", "mean", "median", "sd")] <- round(descr2[, c("length", "mean", "median", "sd")], 2)
colnames(descr2)<- c("Turnout (RV)", "Obs.", "Mean", "Median", "SD")
descr2.p <- ggtexttable(na.omit(descr2), rows = NULL, theme=ttheme("blank"))
right <- ggarrange(NULL,descr1.p, descr2.p, NULL, nrow=4)
ggarrange(left, right, ncol = 2) #Arrange Plots
#Figure 2: distribution of government opposition margin
left <- ggscatterhist(data, x="margin", y="gomargin", color="Regime",
margin.plot = "boxplot",
xlab="Margin of Victory", ylab="Gov.-Opp. Margin",
ggtheme=theme_bw(), palette="grey" , alpha=0.8,
legend="bottom", legend.title="")
descr1 <- desc_statby(data, measure.var = "margin", grps = "Regime")
descr1 <- descr1[, c("Regime", "length", "mean", "median", "sd")]
descr1[, c("length", "mean", "median", "sd")] <- round(descr1[, c("length", "mean", "median", "sd")], 2)
colnames(descr1)<- c("Margin of Victory", "Obs.", "Mean", "Median", "SD")
descr1.p <- ggtexttable(descr1, rows = NULL, theme=ttheme("blank"))
descr2 <- desc_statby(data, measure.var = "gomargin", grps = "Regime")
descr2 <- descr2[, c("Regime", "length", "mean", "median", "sd")]
descr2[, c("length", "mean", "median", "sd")] <- round(descr2[, c("length", "mean", "median", "sd")], 2)
colnames(descr2)<- c("Gov.-Opp. Margin", "Obs.", "Mean", "Median", "SD")
descr2.p <- ggtexttable(descr2, rows = NULL, theme=ttheme("blank"))
right <- ggarrange(NULL,descr1.p, descr2.p, NULL, nrow=4)
ggarrange(left, right, ncol = 2)
#Table 1: distribution of uneven playing field
table(data$uneven, data$Regime)
#Correlation Matrix (Appendix 5, 6, 7)
library(sjPlot)
sjt.corr(data[,c(6,7,8,9,10,4,5,11,12,13,14)], corr.method="pearson", digits=2, triangle = "lower", show.p = T, fade.ns = F)
sjt.corr(plur[,c(6,7,8,9,10,4,11,12,13,15,14)], corr.method="pearson", digits=2, triangle = "lower", show.p = T, fade.ns = F)
sjt.corr(prmix[,c(6,7,8,9,10,4,11,12,13,15,14)], corr.method="pearson", digits=2, triangle = "lower", show.p = T, fade.ns = F)
##################################
#Regression Analysis #
#Table 2 & 3 #
##################################
library(panelAR)
#Define Regression Function
Regression <- turnout~comp*elau+gnipercapitaconst+presidential+elyear+compulsory+concurrent
#steps are annotated in first model only, and then repeated for following models
#Model 1
test <- subset(plur, #subset data for resprective regression
!is.na(plur$vap)&
!is.na(plur$margin)&
!is.na(plur$presidential)&
!is.na(plur$gnipercapitaconst)&
!is.na(plur$compulsory)&
!is.na(plur$concurrent)&
!is.na(plur$unevenpf))
test$turnout<- test$vap #assign turnout operationalization to function
test$comp <- test$margin #assign competitiveness operationalization to function
test$a <- 1 #define consecutive observation within countries
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg1 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg1)
#Model 2
test <- subset(plur, !is.na(plur$vap)&!is.na(plur$gomargin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$vap
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg2 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg2)
#Model 3
test <- subset(plur, !is.na(plur$vap)&!is.na(plur$unevenpf)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent))
test$turnout<- test$vap
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg3 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg3)
#Model 4
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$margin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$rv
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg4 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg4)
#Model 5
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$gomargin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$rv
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg5 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg5)
#Model 6
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$unevenpf)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent))
test$turnout<- test$rv
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg6 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg6)
#Model 7
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$margin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg7 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg7)
#Model 8
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$gomargin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg8 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg8)
#Model 9
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$unevenpf)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg9 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg9)
#Model 10
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$margin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent)&!is.na(prmix$unevenpf))
test$turnout<- test$rv
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg10 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg10)
#Model 11
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$gomargin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent)&!is.na(prmix$unevenpf))
test$turnout<- test$rv
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg11 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg11)
#Model 12
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$unevenpf)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$rv
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg12<- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg12)
##################################
#Boundary Values #
#Figure 3 #
##################################
#steps are annotated in first model only, and then repeated for following models
reg1d <- as.data.frame( cbind(reg1$model$comp, reg1$fitted.values, reg1$model$elau)) #Extract Values for Competitiveness, fitted values and Regimetype
reg1d$V3[reg1d$V3==1] <- "Electoral Autocracy" #Define character Strings for regime type
reg1d$V3[reg1d$V3==0] <- "Democracy"
names(reg1d)[names(reg1d)=="V3"] <- "Regime"
reg1d$V4 <- NA #Create new variable for interquartile range
reg1d$V4[reg1d$V1<=quantile(reg1d$V1, 0.25)] <- "lower" #set character strings for lower and upper bound
reg1d$V4[reg1d$V1>=quantile(reg1d$V1, 0.75)] <- "upper"
reg1d <- subset(reg1d, !is.na(reg1d$V4))
preg1 <- ggplot(reg1d, aes(y=V2, x=V4))+ #create plot
geom_boxplot(aes(fill=Regime))+xlab("")+
ggtitle("Plurality/Majority", subtitle = "Model 1")+
ylim(40,85)+ylab("Turnout (VAP)")+
scale_fill_manual(values = c("gray85", "grey45"))+
theme_bw()+theme(axis.text.y=element_blank())+
theme_bw()+theme_bw()
reg2d <- as.data.frame( cbind(reg2$model$comp, reg2$fitted.values, reg2$model$elau))
reg2d$V3[reg2d$V3==1] <- "Electoral Autocracy"
reg2d$V3[reg2d$V3==0] <- "Democracy"
names(reg2d)[names(reg2d)=="V3"] <- "Regime"
reg2d$V4 <- NA
reg2d$V4[reg2d$V1<=quantile(reg2d$V1, 0.25)] <- "lower"
reg2d$V4[reg2d$V1>=quantile(reg2d$V1, 0.75)] <- "upper"
reg2d <- subset(reg2d, !is.na(reg2d$V4))
preg2 <- ggplot(reg2d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 2")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg3d <- as.data.frame( cbind(reg3$model$comp, reg3$fitted.values, reg3$model$elau))
reg3d$V3[reg3d$V3==1] <- "Electoral Autocracy"
reg3d$V3[reg3d$V3==0] <- "Democracy"
names(reg3d)[names(reg3d)=="V3"] <- "Regime"
reg3d$V4 <- NA
reg3d$V4[reg3d$V1==0] <- "<1"
reg3d$V4[reg3d$V1>=2] <- "\u2265 2"
reg3d <- subset(reg3d, !is.na(reg3d$V4))
preg3 <- ggplot(reg3d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 3")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg4d <- as.data.frame( cbind(reg4$model$comp, reg4$fitted.values, reg4$model$elau))
reg4d$V3[reg4d$V3==1] <- "Electoral Autocracy"
reg4d$V3[reg4d$V3==0] <- "Democracy"
names(reg4d)[names(reg4d)=="V3"] <- "Regime"
reg4d$V4 <- NA
reg4d$V4[reg4d$V1<=quantile(reg4d$V1, 0.25)] <- "lower"
reg4d$V4[reg4d$V1>=quantile(reg4d$V1, 0.75)] <- "upper"
reg4d <- subset(reg4d, !is.na(reg4d$V4))
preg4 <- ggplot(reg4d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 4")+ylim(40,85)+ylab("Turnout (RV)")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg5d <- as.data.frame( cbind(reg5$model$comp, reg5$fitted.values, reg5$model$elau))
reg5d$V3[reg5d$V3==1] <- "Electoral Autocracy"
reg5d$V3[reg5d$V3==0] <- "Democracy"
names(reg5d)[names(reg5d)=="V3"] <- "Regime"
reg5d$V4 <- NA
reg5d$V4[reg5d$V1<=quantile(reg5d$V1, 0.25)] <- "lower"
reg5d$V4[reg5d$V1>=quantile(reg5d$V1, 0.75)] <- "upper"
reg5d <- subset(reg5d, !is.na(reg5d$V4))
preg5 <- ggplot(reg5d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 5")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg6d <- as.data.frame( cbind(reg6$model$comp, reg6$fitted.values, reg6$model$elau))
reg6d$V3[reg6d$V3==1] <- "Electoral Autocracy"
reg6d$V3[reg6d$V3==0] <- "Democracy"
names(reg6d)[names(reg6d)=="V3"] <- "Regime"
reg6d$V4 <- NA
reg6d$V4[reg6d$V1==0] <- "<1"
reg6d$V4[reg6d$V1>=2] <- "\u2265 2"
reg6d <- subset(reg6d, !is.na(reg6d$V4))
preg6 <- ggplot(reg6d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 6")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg7d <- as.data.frame( cbind(reg7$model$comp, reg7$fitted.values, reg7$model$elau))
reg7d$V3[reg7d$V3==1] <- "Electoral Autocracy"
reg7d$V3[reg7d$V3==0] <- "Democracy"
names(reg7d)[names(reg7d)=="V3"] <- "Regime"
reg7d$V4 <- NA
reg7d$V4[reg7d$V1<=quantile(reg7d$V1, 0.25)] <- "lower"
reg7d$V4[reg7d$V1>=quantile(reg7d$V1, 0.75)] <- "upper"
reg7d <- subset(reg7d, !is.na(reg7d$V4))
preg7 <- ggplot(reg7d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("PR/Mixed", subtitle = "Model 7")+ylim(40,85)+ylab("Turnout (VAP)")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg8d <- as.data.frame( cbind(reg8$model$comp, reg8$fitted.values, reg8$model$elau))
reg8d$V3[reg8d$V3==1] <- "Electoral Autocracy"
reg8d$V3[reg8d$V3==0] <- "Democracy"
names(reg8d)[names(reg8d)=="V3"] <- "Regime"
reg8d$V4 <- NA
reg8d$V4[reg8d$V1<=quantile(reg8d$V1, 0.25)] <- "lower"
reg8d$V4[reg8d$V1>=quantile(reg8d$V1, 0.75)] <- "upper"
reg8d <- subset(reg8d, !is.na(reg8d$V4))
preg8 <- ggplot(reg8d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 8")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg9d <- as.data.frame( cbind(reg9$model$comp, reg9$fitted.values, reg9$model$elau))
reg9d$V3[reg9d$V3==1] <- "Electoral Autocracy"
reg9d$V3[reg9d$V3==0] <- "Democracy"
names(reg9d)[names(reg9d)=="V3"] <- "Regime"
reg9d$V4 <- NA
reg9d$V4[reg9d$V1==0] <- "<1"
reg9d$V4[reg9d$V1>=2] <- "\u2265 2"
reg9d <- subset(reg9d, !is.na(reg9d$V4))
preg9 <- ggplot(reg9d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("")+ggtitle("", subtitle = "Model 9")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg10d <- as.data.frame( cbind(reg10$model$comp, reg10$fitted.values, reg10$model$elau))
reg10d$V3[reg10d$V3==1] <- "Electoral Autocracy"
reg10d$V3[reg10d$V3==0] <- "Democracy"
names(reg10d)[names(reg10d)=="V3"] <- "Regime"
reg10d$V4 <- NA
reg10d$V4[reg10d$V1<=quantile(reg10d$V1, 0.25)] <- "lower"
reg10d$V4[reg10d$V1>=quantile(reg10d$V1, 0.75)] <- "upper"
reg10d <- subset(reg10d, !is.na(reg10d$V4))
preg10 <- ggplot(reg10d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("Margin of Victory")+ggtitle("", subtitle = "Model 10")+ylim(40,85)+ylab("Turnout (RV)")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg11d <- as.data.frame( cbind(reg11$model$comp, reg11$fitted.values, reg11$model$elau))
reg11d$V3[reg11d$V3==1] <- "Electoral Autocracy"
reg11d$V3[reg11d$V3==0] <- "Democracy"
names(reg11d)[names(reg11d)=="V3"] <- "Regime"
reg11d$V4 <- NA
reg11d$V4[reg11d$V1<=quantile(reg11d$V1, 0.25)] <- "lower"
reg11d$V4[reg11d$V1>=quantile(reg11d$V1, 0.75)] <- "upper"
reg11d <- subset(reg11d, !is.na(reg11d$V4))
preg11 <- ggplot(reg11d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("Gov.-Opp. Margin")+ggtitle("", subtitle = "Model 11")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
reg12d <- as.data.frame( cbind(reg12$model$comp, reg12$fitted.values, reg12$model$elau))
reg12d$V3[reg12d$V3==1] <- "Electoral Autocracy"
reg12d$V3[reg12d$V3==0] <- "Democracy"
names(reg12d)[names(reg12d)=="V3"] <- "Regime"
reg12d$V4 <- NA
reg12d$V4[reg12d$V1==0] <- "<1"
reg12d$V4[reg12d$V1>=2] <- "\u2265 2"
reg12d <- subset(reg12d, !is.na(reg12d$V4))
preg12 <- ggplot(reg12d, aes(y=V2, x=V4))+geom_boxplot(aes(fill=Regime))+xlab("Uneven Playing Field")+ggtitle("", subtitle = "Model 12")+ylim(40,85)+ylab("")+scale_fill_manual(values = c("gray85", "grey45"))+ theme_bw()+theme(axis.text.y=element_blank())+ theme_bw()+theme_bw()
#
ggarrange(preg1, preg2, preg3, preg4, preg5, preg6,preg7,preg8,preg9,preg10,preg11,preg12, nrow = 4, ncol=3, common.legend = T, legend="bottom", widths = c(18, 18,18))
#############################################
#Marginal Effects (Appendix 1) #
#############################################
par(mfrow=c(4,3), mar = c(4,4,1.5,1))
#Model 1
beta.hat <- coef(reg1) #Extract regression coefficients
cov <- vcov(reg1) #extact covariance
z0 <- seq(min(na.omit(plur$margin)), max(na.omit(plur$margin)), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 1",
ylab = expression(partialdiff*paste("RV")), cex=3)
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 2
beta.hat <- coef(reg2)
cov <- vcov(reg2)
z0 <- seq(min(na.omit(abs(plur$gomargin))), max(na.omit(abs(plur$gomargin))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 2",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 3
beta.hat <- coef(reg3)
cov <- vcov(reg3)
z0 <- seq(min(na.omit(abs(plur$unevenpf))), max(na.omit(abs(plur$unevenpf))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 3",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 4
beta.hat <- coef(reg4)
cov <- vcov(reg4)
z0 <- seq(min(na.omit(plur$margin)), max(na.omit(plur$margin)), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 4",
xlab = "",
ylab = expression(partialdiff*paste("RV")))
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 5
beta.hat <- coef(reg5)
cov <- vcov(reg5)
z0 <- seq(min(na.omit(abs(plur$gomargin))), max(na.omit(abs(plur$gomargin))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 5",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 6
beta.hat <- coef(reg6)
cov <- vcov(reg6)
z0 <- seq(min(na.omit(abs(plur$unevenpf))), max(na.omit(abs(plur$unevenpf))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 6",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 7
beta.hat <- coef(reg7)
cov <- vcov(reg7)
z0 <- seq(min(na.omit(prmix$margin)), max(na.omit(prmix$margin)), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 7",
xlab = "",
ylab = expression(partialdiff*paste("VAP")))
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 8
beta.hat <- coef(reg8)
cov <- vcov(reg8)
z0 <- seq(min(na.omit(abs(prmix$gomargin))), max(na.omit(abs(prmix$gomargin))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 8",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 9
beta.hat <- coef(reg9)
cov <- vcov(reg9)
z0 <- seq(min(na.omit(abs(prmix$unevenpf))), max(na.omit(abs(prmix$unevenpf))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 9",
xlab = "",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 10
beta.hat <- coef(reg10)
cov <- vcov(reg10)
z0 <- seq(min(na.omit(prmix$margin)), max(na.omit(prmix$margin)), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 10",xlab = "Margin of Victory",
ylab = expression(partialdiff*paste("RV")), cex=3)
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 11
beta.hat <- coef(reg11)
cov <- vcov(reg11)
z0 <- seq(min(na.omit(abs(prmix$gomargin))), max(na.omit(abs(prmix$gomargin))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 11",xlab = "Gov.-Opp. Margin",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#Model 12
beta.hat <- coef(reg12)
cov <- vcov(reg12)
z0 <- seq(min(na.omit(abs(prmix$unevenpf))), max(na.omit(abs(prmix$unevenpf))), length.out = 1000)
dy.dx <- beta.hat["comp"] + beta.hat["comp:elau"]*z0
se.dy.dx <- sqrt(cov["elau", "elau"] + z0^2*cov["comp:elau", "comp:elau"] + 2*z0*cov["elau", "comp:elau"])
upr <- dy.dx + 1.64*se.dy.dx
lwr <- dy.dx - 1.64*se.dy.dx
plot(x=z0, y=dy.dx,type="l",xlim=c(min(z0),max(z0)),
ylim=c(-10, 30),
main="Model 12",
xlab = "Uneven Playing Field",
ylab = "")
lines(z0, dy.dx, lwd = 2)
lines(z0, lwr,lwd = 1)
lines(z0, upr,lwd = 1)
abline(h=0,lty=2)
#############################################
#Jackknife Analysis (Appendix 8 & 9) #
#############################################
#steps are annotated in first model only, and then repeated for following models
Consecutive <- function(input) #Function for the ommission of single countries
{
for (id in unique(input$iso))
{
input$number[input$iso== id] <-
ave(input$a[input$iso== id], cumsum(c(F, diff(input$a[input$iso== id]) !=0)),
FUN= cumsum)
}
return(input)
}
std <- function(x) sd(x)/sqrt(length(x)) #Standard deviation function
#Model 1 (Replication of respective data sets and regression models)
test <- subset(plur, !is.na(plur$vap)&!is.na(plur$margin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$vap
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg1 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
summary(reg1)
coefs <- sapply(c(unique(as.character(test$iso))), function (i) #Extraction of Regression Coefficients
summary(panelAR(Regression, data=subset(test, iso!=i),
panelVar = 'iso', timeVar = 'number',
autoCorr = "ar1", panelCorrMethod = "phet",
rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i) #Extraction of r2 values
summary(panelAR(Regression, data=subset(test, iso!=i),
panelVar = 'iso', timeVar = 'number',
autoCorr = "ar1", panelCorrMethod = "phet",
rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu)) #Creation of dataset for the calculation of Pseudovalues
pseudovalues$`(Intercept)` <- reg1[["coefficients"]][["(Intercept)"]]*reg1$panelStructure$N-pseudovalues$`(Intercept)`*(reg1$panelStructure$N-1)
pseudovalues$comp <- reg1[["coefficients"]][["comp"]]*reg1$panelStructure$N-pseudovalues$comp*(reg1$panelStructure$N-1)
pseudovalues$elau <- reg1[["coefficients"]][["elau"]]*reg1$panelStructure$N-pseudovalues$elau*(reg1$panelStructure$N-1)
pseudovalues$presidential <- reg1[["coefficients"]][["presidential"]]*reg1$panelStructure$N-pseudovalues$presidential*(reg1$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg1[["coefficients"]][["gnipercapitaconst"]]*reg1$panelStructure$N-pseudovalues$gnipercapitaconst*(reg1$panelStructure$N-1)
pseudovalues$elyear <- reg1[["coefficients"]][["elyear"]]*reg1$panelStructure$N-pseudovalues$elyear*(reg1$panelStructure$N-1)
pseudovalues$compulsory <- reg1[["coefficients"]][["compulsory"]]*reg1$panelStructure$N-pseudovalues$compulsory*(reg1$panelStructure$N-1)
pseudovalues$concurrent <- reg1[["coefficients"]][["concurrent"]]*reg1$panelStructure$N-pseudovalues$concurrent*(reg1$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg1[["coefficients"]][["comp:elau"]]*reg1$panelStructure$N-pseudovalues$`comp:elau`*(reg1$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg1$coefficients, reg1$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse #Calculation of Tcalc
jkreg1 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), #Creation of Dataset containing min coef, max coef, and t calc
c(apply(coefs, 2,max), max(rsqu)),
jack$tcalc))
names(jkreg1) <- c("reg1
Bmin", "Bmax", "tcalc")
jkreg1 <- round(jkreg1, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i) #Calculation of p values (Appendix 9)
summary(panelAR(Regression, data=subset(test, iso!=i),
panelVar = 'iso', timeVar = 'number',
autoCorr = "ar1", panelCorrMethod = "phet",
rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1] #Extraction of Iso-Codes for influential cases
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp) #Calculation of confidence interval
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 2
test <- subset(plur, !is.na(plur$vap)&!is.na(plur$gomargin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$vap
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg2 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg2[["coefficients"]][["(Intercept)"]]*reg2$panelStructure$N-pseudovalues$`(Intercept)`*(reg2$panelStructure$N-1)
pseudovalues$comp <- reg2[["coefficients"]][["comp"]]*reg2$panelStructure$N-pseudovalues$comp*(reg2$panelStructure$N-1)
pseudovalues$elau <- reg2[["coefficients"]][["elau"]]*reg2$panelStructure$N-pseudovalues$elau*(reg2$panelStructure$N-1)
pseudovalues$presidential <- reg2[["coefficients"]][["presidential"]]*reg2$panelStructure$N-pseudovalues$presidential*(reg2$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg2[["coefficients"]][["gnipercapitaconst"]]*reg2$panelStructure$N-pseudovalues$gnipercapitaconst*(reg2$panelStructure$N-1)
pseudovalues$elyear <- reg2[["coefficients"]][["elyear"]]*reg2$panelStructure$N-pseudovalues$elyear*(reg2$panelStructure$N-1)
pseudovalues$compulsory <- reg2[["coefficients"]][["compulsory"]]*reg2$panelStructure$N-pseudovalues$compulsory*(reg2$panelStructure$N-1)
pseudovalues$concurrent <- reg2[["coefficients"]][["concurrent"]]*reg2$panelStructure$N-pseudovalues$concurrent*(reg2$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg2[["coefficients"]][["comp:elau"]]*reg2$panelStructure$N-pseudovalues$`comp:elau`*(reg2$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg2$coefficients, reg2$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg2 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg2) <- c("reg2
Bmin", "Bmax", "tcalc")
jkreg2 <- round(jkreg2, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 3
test <- subset(plur, !is.na(plur$vap)&!is.na(plur$unevenpf)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent))
test$turnout<- test$vap
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg3 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg3[["coefficients"]][["(Intercept)"]]*reg3$panelStructure$N-pseudovalues$`(Intercept)`*(reg3$panelStructure$N-1)
pseudovalues$comp <- reg3[["coefficients"]][["comp"]]*reg3$panelStructure$N-pseudovalues$comp*(reg3$panelStructure$N-1)
pseudovalues$elau <- reg3[["coefficients"]][["elau"]]*reg3$panelStructure$N-pseudovalues$elau*(reg3$panelStructure$N-1)
pseudovalues$presidential <- reg3[["coefficients"]][["presidential"]]*reg3$panelStructure$N-pseudovalues$presidential*(reg3$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg3[["coefficients"]][["gnipercapitaconst"]]*reg3$panelStructure$N-pseudovalues$gnipercapitaconst*(reg3$panelStructure$N-1)
pseudovalues$elyear <- reg3[["coefficients"]][["elyear"]]*reg3$panelStructure$N-pseudovalues$elyear*(reg3$panelStructure$N-1)
pseudovalues$compulsory <- reg3[["coefficients"]][["compulsory"]]*reg3$panelStructure$N-pseudovalues$compulsory*(reg3$panelStructure$N-1)
pseudovalues$concurrent <- reg3[["coefficients"]][["concurrent"]]*reg3$panelStructure$N-pseudovalues$concurrent*(reg3$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg3[["coefficients"]][["comp:elau"]]*reg3$panelStructure$N-pseudovalues$`comp:elau`*(reg3$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg3$coefficients, reg3$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg3 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg3) <- c("reg3
Bmin", "Bmax", "tcalc")
jkreg3 <- round(jkreg3, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 4
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$margin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$rv
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg4 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg4[["coefficients"]][["(Intercept)"]]*reg4$panelStructure$N-pseudovalues$`(Intercept)`*(reg4$panelStructure$N-1)
pseudovalues$comp <- reg4[["coefficients"]][["comp"]]*reg4$panelStructure$N-pseudovalues$comp*(reg4$panelStructure$N-1)
pseudovalues$elau <- reg4[["coefficients"]][["elau"]]*reg4$panelStructure$N-pseudovalues$elau*(reg4$panelStructure$N-1)
pseudovalues$presidential <- reg4[["coefficients"]][["presidential"]]*reg4$panelStructure$N-pseudovalues$presidential*(reg4$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg4[["coefficients"]][["gnipercapitaconst"]]*reg4$panelStructure$N-pseudovalues$gnipercapitaconst*(reg4$panelStructure$N-1)
pseudovalues$elyear <- reg4[["coefficients"]][["elyear"]]*reg4$panelStructure$N-pseudovalues$elyear*(reg4$panelStructure$N-1)
pseudovalues$compulsory <- reg4[["coefficients"]][["compulsory"]]*reg4$panelStructure$N-pseudovalues$compulsory*(reg4$panelStructure$N-1)
pseudovalues$concurrent <- reg4[["coefficients"]][["concurrent"]]*reg4$panelStructure$N-pseudovalues$concurrent*(reg4$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg4[["coefficients"]][["comp:elau"]]*reg4$panelStructure$N-pseudovalues$`comp:elau`*(reg4$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg4$coefficients, reg4$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg4 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg4) <- c("reg4
Bmin", "Bmax", "tcalc")
jkreg4 <- round(jkreg4, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 5
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$gomargin)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent)&!is.na(plur$unevenpf))
test$turnout<- test$rv
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg5 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg5[["coefficients"]][["(Intercept)"]]*reg5$panelStructure$N-pseudovalues$`(Intercept)`*(reg5$panelStructure$N-1)
pseudovalues$comp <- reg5[["coefficients"]][["comp"]]*reg5$panelStructure$N-pseudovalues$comp*(reg5$panelStructure$N-1)
pseudovalues$elau <- reg5[["coefficients"]][["elau"]]*reg5$panelStructure$N-pseudovalues$elau*(reg5$panelStructure$N-1)
pseudovalues$presidential <- reg5[["coefficients"]][["presidential"]]*reg5$panelStructure$N-pseudovalues$presidential*(reg5$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg5[["coefficients"]][["gnipercapitaconst"]]*reg5$panelStructure$N-pseudovalues$gnipercapitaconst*(reg5$panelStructure$N-1)
pseudovalues$elyear <- reg5[["coefficients"]][["elyear"]]*reg5$panelStructure$N-pseudovalues$elyear*(reg5$panelStructure$N-1)
pseudovalues$compulsory <- reg5[["coefficients"]][["compulsory"]]*reg5$panelStructure$N-pseudovalues$compulsory*(reg5$panelStructure$N-1)
pseudovalues$concurrent <- reg5[["coefficients"]][["concurrent"]]*reg5$panelStructure$N-pseudovalues$concurrent*(reg5$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg5[["coefficients"]][["comp:elau"]]*reg5$panelStructure$N-pseudovalues$`comp:elau`*(reg5$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg5$coefficients, reg5$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg5 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg5) <- c("reg5
Bmin", "Bmax", "tcalc")
jkreg5 <- round(jkreg5, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 6
test <- subset(plur, !is.na(plur$rv)&!is.na(plur$unevenpf)&!is.na(plur$presidential)&!is.na(plur$gnipercapitaconst)&!is.na(plur$compulsory)&!is.na(plur$concurrent))
test$turnout<- test$rv
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg6 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg6[["coefficients"]][["(Intercept)"]]*reg6$panelStructure$N-pseudovalues$`(Intercept)`*(reg6$panelStructure$N-1)
pseudovalues$comp <- reg6[["coefficients"]][["comp"]]*reg6$panelStructure$N-pseudovalues$comp*(reg6$panelStructure$N-1)
pseudovalues$elau <- reg6[["coefficients"]][["elau"]]*reg6$panelStructure$N-pseudovalues$elau*(reg6$panelStructure$N-1)
pseudovalues$presidential <- reg6[["coefficients"]][["presidential"]]*reg6$panelStructure$N-pseudovalues$presidential*(reg6$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg6[["coefficients"]][["gnipercapitaconst"]]*reg6$panelStructure$N-pseudovalues$gnipercapitaconst*(reg6$panelStructure$N-1)
pseudovalues$elyear <- reg6[["coefficients"]][["elyear"]]*reg6$panelStructure$N-pseudovalues$elyear*(reg6$panelStructure$N-1)
pseudovalues$compulsory <- reg6[["coefficients"]][["compulsory"]]*reg6$panelStructure$N-pseudovalues$compulsory*(reg6$panelStructure$N-1)
pseudovalues$concurrent <- reg6[["coefficients"]][["concurrent"]]*reg6$panelStructure$N-pseudovalues$concurrent*(reg6$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg6[["coefficients"]][["comp:elau"]]*reg6$panelStructure$N-pseudovalues$`comp:elau`*(reg6$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg6$coefficients, reg6$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg6 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg6) <- c("reg6
Bmin", "Bmax", "tcalc")
jkreg6 <- round(jkreg6, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 7
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$margin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg7 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg7[["coefficients"]][["(Intercept)"]]*reg7$panelStructure$N-pseudovalues$`(Intercept)`*(reg7$panelStructure$N-1)
pseudovalues$comp <- reg7[["coefficients"]][["comp"]]*reg7$panelStructure$N-pseudovalues$comp*(reg7$panelStructure$N-1)
pseudovalues$elau <- reg7[["coefficients"]][["elau"]]*reg7$panelStructure$N-pseudovalues$elau*(reg7$panelStructure$N-1)
pseudovalues$presidential <- reg7[["coefficients"]][["presidential"]]*reg7$panelStructure$N-pseudovalues$presidential*(reg7$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg7[["coefficients"]][["gnipercapitaconst"]]*reg7$panelStructure$N-pseudovalues$gnipercapitaconst*(reg7$panelStructure$N-1)
pseudovalues$elyear <- reg7[["coefficients"]][["elyear"]]*reg7$panelStructure$N-pseudovalues$elyear*(reg7$panelStructure$N-1)
pseudovalues$compulsory <- reg7[["coefficients"]][["compulsory"]]*reg7$panelStructure$N-pseudovalues$compulsory*(reg7$panelStructure$N-1)
pseudovalues$concurrent <- reg7[["coefficients"]][["concurrent"]]*reg7$panelStructure$N-pseudovalues$concurrent*(reg7$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg7[["coefficients"]][["comp:elau"]]*reg7$panelStructure$N-pseudovalues$`comp:elau`*(reg7$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg7$coefficients, reg7$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg7 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg7) <- c("reg7
Bmin", "Bmax", "tcalc")
jkreg7 <- round(jkreg7, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 8
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$gomargin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg8 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg8[["coefficients"]][["(Intercept)"]]*reg8$panelStructure$N-pseudovalues$`(Intercept)`*(reg8$panelStructure$N-1)
pseudovalues$comp <- reg8[["coefficients"]][["comp"]]*reg8$panelStructure$N-pseudovalues$comp*(reg8$panelStructure$N-1)
pseudovalues$elau <- reg8[["coefficients"]][["elau"]]*reg8$panelStructure$N-pseudovalues$elau*(reg8$panelStructure$N-1)
pseudovalues$presidential <- reg8[["coefficients"]][["presidential"]]*reg8$panelStructure$N-pseudovalues$presidential*(reg8$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg8[["coefficients"]][["gnipercapitaconst"]]*reg8$panelStructure$N-pseudovalues$gnipercapitaconst*(reg8$panelStructure$N-1)
pseudovalues$elyear <- reg8[["coefficients"]][["elyear"]]*reg8$panelStructure$N-pseudovalues$elyear*(reg8$panelStructure$N-1)
pseudovalues$compulsory <- reg8[["coefficients"]][["compulsory"]]*reg8$panelStructure$N-pseudovalues$compulsory*(reg8$panelStructure$N-1)
pseudovalues$concurrent <- reg8[["coefficients"]][["concurrent"]]*reg8$panelStructure$N-pseudovalues$concurrent*(reg8$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg8[["coefficients"]][["comp:elau"]]*reg8$panelStructure$N-pseudovalues$`comp:elau`*(reg8$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg8$coefficients, reg8$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg8 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg8) <- c("reg8
Bmin", "Bmax", "tcalc")
jkreg8 <- round(jkreg8, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 9
test <- subset(prmix, !is.na(prmix$vap)&!is.na(prmix$unevenpf)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$vap
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg9 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg9[["coefficients"]][["(Intercept)"]]*reg9$panelStructure$N-pseudovalues$`(Intercept)`*(reg9$panelStructure$N-1)
pseudovalues$comp <- reg9[["coefficients"]][["comp"]]*reg9$panelStructure$N-pseudovalues$comp*(reg9$panelStructure$N-1)
pseudovalues$elau <- reg9[["coefficients"]][["elau"]]*reg9$panelStructure$N-pseudovalues$elau*(reg9$panelStructure$N-1)
pseudovalues$presidential <- reg9[["coefficients"]][["presidential"]]*reg9$panelStructure$N-pseudovalues$presidential*(reg9$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg9[["coefficients"]][["gnipercapitaconst"]]*reg9$panelStructure$N-pseudovalues$gnipercapitaconst*(reg9$panelStructure$N-1)
pseudovalues$elyear <- reg9[["coefficients"]][["elyear"]]*reg9$panelStructure$N-pseudovalues$elyear*(reg9$panelStructure$N-1)
pseudovalues$compulsory <- reg9[["coefficients"]][["compulsory"]]*reg9$panelStructure$N-pseudovalues$compulsory*(reg9$panelStructure$N-1)
pseudovalues$concurrent <- reg9[["coefficients"]][["concurrent"]]*reg9$panelStructure$N-pseudovalues$concurrent*(reg9$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg9[["coefficients"]][["comp:elau"]]*reg9$panelStructure$N-pseudovalues$`comp:elau`*(reg9$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg9$coefficients, reg9$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg9 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg9) <- c("reg9
Bmin", "Bmax", "tcalc")
jkreg9 <- round(jkreg9, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 10
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$margin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent)&!is.na(prmix$unevenpf))
test$turnout<- test$rv
test$comp <- test$margin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg10 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg10[["coefficients"]][["(Intercept)"]]*reg10$panelStructure$N-pseudovalues$`(Intercept)`*(reg10$panelStructure$N-1)
pseudovalues$comp <- reg10[["coefficients"]][["comp"]]*reg10$panelStructure$N-pseudovalues$comp*(reg10$panelStructure$N-1)
pseudovalues$elau <- reg10[["coefficients"]][["elau"]]*reg10$panelStructure$N-pseudovalues$elau*(reg10$panelStructure$N-1)
pseudovalues$presidential <- reg10[["coefficients"]][["presidential"]]*reg10$panelStructure$N-pseudovalues$presidential*(reg10$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg10[["coefficients"]][["gnipercapitaconst"]]*reg10$panelStructure$N-pseudovalues$gnipercapitaconst*(reg10$panelStructure$N-1)
pseudovalues$elyear <- reg10[["coefficients"]][["elyear"]]*reg10$panelStructure$N-pseudovalues$elyear*(reg10$panelStructure$N-1)
pseudovalues$compulsory <- reg10[["coefficients"]][["compulsory"]]*reg10$panelStructure$N-pseudovalues$compulsory*(reg10$panelStructure$N-1)
pseudovalues$concurrent <- reg10[["coefficients"]][["concurrent"]]*reg10$panelStructure$N-pseudovalues$concurrent*(reg10$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg10[["coefficients"]][["comp:elau"]]*reg10$panelStructure$N-pseudovalues$`comp:elau`*(reg10$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg10$coefficients, reg10$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg10 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg10) <- c("reg10
Bmin", "Bmax", "tcalc")
jkreg10 <- round(jkreg10, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 11
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$gomargin)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent)&!is.na(prmix$unevenpf))
test$turnout<- test$rv
test$comp <- test$gomargin
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg11 <- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg11[["coefficients"]][["(Intercept)"]]*reg11$panelStructure$N-pseudovalues$`(Intercept)`*(reg11$panelStructure$N-1)
pseudovalues$comp <- reg11[["coefficients"]][["comp"]]*reg11$panelStructure$N-pseudovalues$comp*(reg11$panelStructure$N-1)
pseudovalues$elau <- reg11[["coefficients"]][["elau"]]*reg11$panelStructure$N-pseudovalues$elau*(reg11$panelStructure$N-1)
pseudovalues$presidential <- reg11[["coefficients"]][["presidential"]]*reg11$panelStructure$N-pseudovalues$presidential*(reg11$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg11[["coefficients"]][["gnipercapitaconst"]]*reg11$panelStructure$N-pseudovalues$gnipercapitaconst*(reg11$panelStructure$N-1)
pseudovalues$elyear <- reg11[["coefficients"]][["elyear"]]*reg11$panelStructure$N-pseudovalues$elyear*(reg11$panelStructure$N-1)
pseudovalues$compulsory <- reg11[["coefficients"]][["compulsory"]]*reg11$panelStructure$N-pseudovalues$compulsory*(reg11$panelStructure$N-1)
pseudovalues$concurrent <- reg11[["coefficients"]][["concurrent"]]*reg11$panelStructure$N-pseudovalues$concurrent*(reg11$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg11[["coefficients"]][["comp:elau"]]*reg11$panelStructure$N-pseudovalues$`comp:elau`*(reg11$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg11$coefficients, reg11$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg11 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg11) <- c("reg11
Bmin", "Bmax", "tcalc")
jkreg11 <- round(jkreg11, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Model 12
test <- subset(prmix, !is.na(prmix$rv)&!is.na(prmix$unevenpf)&!is.na(prmix$presidential)&!is.na(prmix$gnipercapitaconst)&!is.na(prmix$compulsory)&!is.na(prmix$concurrent))
test$turnout<- test$rv
test$comp <- test$unevenpf
test$a <- 1
for (id in unique(test$iso))
{
test$number[test$iso== id] <-
ave(test$a[test$iso== id], cumsum(c(F, diff(test$a[test$iso== id]) !=0)),
FUN= cumsum)
}
reg12<- panelAR(Regression, data=test, panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T)
coefs <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,1])
coefs <- t(coefs)
rsqu <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$r2)
pseudovalues <- cbind(coefs, as.data.frame(rsqu))
pseudovalues$`(Intercept)` <- reg12[["coefficients"]][["(Intercept)"]]*reg12$panelStructure$N-pseudovalues$`(Intercept)`*(reg12$panelStructure$N-1)
pseudovalues$comp <- reg12[["coefficients"]][["comp"]]*reg12$panelStructure$N-pseudovalues$comp*(reg12$panelStructure$N-1)
pseudovalues$elau <- reg12[["coefficients"]][["elau"]]*reg12$panelStructure$N-pseudovalues$elau*(reg12$panelStructure$N-1)
pseudovalues$presidential <- reg12[["coefficients"]][["presidential"]]*reg12$panelStructure$N-pseudovalues$presidential*(reg12$panelStructure$N-1)
pseudovalues$gnipercapitaconst <-reg12[["coefficients"]][["gnipercapitaconst"]]*reg12$panelStructure$N-pseudovalues$gnipercapitaconst*(reg12$panelStructure$N-1)
pseudovalues$elyear <- reg12[["coefficients"]][["elyear"]]*reg12$panelStructure$N-pseudovalues$elyear*(reg12$panelStructure$N-1)
pseudovalues$compulsory <- reg12[["coefficients"]][["compulsory"]]*reg12$panelStructure$N-pseudovalues$compulsory*(reg12$panelStructure$N-1)
pseudovalues$concurrent <- reg12[["coefficients"]][["concurrent"]]*reg12$panelStructure$N-pseudovalues$concurrent*(reg12$panelStructure$N-1)
pseudovalues$`comp:elau` <- reg12[["coefficients"]][["comp:elau"]]*reg12$panelStructure$N-pseudovalues$`comp:elau`*(reg12$panelStructure$N-1)
pseudovalues <- rbind(pseudovalues, c(reg12$coefficients, reg12$r2))
jackcoef <- c(colMeans(pseudovalues))
jackse <- c(std(pseudovalues[,1]),
std(pseudovalues[,2]),
std(pseudovalues[,3]),
std(pseudovalues[,4]),
std(pseudovalues[,5]),
std(pseudovalues[,6]),
std(pseudovalues[,7]),
std(pseudovalues[,8]),
std(pseudovalues[,9]),
std(pseudovalues[,10]))
jack <- as.data.frame(t(rbind(jackcoef, jackse)))
jack$tcalc <- jack$jackcoef/jack$jackse
jkreg12 <- as.data.frame(cbind(c(apply(coefs, 2,min), min(rsqu)), c(apply(coefs, 2,max), max(rsqu)), jack$tcalc))
names(jkreg12) <- c("reg12
Bmin", "Bmax", "tcalc")
jkreg12 <- round(jkreg12, 2)
pval <- sapply(c(unique(as.character(test$iso))), function (i)
summary(panelAR(Regression, data=subset(test, iso!=i), panelVar = 'iso', timeVar = 'number', autoCorr = "ar1", panelCorrMethod = "phet", rho.na.rm=T))$coef[,4])
pval <- t(pval)
pval <- as.data.frame(pval)
pval <- cbind(rownames(pval), pval)
pval$`rownames(pval)`[pval$comp>=0.1]
pval$`rownames(pval)`[pval$comp<0.1]
mean(pval$comp)-qnorm(0.975)*std(pval$comp)
mean(pval$comp)+qnorm(0.975)*std(pval$comp)
pval$`rownames(pval)`[pval$`comp:elau`>=0.1]
pval$`rownames(pval)`[pval$`comp:elau`<0.1]
mean(pval$`comp:elau`)-qnorm(0.975)*std(pval$`comp:elau`)
mean(pval$`comp:elau`)+qnorm(0.975)*std(pval$`comp:elau`)
#Appendix 8 - Table summary
tab_df(cbind(jkreg1, jkreg2, jkreg3, jkreg4, jkreg5, jkreg6))
tab_df(cbind(jkreg7, jkreg8, jkreg9, jkreg10, jkreg11, jkreg12))