rm(list = ls())

############################## MP - Subgroup Effects  #############################


rm(list = ls())
require(stargazer)
require(starpolishr)
require(Hmisc)


## Source a function to make equations (to remove clutter)

make.equation <- function(dvs, ivs, interactions = c()){
  return(paste(dvs, "~", paste(c(ivs, interactions), sep = "", collapse = " + ")))
}


load("results/mp_heteffects_appendix.RData")

load("data/uganda_mp_full.RData")
dumMod <- d.ug.mp

varInfo <- read.csv("data/mp_analysis_varinfo.csv", stringsAsFactors = F)

## Create necessary QOIs for ggplot

alpha <- 0.05
lm.results$uci_95 <- lm.results$est + qnorm(alpha/2)*lm.results$se
lm.results$lci_95 <- lm.results$est - qnorm(alpha/2)*lm.results$se
alpha <- 0.10
lm.results$uci_90 <- lm.results$est + qnorm(alpha/2)*lm.results$se
lm.results$lci_90 <- lm.results$est - qnorm(alpha/2)*lm.results$se
lm.results$iv <- gsub("ngo", "NGO", lm.results$iv)
lm.results$iv <- gsub("Ngo", "NGO", lm.results$iv)
lm.results$iv <- gsub("nontax_direct", "Aid/Oil", lm.results$iv)
lm.results$reference_category <- gsub("non-ngo", "non-NGO", lm.results$reference_category)
lm.results$reference_category <- gsub("ngo", "NGO", lm.results$reference_category)
lm.results$reference_category <- gsub("non-tax", "non-Tax", lm.results$reference_category)
lm.results$iv <- gsub(":", " X ", lm.results$iv)
lm.results$iv <- gsub("services_poor", "Poor Serv", lm.results$iv)
lm.results$iv <- gsub("corr_high", "High Corr", lm.results$iv)
lm.results$iv <- gsub("female", "Female", lm.results$iv)
lm.results$iv <- gsub("mp_ruling", "Ruling Party", lm.results$iv)
#lm.results$iv <- capitalize(lm.results$iv)
lm.results$comparison <- paste(capitalize(lm.results$iv), "Treatment,",
                               capitalize(lm.results$reference_category), "Control", sep=" ")
lm.results$comparison <- gsub("Ngo", "NGO", lm.results$comparison)



###### Influence Measures (Tax-Aid) -- UGANDA
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="influence"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="influence"]

