#############################
# REPLICATION FILES FOR
# 
# Dill, Janina, Howlett, Marnie, & Müller-Crepon, Carl (2025).
# Do Ukrainians Still Prefer Self-Defense Against Russia At Any Cost? 
# Journal of Peace Research, forthcoming.
#
# README FILE
# 
#############################

Introduction


The analysis has been carried out entirely in R. To install necessary R-packages, please run code/libraries.R. One might have to run the file multiple times until all librariers are successfully installed. In cases of uncertainty, this README file contains all package versions used at the very end. 

The entire analysis can be replicated by running REPLICATE_ALL.R. The working directory of your R Session must point to the root of the replication directory. All tables and figures used to summarize the estimated models and other results are saved under results/*, into subdirectories figures and tables as appropriate, overwriting the files that are stored there (which are the original ones used in the article). See file descriptions below for a mapping of figure/table filenames to figure and table numbers in the paper and appendix. 

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


#############################################
Overall workflow

All analyses code files can be found under code/*. All results they produce are saved under results/* as figures and tables into the respective subdirectories. All analysis R-code is called by the main REPLICATE_ALL.R file.


#############################################
R version 4.5.1 has been used for the analysis on a Linux Server, running Ubuntu 24.04.3 LTS


##########################################   
Directory structure and description

|-- replication                           Root directory
    |-- codebook.pdf                      pdf file with codebook
    |-- README                            Readme file. Please consult. 
    |-- REPLICATE_ALL.R                   R-script to replicate all analyses.   
    
    |-- code                              Directory with all code sourced by REPLICATE_ALL.R            
    |   |-- analysis_main.R               Code for the main analysis. Produces Figures 2, 3, 5, and A23, and Table 2.
    |   |-- data_load.R                   Loads all data for the conjoint analysis.  
    |   |-- descriptives.R                Makes descriptive plots. Produces Figure 1    
    |   |-- functions.R                   File that contains self-written functions used in the analysis. 
    |   |-- globals.R                     Sets all globals for the analysis and loads packages.   
    |   |-- het_effects.R                 Heterogeneity analysis. Table A2-A4, Table A6, Figure 4, A8-A22      
    |   |-- libraries.R                   Checks and installs all necessary libraries.   
    |   |-- ranking.R                     Ranking analysis and nested marginal means. Table A7, Figures 7 and A29
    |   |-- robchecks.R                   Robustness checks. Figures A1-A6;  A25 - A28  
    |   |-- sample_characteristics.R      Sample characteristics and descriptives. Figures A1-A6;  A25 - A28  
    |   |-- within_location.R             Within location analysis. Figures A1-A6;  A25 - A28  
    
    |-- data                              Directory with all data to replicate analysis
    |   |-- acled_analysis.rds            ACLED data for Ukraine. Used for Figure 1         
    |   |-- data_long_analysis.rds        Long-form survey data. Eachrow = one strategy seen by a respondent. Experiments 0, 1, and 2.             
    |   |-- data_wide_analysis.rds        Wide-form survey data. One row = one respondent. Only experiments 1 and 2.              

    |   |-- adm_shapes                    Shapefile with regional borders in Ukraine. Used for Figure 1.  
    |       |-- gadm40_UKR_1.cpg          Part of shapefile           
    |       |-- gadm40_UKR_1.dbf          Part of shapefile            
    |       |-- gadm40_UKR_1.prj          Part of shapefile            
    |       |-- gadm40_UKR_1.shp          Main shapefile           
    |       |-- gadm40_UKR_1.shx          Part of shapefile 
    
    |-- replication.log                   Log file for the analysis run by the authors.          
    
    |-- results                           Directory containing all results
    
        |-- figures                       Directory with all figures
        |   |-- all_experiments_mainin_2022.png     AMCEs and Marginal Means, choice, all experiments, DHM sample, Figure A3
        |   |-- all_experiments_mainin_2022_score.png  AMCEs and Marginal Means, score, all experiments, DHM sample, Figure A4
        |   |-- all_experiments_mainin_2024.png     AMCEs and Marginal Means, choice, all experiments, main sample, Figure 1
        |   |-- all_experiments_mainin_2024_score.png  AMCEs and Marginal Means, score, all experiments, main sample, Figure A5
        |   |-- all_ranks_mm.png                    nested marginal means, Figure 4
        |   |-- all_win_rank_mm.png                 marginal means within ranks, all experiments, Figure A37      
        |   |-- demographic_comp.png                Demographic comparisons, Figure A2
        |   |-- exp12_amcie_choice.png              Average marginal component interaction effects on choice, for background information      
        |   |-- exp12_amcie_score.png               Average marginal component interaction effects on scores, for background information     
        |   |-- exp12_fsl_hetamce_diraffected.png   Heterogeneous AMCEs by region first affected by invasion, fixed slope, Figure A31                
        |   |-- exp12_fsl_hetamce_ethnic.png        Heterogeneous AMCEs by ethnic identity, fixed slope, Figure A24         
        |   |-- exp12_fsl_hetamce_lang.png          Heterogeneous AMCEs by interview language, fixed slope, Figure A22          
        |   |-- exp12_fsl_hetamce_natlang.png       Heterogeneous AMCEs by native language, fixed slope, Figure A26             
        |   |-- exp12_fsl_hetamce_region.png        Heterogeneous AMCEs by east vs west, fixed slope, Figure A29            
        |   |-- exp12_heteff_hetamce_aff_score.png  Heterogeneous AMCEs by affectedness score, Figure A27         
        |   |-- exp12_heteff_hetamce_age_5gr.png    Heterogeneous AMCEs by age group, for background information       
        |   |-- exp12_heteff_hetamce_battle_all_d.png    Heterogeneous AMCEs by battle event dummy, for background information       
        |   |-- exp12_heteff_hetamce_children.png   Heterogeneous AMCEs by children yes/no, for background information       
        |   |-- exp12_heteff_hetamce_diraffected.png     Heterogeneous AMCEs by region first affected by invasion, Figure A30   
        |   |-- exp12_heteff_hetamce_econdepr.png   Heterogeneous AMCEs by economic deprivation, for background information         
        |   |-- exp12_heteff_hetamce_educ.png       Heterogeneous AMCEs by education, for background information     
        |   |-- exp12_heteff_hetamce_ethnic.png     Heterogeneous AMCEs by ethnic identity, Figure A23       
        |   |-- exp12_heteff_hetamce_famaffected.png     Heterogeneous AMCEs by family affectedness, for background information       
        |   |-- exp12_heteff_hetamce_lang.png       Heterogeneous AMCEs by interview language, Figure A21   
        |   |-- exp12_heteff_hetamce_moved.png  Heterogeneous AMCEs by internal migration status, Figure A20       
        |   |-- exp12_heteff_hetamce_natlang.png    Heterogeneous AMCEs by native language, Figure A25    
        |   |-- exp12_heteff_hetamce_onesided_all_d.png  Heterogeneous AMCEs by onesided violence dummy, for background information      
        |   |-- exp12_heteff_hetamce_region.png     Heterogeneous AMCEs by east vs west, Figure A28      
        |   |-- exp12_heteff_hetamce_selfaffected.png    Heterogeneous AMCEs by respondents' affectedness, for background information        
        |   |-- exp12_heteff_hetamce_sex.png        Heterogeneous AMCEs by respondent gender, for background information  
        |   |-- exp12_heteff_hetamce_shelling_all_d.png  Heterogeneous AMCEs by shelling dummy, for background information           
        |   |-- exp12_heteff_hetamce_survnat.png    Heterogeneous AMCEs by "Survival of nation at stake", for background information       
        |   |-- exp12_heteff_hetamce_trustpres.png  Heterogeneous AMCEs by trust in president, Figure A33          
        |   |-- exp12_heteff_hetamce_urbrur.png     Heterogeneous AMCEs by Urban status, for background information      
        |   |-- exp12_heteff_hetamce_victimp.png    Heterogeneous AMCEs by "Importance of Victory", Figure A32        
        |   |-- exp12in_2024_heter_amce_ambiguity.png  Heterogeneous AMCEs by variation in attributes 1 and 5, Figure 3         
        |   |-- exp12in_2024_moder_amce_choice.png  heterogeneous AMCEs on choices by attribute 1 and 5 levels, Figure 2         
        |   |-- exp12in_2024_moder_amce_score.png   heterogeneous AMCEs on scores by attribute 1 and 5 levels.               
        |   |-- exp_12_main_afcp.png                Average Feature Choice Probabilities, Figure A14
        |   |-- exp12_main_amce_logit.png           Main AMCE estimates, logit, Figure A17   
        |   |-- exp12_main_lineffect.png            Average linear attribute effect, Figure A16   
        |   |-- exp12_moder_amce_lin_choice.png     heterogeneous AMCEs on coices by attribute 1 and 5 levels, linear interaction, Figure A8                    
        |   |-- exp12_moder_amce_lin_score.png      Heterogeneous AMCEs on scores by attribute 1 and 5 levels, linear interaction, Figure A11        
        |   |-- exp12_order_effects.png             Order effects, Figure A19 
        |   |-- exp12_se_clustering.png             Clustering standard errors, Figure A18  
        |   |-- exp12_weighted_amce.png             AMCEs estimated from the weighted sample, Figure A15 
        |   |-- exp1in_2024_heter_amce_ambiguity.png  Heterogeneous AMCEs by variation in attributes 1 and 5, Figure A12            
        |   |-- exp1in_2024_moder_amce_choice.png   heterogeneous AMCEs on choices by attribute 1 and 5 levels, Figure A6            
        |   |-- exp1in_2024_moder_amce_score.png    heterogeneous AMCEs on scores by attribute 1 and 5 levels. Figure A9           
        |   |-- exp2in_2024_heter_amce_ambiguity.png  Heterogeneous AMCEs by variation in attributes 1 and 5, Figure A13             
        |   |-- exp2in_2024_moder_amce_choice.png   heterogeneous AMCEs on choices by attribute 1 and 5 levels, Figure A7            
        |   |-- exp2in_2024_moder_amce_score.png    heterogeneous AMCEs on scores by attribute 1 and 5 levels. Figure A10        
        |   |-- map_sample.png                      Map of survey sample, Figure A1a      
        |   |-- map_war.png                         Map of ACLED events, Figure A1b    
        |   |-- winloc_famaff_mean.png              Within locations, heterogeneity by family affectedness, Figure A36
        |   |-- winloc_selfaff_mean.png             Within locations, heterogeneity by respondent affectedness, Figure A35 
        |   |-- winloc_shelling_mon24_d.png         Within locations, heterogeneity by exposure to shelling, Figure A34
   
        |-- tables     
            |-- exp0_ranking.tex          Ranking of attribute features, for background information    
            |-- exp12_heteff_het_test.tex Table A7: Omnibus Wald-Test Result for Joint Nullity of Heterogenous Effects             
            |-- exp1_heteff_het_test.tex  Table A8: Omnibus Wald-Test Result for Joint Nullity of Heterogenous Effects            
            |-- exp1_ranking.tex          Ranking of attribute features, for background information    
            |-- exp2_heteff_het_test.tex  Table A9: Omnibus Wald-Test Result for Joint Nullity of Heterogenous Effects            
            |-- exp2_ranking.tex          Ranking of attribute features, for background information    
            |-- sumstats_1.tex            Table A3: Respondent-level summary statistics: Demographics
            |-- sumstats_2.tex            Table A4: Respondent-level summary statistics: Affectedness
            |-- sumstats_3.tex            Table A5: Respondent-level summary statistics: Political attitudes
   
##########################################         
Package versions

as returned by loadedPackages()


Name             Version                
labelled          2.14.1 
lubridate          1.9.4 
haven              2.5.5 
ggtext             0.1.2 
rgdal              1.6.7 
cjRank               1.0 
gtools             3.9.5 
stargazer          5.2.3 
rgeos              0.6.4 
sp                 2.2.0 
plyr               1.8.9 
ggplot2            4.0.0 
fixest            0.13.2 
msm                1.8.2 
car                3.1.3 
carData            3.0.5 
devtools           2.4.5 
usethis            3.2.1 
stats              4.5.1 
graphics           4.5.1 
grDevices          4.5.1 
utils              4.5.1 
datasets           4.5.1 
methods            4.5.1 
base               4.5.1 
dplyr              1.1.4 
farver             2.1.2 
S7                 0.2.0 
fastmap            1.2.0 
TH.data            1.1.4 
promises           1.3.3 
digest            0.6.37 
timechange         0.3.0 
estimability       1.5.1 
mime                0.13 
lifecycle          1.0.4 
dreamerr           1.5.0 
ellipsis           0.3.2 
survival           3.8.3 
magrittr           2.0.4 
compiler           4.5.1 
rlang              1.1.6 
tools              4.5.1 
htmlwidgets        1.6.4 
pkgbuild           1.4.8 
curl               7.0.0 
xml2               1.4.0 
RColorBrewer       1.1.3 
pkgload            1.4.1 
multcomp          1.4.28 
abind              1.4.8 
miniUI             0.1.2 
expm               1.0.0 
withr              3.0.2 
purrr              1.1.0 
numDeriv      2016.8.1.1 
grid               4.5.1 
profvis            0.4.0 
xtable             1.8.4 
emmeans         1.11.2.8 
scales             1.4.0 
MASS              7.3.65 
cli                3.6.5 
mvtnorm            1.3.3 
generics           0.1.4 
remotes            2.5.0 
rstudioapi        0.17.1 
sessioninfo        1.2.3 
cachem             1.1.0 
splines            4.5.1 
stringmagic        1.2.0 
vctrs              0.6.5 
Matrix             1.7.4 
sandwich           3.1.1 
hms                1.1.3 
Formula            1.2.5 
glue               1.8.0 
codetools         0.2.20 
gtable             0.3.6 
later              1.4.4 
tibble             3.3.0 
pillar            1.11.1 
htmltools        0.5.8.1 
R6                 2.6.1 
shiny             1.11.1 
lattice           0.22.7 
gridtext           0.1.5 
memoise            2.0.1 
httpuv            1.6.16 
Rcpp               1.1.0 
coda            0.19.4.1 
nlme             3.1.168 
fs                 1.6.6 
zoo               1.8.14 
pkgconfig          2.0.3 
            
            