##########################################
# Local Ethno-Political Polarization and Election Violence in 
#         Majoritarian vs. Proportional Systems
#
# Main Replication File
#
# Journal of Peace Research, 2020
#
# Carl Müller-Crepon
# 
# Corresponding author: carl.muller-crepon@politics.ox.ac.uk
###########################################


This directory contains all data and code necessary to replicate the 
results of the study entitled "Local Ethno-Political Polarization and 
Election Violence in Majoritarian vs. Proportional Systems". 
Please cite the original paper when drawing on the replication data.


REPLICATION DIRECTORY #####################

The directory contains:

- replicate_rstats.R: Main R file to replicate all Figures and Tables in the main paper and the Appendix,
      except those computed with Stata.
      The script calls code contained in the subdirectory scripts/. All necessary packages are 
      install automatically if they are not already. 
      Run this file before running the stata code.

- replicate_stata.do: Main Stata file to replicate Tables A17-A19 in the main paper and the Appendix.
      The script calls code contained in the subdirectory scripts/. 

- scripts/ : Contains single R code files for all parts of the analysis.
    - install_pkgs.R : Installs packages needed for the analysis
    - analysis_riots.R : Riot data analysis
    - plot_riots.R : Plots for riot data analysis, called from within analysis_riots.R
    - analysis_ab : Afrobarometer data analsis
    - analysis_ordlogit.do: Stat code to estimate ordinal logits, Tables A17-A19
    - functions/ : R functions for Conley SE computation. 
    

- data/
    - elec_viol_ts_main.rds : Main time-series data (district x month) 
          for riot analysis
    - elec_viol_ts_kenya.rds : Time-series data for Kenyan constituencies (Table A9)
    - elec_viol_ts_stab.rds : Time-series data for stable district boundaries in 1990 (Table A6)
    - elec_viol_ts_vor1990.rds : Time-series data for stable Voronoi boundaries in 1990 (Table A6)
    - elec_viol_ts_vortv.rds : Time-series data for time-varian Voronoi boundaries (Table A6)
    - districts_ngb_df.rds : Neighbor data for districts to compute Moran's I
    - afrobarometer.rds /.dta : Afrobarometer data
    - afrobarometer_niguga.rds /.dta : Pre-election afrobarometer data from Nigeria and Uganda
    - shapefiles/ : Shapefiles for maps in paper: Administrative units in Kenya and Uganda, 
          Uganda Voronoi polygons, and lake data in Kenya
    
    
- results/
    - figures : Created & filled through replicate_rstats.R and replicate_stata.do
    - tables : Created & filled through replicate_rstats.R and replicate_stata.do
          