#############################
# REPLICATION FILES FOR
#
# "Right-Peopling" the State: Nationalism, Historical Legacies, and Ethnic Cleansing in Europe, 1886-2020
# Carl Müller-Crepon, Guy Schvitz, Lars-Erik Cederman
# November 2023
#
# Forthcoming, Journal of Conflict Resolution
#############################

Introduction

The analysis has been carried out entirely in R. To install necessary R-packages, please run scripts/libraries.R.

The entire analysis can be replicated by running REPLICATION.R located in the root directory. The working directory of your R Session must point to the root of the replication directory. All tables, figures and numbers used to summarize the estimated models and other results are saved under results/*, into subdirectories figures, tables, numbers as appropriate. These directories are created by scripts/globals.R.

To set global values appropriate for your system, in particular the number of CPUs please adapt scripts/globals.R, particularly the value for "ncore" around line 18. The variable is currently set to 10 CPUs which might exceed the number of CPUs on your machine. Lowering the value will not affect the results.

R version 4.3.1 has been used on a Linux Server, running Ubuntu 22.04.2 LTS, using 40 CPUs. 

Run this file from the command line, for example on a Linux machine, as:
nohup Rscript REPLICATION.R  >replication.log>&1 &


#############################################
Replication directory 


- REPLICATE_ALL.R                     Main replication code, calls all files in scripts/
- codebook.pdf                        Codebook for all files in data/
- README.txt                          README file (this file)
- data/                               Data directory
   - country_grp_year_analysis.rds    Main analysis file. One row for each country-group-year, .rds format
   - fearonlist.csv                   Link of Fearon's List to language tree
   - Fearon_List.dta                  Fearon's List of comparison with HEG data
   - sys_homogeneity.rds              Data for nation-to-state alignment analysis
   - sys_homogeneity_tv.rds           Data for nation-to-state alignment analysis, w/ smoothed HEG data         
   - country_grp_year_analysis.csv    Main analysis file. One row for each country-group-year, .csv format             
   - ethnic_cleansing_list.csv        List of cases of ethnic cleansing         
   - heg_map_points.rds               HEG data as points, for Figure 5  
   - poles_1918.tif                   Raster of Poles in 1918, Figure 4c
   - poles_1951.tif                   Raster of Poles in 1951, Figure 4c
   - poles_shapes.rds                 Shapefiles for Poles, Figure 4a
   - heg_meta.csv                     HEG Metadata, for Figure 3
   - census_AH_comparison.rds         Comparison data HEP to Austria-Hungary census        
   - compare_heg_df.rds               Comparisons among HEG maps, for Figure A4
   - heg_extent_main.geojson          Spatial Extent of HEG data, for Figure 5       
- scripts/                            Directory with all R-scripts      
  - analysis_functions.R              Functions needed for analysis   
  - analysis_groupboot.R              Bootstrapped standard errors, Figure 7   
  - analysis_main.R                   Main analysis, in particular Tables 1 and 2, and A1
  - heter_vdem.R                      Heterogeneity by level of democracy, Table A8
  - heg_comparison_plot.R             Comparisons among HEG maps, Figure A4
  - maps_descr.R                      Descriptive maps: Figures 4 and 6
  - map_heg_all.R                     Full HEG map, Figure 5
  - rightpeopling_macroplot.R         State-to-nation alignment, Figure 8   
  - robcheck_controls.R               Robustness: dropping and adding controls, Tables A3 and A5  
  - robcheck_fixeffs.R                Robustness: dropping and adding fixed effects, Table A4 and A6 
  - robcheck_logit.R                  Robustness: Logistic regression, Table A2
  - robcheck_noww.R                   Robustness: dropping world wars, Table A7
  - robcheck_randinf.R                Robustness: Randomization inference, Figure A1 
  - validation_ah_census.R            Validation with Austria-Hungary census, cited in text     
  - validation_fearon.R               Validation with Fearon's List, cited in text   
  - libraries.R                       Installation of libraries
  - globals.R                         Setting all globals for the analysis
  - load_data.R                       Loads main dataset