badserv <- lm.results[lm.results$comparison %in% c("Tax X Poor Serv Treatment, Aid Control")
                      & lm.results$var_group == "influence"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Tax X High Corr Treatment, Aid Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

rulparty <- lm.results[lm.results$comparison %in% c("Tax X Ruling Party Treatment, Aid Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}


#Table S98. Uganda MPs: Influence Index, Tax Treatment-Aid Control, Het. Effects Results
host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model
tab.s98 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:influence:taxaid:het", 
          title = "Uganda MPs: Influence Index, Tax Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s98 <- star_notes_tex(tab.s98, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s98, file = paste0(getwd(),"/tables/s98.tex"),sep="\n") 




## Ghana - Inluence (Tax-Aid)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S99: Ghana MPs: Influence Index, Tax Treatment-Aid Control, Het. Effects Results
tab.s99 <-  stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:influence:taxaid:het", 
          title = "Ghana MPs: Influence Index, Tax Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s99 <- star_notes_tex(tab.s99, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s99, file = paste0(getwd(),"/tables/s99.tex"),sep="\n") 

###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="influence"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="influence"]

badserv <- lm.results[lm.results$comparison %in% c("Oil X Poor Serv Treatment, Aid Control")
                      & lm.results$var_group == "influence"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Oil X High Corr Treatment, Aid Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

rulparty <- lm.results[lm.results$comparison %in% c("Oil X Ruling Party Treatment, Aid Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S100. Uganda MPs: Influence Index, Oil Treatment-Aid Control, Het. Effects Results
tab.s100 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:influence:oilaid:het", 
          title = "Uganda MPs: Influence Index, Oil Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s100 <- star_notes_tex(tab.s100, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s100, file = paste0(getwd(),"/tables/s100.tex"),sep="\n") 



## Ghana - Influence (Oil-Aid)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S101. Ghana MPs: Influence Index, Oil Treatment-Aid Control, Het. Effects Results
tab.s101 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:influence:oilaid:het", 
          title = "Ghana MPs: Influence Index, Oil Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s101 <- star_notes_tex(tab.s101, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s101, file = paste0(getwd(),"/tables/s101.tex"),sep="\n") 




###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="influence"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="influence"]

badserv <- lm.results[lm.results$comparison %in% c("Tax X Poor Serv Treatment, Oil Control")
                      & lm.results$var_group == "influence"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Tax X High Corr Treatment, Oil Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

rulparty <- lm.results[lm.results$comparison %in% c("Tax X Ruling Party Treatment, Oil Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])

coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S102. Uganda MPs: Influence Index, Tax Treatment-Oil Control, Het. Effects Results
tab.s102 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption",  "Ruling Party"), 
          label = "tab:ug:mp:influence:taxoil:het", 
          title = "Uganda MPs: Influence Index, Tax Treatment-Oil Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s102 <- star_notes_tex(tab.s102, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s102, file = paste0(getwd(),"/tables/s102.tex"),sep="\n") 



## Ghana - Influence (Tax-Oil)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S103. Ghana MPs: Influence Index, Tax Treatment-Oil Control, Het. Effects Results
tab.s103 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:influence:taxoil:het", 
          title = "Ghana MPs: Influence Index, Tax Treatment-Oil Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s103 <- star_notes_tex(tab.s103, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s103, file = paste0(getwd(),"/tables/s103.tex"),sep="\n") 


###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="influence"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="influence"]

badserv <- lm.results[lm.results$comparison %in% c("NGO X Poor Serv Treatment, Non-NGO Control")
                      & lm.results$var_group == "influence"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("NGO X High Corr Treatment, Non-NGO Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]


rulparty <- lm.results[lm.results$comparison %in% c("NGO X Ruling Party Treatment, Non-NGO Control")
                       & lm.results$var_group == "influence"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])

coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S104. Uganda MPs: Influence Index, NGO Treatment-non-NGO Control, Het. Effects Results
tab.s104 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:influence:ngonon:het", 
          title = "Uganda MPs: Influence Index, NGO Treatment-non-NGO Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s104 <- star_notes_tex(tab.s104, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s104, file = paste0(getwd(),"/tables/s104.tex"),sep="\n") 


## Ghana - Influence (NGO-non-NGO)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S105. Ghana MPs: Influence Index, NGO Treatment-non-NGO Control, Het. Effects Results
tab.s105 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:influence:ngonon:het", 
          title = "Ghana MPs: Influence Index, NGO Treatment-non-NGO Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s105 <- star_notes_tex(tab.s105, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s105, file = paste0(getwd(),"/tables/s105.tex"),sep="\n") 



########################### BENEFIT INDEX  ################################

plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]

badserv <- lm.results[lm.results$comparison %in% c("Tax X Poor Serv Treatment, Aid Control")
                      & lm.results$var_group == "benefit"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Tax X High Corr Treatment, Aid Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]


rulparty <- lm.results[lm.results$comparison %in% c("Tax X Ruling Party Treatment, Aid Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}


#Table S90. Uganda MPs: Benefit Index, Tax Treatment-Aid Control, Het. Effects Results
host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model
tab.s90 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:benefit:taxaid:het", 
          title = "Uganda MPs: Benefit Index, Tax Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s90 <- star_notes_tex(tab.s90, note.type = "threeparttable", 
                           note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s90, file = paste0(getwd(),"/tables/s90.tex"),sep="\n") 


## Ghana - Benefit (Tax-Aid)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

# Table S91. Ghana MPs: Benefit Index, Tax Treatment-Aid Control, Het. Effects Results
tab.s91 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:benefit:taxaid:het", 
          title = "Ghana MPs: Benefit Index, Tax Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s91 <- star_notes_tex(tab.s91, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s91, file = paste0(getwd(),"/tables/s91.tex"),sep="\n") 



###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]

badserv <- lm.results[lm.results$comparison %in% c("Oil X Poor Serv Treatment, Aid Control")
                      & lm.results$var_group == "benefit"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Oil X High Corr Treatment, Aid Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]


rulparty <- lm.results[lm.results$comparison %in% c("Oil X Ruling Party Treatment, Aid Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S92. Uganda MPs: Benefit Index, Oil Treatment-Aid Control, Het. Effects Results
tab.s92 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:benefit:oilaid:het", 
          title = "Uganda MPs: Benefit Index, Oil Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s92 <- star_notes_tex(tab.s92, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s92, file = paste0(getwd(),"/tables/s92.tex"),sep="\n") 



## Ghana - Influence (Oil-Aid)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S93. Ghana MPs: Benefit Index, Oil Treatment-Aid Control, Het. Effects Results
tab.s93 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:benefit:oilaid:het", 
          title = "Ghana MPs: Benefit Index, Oil Treatment-Aid Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s93 <- star_notes_tex(tab.s93, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s93, file = paste0(getwd(),"/tables/s93.tex"),sep="\n") 


###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]

badserv <- lm.results[lm.results$comparison %in% c("Tax X Poor Serv Treatment, Oil Control")
                      & lm.results$var_group == "benefit"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("Tax X High Corr Treatment, Oil Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]


rulparty <- lm.results[lm.results$comparison %in% c("Tax X Ruling Party Treatment, Oil Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])

coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S94. Uganda MPs: Benefit Index, Tax Treatment-Oil Control, Het. Effects Results
tab.s94 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption",  "Ruling Party"), 
          label = "tab:unimpaction", 
          title = "Uganda MPs: Benefit Index, Tax Treatment-Oil Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)

tab.s94 <- star_notes_tex(tab.s94, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s94, file = paste0(getwd(),"/tables/s94.tex"),sep="\n") 



## Ghana - Influence (Tax-Oil)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S95. Ghana MPs: Benefit Index, Tax Treatment-Oil Control, Het. Effects Results
tab.s95 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:benefit:taxoil:het", 
          title = "Ghana MPs: Benefit Index, Tax Treatment-Oil Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)


tab.s95 <- star_notes_tex(tab.s95, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s95, file = paste0(getwd(),"/tables/s95.tex"),sep="\n") 



###################
plotVars <- varInfo$var_name[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]
var_group <- c(plotVars) # Include all variable names you want to report
names(var_group) <- varInfo$var_label[varInfo$include_plot == 1 & varInfo$var_index=="benefit"]

badserv <- lm.results[lm.results$comparison %in% c("NGO X Poor Serv Treatment, Non-NGO Control")
                      & lm.results$var_group == "benefit"
                      & lm.results$dv %in% plotVars, ]

highcorr <- lm.results[lm.results$comparison %in% c("NGO X High Corr Treatment, Non-NGO Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]

rulparty <- lm.results[lm.results$comparison %in% c("NGO X Ruling Party Treatment, Non-NGO Control")
                       & lm.results$var_group == "benefit"
                       & lm.results$dv %in% plotVars, ]

res.list <- list(badserv[badserv$country == "uganda", ], 
                 highcorr[highcorr$country == "uganda", ],
                 rulparty[rulparty$country == "uganda", ])

coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

#Table S96. Uganda MPs: Benefit Index, NGO Treatment-non-NGO Control, Het. Effects Results
tab.s96 <- stargazer(host.model, host.model, host.model,  style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:ug:mp:benefit:ngonon:het", 
          title = "Uganda MPs: Benefit Index, NGO Treatment-non-NGO Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)


tab.s96 <- star_notes_tex(tab.s96, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s96, file = paste0(getwd(),"/tables/s96.tex"),sep="\n") 


## Ghana - Influence (NGO-non-NGO)

res.list <- list(badserv[badserv$country == "ghana", ], 
                 highcorr[highcorr$country == "ghana", ],
                 rulparty[rulparty$country == "ghana", ])


coef.list <- list()
for(j in 1:length(res.list)){
  coef.loop <- c()
  for(i in 1:length(var_group)){
    coef.loop <- c(coef.loop, res.list[[j]]$est[res.list[[j]]$dv == var_group[i]])
  }
  names(coef.loop) <- var_group
  coef.list[[j]] <- coef.loop
}

se.list <- list()
for(j in 1:length(res.list)){
  se.loop <- c()
  for(i in 1:length(var_group)){
    se.loop <- c(se.loop, res.list[[j]]$se[res.list[[j]]$dv == var_group[i]])
  }
  names(se.loop) <- var_group
  se.list[[j]] <- se.loop
}

p.list <- list()
for(j in 1:length(res.list)){
  p.loop <- c()
  for(i in 1:length(var_group)){
    p.loop <- c(p.loop, res.list[[j]]$p[res.list[[j]]$dv == var_group[i]])
  }
  names(p.loop) <- var_group
  p.list[[j]] <- p.loop
}



host.model <- lm(make.equation(dvs = "gov_public", ivs = var_group), data =dumMod) # -1 to account for intercept in host model

# Table S97. Ghana MPs: Benefit Index, NGO Treatment-non-NGO Control, Het. Effects Results
tab.s97 <- stargazer(host.model, host.model, host.model, style = "APSR", 
          colnames = T, omit="Constant", covariate.labels = c(names(var_group)), 
          coef = coef.list,
          se = se.list, 
          p = p.list,
          intercept.bottom = F,
          dep.var.labels.include = T, 
          dep.var.labels = c("Poor Services", "High Corruption", "Ruling Party"), 
          label = "tab:gh:mp:benefit:ngonon:het", 
          title = "Ghana MPs: Benefit Index, NGO Treatment-non-NGO Control, Het. Effects Results",
          omit.stat = c("all"),
          multicolumn = F, 
          model.numbers = T)


tab.s97 <- star_notes_tex(tab.s97, note.type = "threeparttable", 
                          note ="Estimates are based on Generalized Least Squares with enumerator fixed effects. Standard errors in parentheses. Reported estimates are interaction effects that test whether the effect of the treatment varies across potential moderators, including whether the respondent thought there was a poor level of public services in their district (Poor Services), reported high levels of corruption by politicians (Corrupt), and member of the ruling party.") 

cat(tab.s97, file = paste0(getwd(),"/tables/s97.tex"),sep="\n") 
