
*** Stata-code for replication
* Article: Comparing Refugee Dispersal Policies: Varieties of Responsibility-Sharing in Europe
* Authors: Walter Bartl & Philipp Lutz
* Forthcoming in 'Governance'





*** Multidimensional Scaling (MDS)

* Loading and sorting the data
cd "INSERT PATH"
use data_replication.dta, clear
order country b s g c m // b=bindingness; s=sanctions; g=governance; c=criteria; m=monitoring
sort country


* Weighting of attributes according to theoretical considerations
replace b = b*0.6
replace s = s*0.4
replace g = g*0.5
replace c = c*0.3
replace m = m*0.2

* Index construction
gen index = b+s+g+c+m

save RDP_master_w.dta, replace

****************************************************************
* MDS classic, City-Block measure (Manhattan)
****************************************************************
mds b s g c m, id(country) method(classical) measure(L1) config

* Estimating stress value
estat stress 




**************************************************************************
* MDS classic, Canberra measure
**************************************************************************
sort country
mds b s g c m, id(country) method(classical) measure(Canberra) config

* Estimating stress value
estat stress 

* Converting dimensions in variables that can be plotted 
svmat Y, names(dimC)

* Generating a variable for flexible marker labels
gen place = 3

* MDS plot with individually adjusted maker labels
replace place = 1 if inlist(country, "Belgium")
replace place = 6 if inlist(country, "Czech Republic", "Netherlands")
replace place = 9 if inlist(country, "Croatia", "Spain", "Germany", "Malta", "Portugal") 
replace place = 9 if inlist(country, "Denmark", "Cyprus", "Portugal", "Romania", "Austria")
replace place = 9 if inlist(country, "UK", "Ireland")
replace place = 7 if inlist(country, "Luxembourg")
replace place = 12 if inlist(country, "Lithuania", "Norway", "Finland")
replace place = 8 if inlist(country,  "Poland")
replace place = 11 if inlist(country, "Estonia")
replace place = 6 if inlist(country, "Italy")


* Readjusting marker labels to minimize overlap
gen label = country
replace label = "" if country == "Slovakia" 
replace label = "" if country == "Poland" 
replace label = "" if country == "Croatia"
replace label = "" if country == "Czech Republic"
replace label = "Bulgaria, Croatia, Czech Republic, Poland, Slovakia" if country == "Bulgaria" 
replace label = "" if country == "Luxembourg"
replace label = "" if country == "Spain"
replace label = "" if country == "Norway"
replace label = "Finland, Norway, Spain" if country == "Finland"
replace label = "" if country == "Estonia"
replace label = "" if country == "Romania"
replace label = "Belgium, Estonia, Luxembourg, Romania" if country == "Belgium"


* Definition of the configuration of attributes highlighting the territorial justice dimension of the index.
gen conf2 = 1 if c==2 | m>0  // Highlights cases with quota and subnational monitoring.


* MDS plot highlighting the dimension of territorial justice
twoway (scatter dimC2 dimC1, xlabel(-2(1)4) xtitle("Dimension 1", size(small)) ytitle("Dimension 2", size(small)) note("Classical MDS, Canberra measure", size(small)) aspectratio(0.45) mlabvpos(place) mlabsize(2) scheme(lean2) mlabel(label) title(MDS configuration)) || (scatter dimC2 dimC1 if conf2==1, legend(pos(6) order(1 "Regulating asylum seekers" 2 "Regulating asylum seekers and subnational governments"))) 

* Exporting graph
graph export "PATH\mds_c_territ.png", as(png) name("Graph") replace



