##########################################
# Roads to Rule, Roads to Rebel: Relational State Capacity and Conflict in Africa
#
# Main Replication File
#
# Journal of Conflict Resolution, 2020
#
# Carl Müller-Crepon, Philipp Hunziker, Lars-Erik Cederman
# 
# Corresponding author: c.a.muller-crepon@lse.ac.uk
###########################################


This directory contains all data and code necessary to replicate the 
results of the study entitled "Roads to Rule, Roads to Rebel: Relational
State Capacity and Conflict in Africa". Please cite the original paper
when drawing on the replication data.


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

The directory contains:

- replicate_all.R: Main R file to replicate all Figures and Tables in the main paper and the Appendix.
      The script calls all code contained in the subdirectory scripts/. All necessary packages are 
      install automatically if they are not already. 

- scripts/ : Contains single R code files for all parts of the analysis.
    Preparation:
    - prepare_functions.R : Functions, libraries, and globals
    - prepare_data.R : Loads data from data/*
    - prepare_specification.R : Sets up the main specifications used throughout the analysis
    
    Main Paper:
    - main_tables.R : Tables in main paper
    - main_figures.R : Figures in main paper
    
    Appendix:
    - appendix_descriptives.R : Summary statistics and descriptive statistics in Appendix, 
          Tables A2 and A3
    - robcheck_ols.R : All OLS robustness checks. Estimates models that feed Figures A7-A11 and Table A4
    - robcheck_iv.R : All 2SLS-IV robustness checks. Estimates models that feed Figures A7-A11, and A16-A17, 
          as well as Tables A6-A8
    - robcheck_crosssection.R : Analysis for Appendix A4.8 and Figure A12, both OLS and 2SLS-IV
    - robcheck_plot.R : Makes all plots of the robustness checks, Figures A7-A12
    - appendix_mapsplots.R : Produces maps and plots in Appendix, in particular: 
          Figure A5, A6, A13, A14, A15, and Table A5.
    
    

- data/
    - conflictroads_data.rds : Contains a list (data.ls) with the main
          data produced for spatial polygons from Ethnologue / WLMS, GREG, Murdock. 
          See below for guide to variable names
    - conflictroads_crosssec.rds : Contains a list of two cross-sectional datasets 
          (in borders at independence and 1990) for
          robustness checks in Appendix A4.8. See below for guide to variable names.
    - speed_viamichelin.csv : Speed-data retrieve from viamichelin.com
    - mich_google_comp.rds : Comparison of travel times retrieved from Google and 
          computed on Michelin-map-based road networks.
    - opt_*.rds : Inputs for and descriptive statistics on the road network simulation.
    - hyde_firstyear.csv : First year with observed subnational census data used in HYDE population back-projection.
          Used in robustness check Appendix A6.2
    - networks/ : selected observed (*_obsnw.rds) and simulated road networks (*_opt*.rds) for Uganda (500_*),
          Zambia (551_*), Mali (432_*), and Senegal (433_*).
    - shapefiles/ : Selected WLMS / Ethnologue Polygons (groups.select.shp) and 
          roads in the DR Congo (drc_roads_1966.shp)
          
- results/
    - figures : Created through replicate_all.R
    - tables : Created through replicate_all.R
          

VARIABLE DESCRIPTIONS #####################

The following describes the variable names of the main datasets contained in
conflictroads_data.rds. The data in conflictroads_crosssec.rds follows the 
same convention. 


# ID Variables: 
ethno.id: WMLS polygon ID (in respective data)
NAM_LABEL: Language name of WMLS polygon
greg.id: unique GREG group by country
group: GREG ID (as G1ID, G2ID and G3ID in original data from Weidmann et al.)
gid: Murdock ID (in respective data)
name: Murdock group name (in respective data)
id: ID for polygon x country
cowcode: Correlates of War countrycode
cntry_name: Country name (from cshapes)
area: Country area (from cshapes)
year: Year
cow.year: cowcode x year
cow.period.id: Country period ID with stable country-borders (from cshapes)


# Outcome measures

## ACLED (see ACLED codebook for details)
challenger.num           No. of challengers
acled.nonstateorg.count  No. of fighting events between challengers
acled.state.count        No. of events challenger-state
acled.nonstateorg.fatal  Fatalities in  between-challenger events
acled.state.fatal        Fatalities in challenger-state events
rebel.num                Number of rebel groups
militia.num              Number of militias
acled.rebel.m.count      No. events rebels vs. all challengers
acled.militia.count      No. events militias vs. all challengers
acled.staterebel.count   No. events state vs. rebels
acled.statemilitia.count No. events state vs. militias
acled.riot.demo.count    No. riot and demonstration events
acled.viol.civil.count   No. violence against civilian events
acled.battle.count       No. of battles in general
acled.remote.viol.count  No. of remote violence events.

## UCDP GED (see UCDP GED codebook for details)
state.events             Events of fighting of rebels against the state. 
onesided.events          One-sided violence events. 
nonstate.events          Communal violence events. 

## SCAD (see SCAD codebook for details)
scad.provgov.count       Number of events involving pro-government militias
scad.anti.gov.count      Number of events involving anti-government militias
scad.extra.gov.count     Number of events involving extra-government militias


# Relational state capacity 

## Observed (1966 and 1990)

### On roads
rsc.1966                 RSC on 1966 roads; Eq. 3 in main paper
rsc.1990                 RSC on 1990 roads; Eq. 3 in main paper
road.capital.mean.1966   State acces on 1966 roads; Eq 1 in main paper
road.internal.mean.1966  Internal connectedness on 1966 roads; Eq 2 in main paper
road.capital.mean.1990   State acces on 1990 roads; Eq 1 in main paper
road.internal.mean.1990  Internal connectedness on 1990 roads; Eq 2 in main paper

### Foot-path equivalents
foot.capital.mean.1966   State acces by foot (1966 network structure); Eq 1 in main paper
foot.internal.mean.1966  Internal connectedness by foot (1966 network structure); Eq 2 in main paper
foot.capital.mean.1990   State acces by foot (1990 network structure); Eq 1 in main paper
foot.internal.mean.1990  Internal connectedness by foot (1990 network structure); Eq 2 in main paper

## Simulated (see IV analysis, main paper)
The following variables are equivalent to the ones above, 
only computed on the simulated/'optimal' (opt.*) road networks,
simulated with 1880 population data and either road mileage from 1966 or 1990.
  opt.road.capital.mean.1880.1966
  opt.road.internal.mean.1880.1966
  opt.foot.capital.mean.1880.1966
  opt.foot.internal.mean.1880.1966
  opt.road.capital.mean.1880.1990
  opt.road.internal.mean.1880.1990
  opt.foot.capital.mean.1880.1990
  opt.foot.internal.mean.1880.1990


# Main control variables

## Population
pop Population  (HYDE data)
pop.urban Urban population (HYDE data)
opt.pop.graph.1880.1966  Population 1880 (corresponds to network simulation, for IV analysis)
opt.pop.graph.1880.1990  Population 1880 (corresponds to network simulation, for IV analysis)

## Group size
poly.area.km2 Size of ethnic group polygon in km2

## Geography & climate
median.altitude          average Altitude (FAO GAEZ)
median.slope             average sloge (FAO GAEZ)
precipitation            average precipitation (FAO GAEZ)
evapotranspiration       avg. evapotranspiration (FAO GAEZ)
ppetratio                precipitation / evapotranspiration (FAO GAEZ)
temperaturemean          avg. temperature (FAO GAEZ)
max.cash.crop            Cash crop suitability (see footnote 14) (FAO GAEZ)
suit                     Agricultural suitability (Ramankutty et al. 2002)
mindeposit.any           Dummy for mineral deposit (Schulz and Briskey 2005)

## Distances
dist.coast               Distance to coastline
dist.river               Distance to next navibalbe river
is.capital               Ethnic group settlement area contains capital 
border.dist              Distance to border


# Murdock ethnographic atlas (Appendix A4.4)
v33.num                  Precolonial centralization (Murdock, 1967)
v28.num                  Agriculture intensity (Murdock, 1967)
v2.num                   Dependence on hunting (Murdock, 1967)
v3.num                   Dependence on fishing (Murdock, 1967)
v4.num                   Dependence on animal husbandry (Murdock, 1967)
v5.num                   Dependence on agriculture (Murdock, 1967)


# Landcover  (Appendix A4.4)
Pasturelandusedforgrazing  Landcover type (FAO GAEZ)
Savanna                  Landcover type (FAO GAEZ)
Tropicalwoodland         Landcover type (FAO GAEZ)
Tropicalforest           Landcover type(FAO GAEZ)


# Economic activity & mrket acces  (Appendix A4.9)
road.totinv.1966         Total, quality-weighted road stock in 1966, see Appx. A4.9
nightlights              Nightlights by year (National Geophysical Data Center, 2014)


# Connectedness to co-nationals  (Appendix A4.9)
road.external.mean.1966  1966 road travel time to all non-coethnics in same country, see Appx. A4.9. 
foot.external.mean.1966  1966 foot travel time to all non-coethnics in same country, see Appx. A4.9. 


# Area between ethnic group and capital  (Appendix A4.4)
The following variables are computed for the areas between an ethnic group 
and its capital. They follow the same definitions as their equivalents
above
  pop.ext, pop.urban.ext, poly.area.km2.ext, road.totinv.ext.1966,
  median.altitude.ext,median.slope.ext, precipitation.ext,
  evapotranspiration.ext,  ppetratio.ext , temperaturemean.ext, dist.coast.ext
  

# UPDATES ########

3.4.2025: Added "group" variable to greg data which contains the original G*ID; updated email address.