REPRO-Bench / 41 /replication_package /2_jtg_prepare_data_all.do
anonymous-submission-acl2025's picture
add 41
517dc40
clear
*IMPORTANT: Set current directoy to path of do-file before running
cd "path of this do file"
// OUTLINE OF THIS DO-FILE
* 1 Import data sets and construct variables
* 2 Code neighbors, second neighbors, and bilateral distances used in IV and controls for spatial spill-overs
* 3 Construct IV
* 4 Construct controls for spatial spill-overs
* 5 Merge intermediate data sets and prepare final data set for analysis
*###############################################################################
* 1 IMPORT DATA AND CONSTRUCT MAIN VARIABLES
*###############################################################################
use "jtg_data_raw\mtech_raw.dta"
local categories "s a r t m h"
local stechs "1 2 3 4 5 6 7 8 9"
local atechs "1 2 3 4 5"
local rtechs "1 2 3 4 5 6"
local ttechs "1 2 3 4 5"
local mtechs "1 2"
local htechs "1 2"
// GENERATE MILITARY TECHNOLOGY INDEX FROM DATA ON INDIVIDUAL TECHNOLOGIES
gen mtech=0
foreach x of local categories {
gen mtech_`x'=0
foreach y of local `x'techs {
replace mtech=mtech+`x'`y'_use
replace mtech_`x'=mtech_`x'+`x'`y'_use
}
}
gen mtech_exf=mtech_a+mtech_r+mtech_t+mtech_m+mtech_h
gen mtech_exgen=mtech-r4_use-r5_use-r6_use-h2_use-t4_use-t5_use
drop mtech_s mtech_a mtech_r mtech_t mtech_m mtech_h
//MERGE REGIONS AND COUNTRY CODE CROSSWALK
merge m:1 iso3 using "jtg_data_raw/country_codes.dta", keepusing(continent* region* COW_ccode)
drop if _merge!=3
drop _merge
rename COW_ccode ccode
drop if iso3=="KOS"
// ADD WORLD BANL CLASSIFICATION OF REGIONS (TO CONSTRUCT ACEMOGLU ET AL IV FOR DEMOCRACY)
gen region3=region2
replace region3="Eastern Europe and Central Asia" if country=="Kazakhstan"
replace region3="Eastern Europe and Central Asia" if country=="Kyrgyzstan"
replace region3="Eastern Europe and Central Asia" if country=="Tajikistan"
replace region3="Eastern Europe and Central Asia" if country=="Turkmenistan"
replace region3="Eastern Europe and Central Asia" if country=="Uzbekistan"
replace region3="Eastern Europe and Central Asia" if country=="Armenia"
replace region3="Eastern Europe and Central Asia" if country=="Azerbaijan"
replace region3="Eastern Europe and Central Asia" if country=="Georgia"
replace region3="Eastern Europe and Central Asia" if country=="Russian Federation"
replace region3="East Asia and the Pacific" if region3=="Asia and Oceania"
replace region3="Eastern Europe and Central Asia" if region3=="Eastern Europe and Balkan"
//MERGE GDP FROM MADDISON
rename iso3 countrycode
merge 1:1 countrycode year using "jtg_data_raw/maddison_gdp.dta", keepusing(cgdppc)
gen temp=ln(cgdppc)
ipolate temp year, gen(lngdpc) by(countrycode)
drop if _merge==2
drop _merge temp cgdppc
rename countrycode iso3
// FIX CCODE TO EASE MERGE
replace ccode = 529 if country=="Ethiopia" & year>=1993
replace ccode = 818 if country=="Viet nam" & year>=1976
replace ccode = 315 if country=="Czech Republic" & year<1993
replace ccode = 342 if country=="Serbia" & year<=1920
replace ccode = 345 if country=="Serbia" & year>1920 & year<1991
replace ccode = 347 if country=="Serbia" & year>=1991 & year<2006
replace ccode = 342 if country=="Serbia" & year>=2006
replace ccode = 730 if country=="Korea, Republic of" & year<=1910
replace ccode = 769 if country=="Pakistan" & year<=1971
//MERGE DEMOCRACY DATA (BOIX ET AL, POLITY IV, AND V-DEM)
//Boix et al
merge 1:1 ccode year using "jtg_data_raw/BoixMillerRosato-v4.dta", keepusing(democracy democracy_trans)
sort ccode year
replace country=country[_n-1] if ccode==ccode[_n-1] & country==""
replace iso3=iso3[_n-1] if ccode==ccode[_n-1] & iso3==""
replace continent=continent[_n-1] if ccode==ccode[_n-1] & continent==""
replace continent2=continent2[_n-1] if ccode==ccode[_n-1] & continent2==""
drop if country=="" | iso3==""
drop _merge
replace democracy=0 if country=="Russian Federation" & democracy==. //codes USSR as autocracy (neccessary becayse ccode is different in using data)
drop if country=="Serbia" & year<2010 & s1_use==. //Solves issue with having both Serbia and Serbia and Montenegro in data
*polity
merge 1:1 country year using "jtg_data_raw/polity_IV_2016", keepusing(polity2)
sort country year
replace ccode=ccode[_n-1] if country==country[_n-1] & ccode==.
replace iso3=iso3[_n-1] if country==country[_n-1] & iso3==""
drop if country=="" | iso3==""
drop _merge
*Vdem
gen country_text_id=iso3
merge 1:1 country_text_id year using "jtg_data_raw/Vdem10_extract.dta", keepusing(v2x_polyarchy v2regendtype v2reginfo)
sort country_text_id year
replace ccode=ccode[_n-1] if country_text_id==country_text_id[_n-1] & ccode==.
replace iso3=iso3[_n-1] if country_text_id==country_text_id[_n-1] & iso3==""
replace country=country[_n-1] if country_text_id==country_text_id[_n-1] & country==""
drop if country=="" | iso3==""
drop _merge
//CONSTRUCT DEMOCRATIZATION VARIABLES
*Democratization and regime no, Boix et al data
gen democratization=1 if democracy_trans==1
replace democratization=0 if democracy_trans!=1 & democracy_trans!=.
replace democratization=. if democracy==1 & democratization!=1
replace democratization=democratization*100
gen demoyear=year if democracy_trans==1
gen autoyear=year if democracy_trans==-1
egen lastdemo=max(demoyear), by(country)
egen lastauto=max(autoyear), by(country)
gen lastdem = 1 if lastdemo==year
replace lastdem=0 if lastdemo<lastauto & lastauto!=.
replace lastdem=0 if lastdemo>year
replace lastdem=. if democracy==.
replace lastdem=. if democracy==1 & year>lastdemo & lastdemo>lastauto
replace lastdem=. if democracy==1 & lastdemo==.
replace lastdem=lastdem*100
gen demreverse=1 if democracy_trans==-1
replace demreverse=0 if democracy_trans!=-1 & democracy_trans!=.
replace demreverse=. if democracy==0 & demreverse!=1
replace demreverse=demreverse*100
drop demoyear autoyear lastdemo lastauto
gen new_regime=0
gen regime_no=0
gen ones=1
replace new_regime=1 if democracy_trans[_n-1]!=0 & democracy_trans[_n-1]!=.
replace new_regime=1 if year!=year[_n-1]+1
replace new_regime=1 if iso3!=iso3[_n-1]
replace new_regime=1 if iso3==iso3[_n-1] & year==year[_n-1]+1 & democracy!=. & democracy[_n-1]==.
replace regime_no=regime_no[_n-1]+new_regime if regime_no[_n-1]!=.
replace regime_no=regime_no[_n+1] if democratization[_n-1]==. & democratization==0 & country[_n+1]==country[_n-1]
replace regime_no=. if democracy==.
egen regime_length=sum(ones), by(regime_no)
gen durdem=democratization
replace durdem=0 if democratization==100 & regime_length[_n+1]<10
replace durdem=0 if democracy==1 & regime_length[_n+1]<10
replace new_regime=0 if durdem!=. & durdem[_n-1]!=. & iso3==iso3[_n-1]
gen durableregime_no=regime_no if regime_no[_n-1]==. & iso3==iso3[_n-1]
replace durableregime_no=regime_no if iso3!=iso3[_n-1]
replace durableregime_no=regime_no if durdem[_n-1]==100 & iso3==iso3[_n-1]
replace durableregime_no=durableregime_no[_n-1] if durableregime_no==. & iso3==iso3[_n-1]
replace durableregime_no=. if durdem==.
gen dregime_no=regime_no
replace dregime_no=regime_no[_n-1] if demreverse==100
replace dregime_no=regime_no[_n+1] if demreverse[_n-1]!=0 & democracy==1
replace dregime_no=. if demreverse==.
*Democratization and regime no, polity IV data
gen democratization_polity=1 if polity2>5 & polity2[_n-1]<=5 & polity2!=. & country==country[_n-1]
replace democratization_polity=0 if democratization_polity!=1 & polity2<=5
replace democratization_polity=democratization_polity*100
gen demoyear=year if polity2>5 & polity2[_n-1]<=5 & polity2!=. & country==country[_n-1]
gen autoyear=year if polity2<5 & polity2[_n-1]>=5 & polity2!=. & country==country[_n-1]
egen lastdemo=max(demoyear), by(country)
egen lastauto=max(autoyear), by(country)
gen lastdem_polity = 1 if lastdemo==year
replace lastdem_polity=0 if lastdemo<lastauto & lastauto!=.
replace lastdem_polity=0 if lastdemo>year
replace lastdem_polity=. if polity2>5 & year>lastdemo & lastdemo>lastauto
replace lastdem_polity=. if polity2>5 & lastdemo==.
replace lastdem_polity=lastdem_polity*100
gen demreverse_polity=1 if polity2<5 & polity2[_n-1]>=5 & polity2!=. & country==country[_n-1]
replace demreverse_polity=0 if demreverse_polity!=1 & polity2!=.
replace demreverse_polity=. if polity2<=5 & demreverse_polity!=1
replace demreverse_polity=demreverse_polity*100
drop demoyear autoyear lastdemo lastauto
gen new_regime_polity=0
gen regime_no_polity=0
replace new_regime_polity=1 if democratization_polity[_n-1]==100 | demreverse_polity[_n-1]==100
replace new_regime_polity=1 if year!=year[_n-1]+1
replace new_regime_polity=1 if iso3!=iso3[_n-1]
replace new_regime_polity=1 if iso3==iso3[_n-1] & year==year[_n-1]+1 & polity2!=. & polity2[_n-1]==.
replace regime_no_polity=regime_no_polity[_n-1]+new_regime_polity if regime_no_polity[_n-1]!=.
replace regime_no_polity=regime_no_polity[_n+1] if democratization_polity[_n-1]==. & democratization_polity==0 & country[_n+1]==country[_n-1]
replace regime_no_polity=. if polity2==.
egen regime_length_polity=sum(ones), by(regime_no_polity)
gen durdem_polity=democratization_polity
replace durdem_polity=0 if democratization_polity==100 & regime_length_polity[_n+1]<10
replace durdem_polity=0 if polity2>5 & polity2!=. & regime_length_polity[_n+1]<10
replace new_regime_polity=0 if durdem_polity!=. & durdem_polity[_n-1]!=. & iso3==iso3[_n-1]
gen durableregime_no_polity=regime_no_polity if regime_no_polity[_n-1]==. & iso3==iso3[_n-1]
replace durableregime_no_polity=regime_no_polity if iso3!=iso3[_n-1]
replace durableregime_no_polity=regime_no_polity if durdem_polity[_n-1]==100 & iso3==iso3[_n-1]
replace durableregime_no_polity=durableregime_no_polity[_n-1] if durableregime_no_polity==. & iso3==iso3[_n-1]
replace durableregime_no_polity=. if durdem_polity==.
*Democratization and regime change, V-Dem data
sort country year
replace v2x_polyarchy=. if democracy==. // V-Dem codes colonial institutions in some cases, we remove those by making this replacement
gen rchange_vdem=0 if v2regendtype!=.
replace rchange_vdem=100 if v2reginfo[_n-1]!=v2reginfo & country[_n-1]==country & v2reginfo[_n-1]!="" & v2reginfo!=""
egen regime_no_vdem=group(v2reginfo country)
egen democracy_vdem=mean(v2x_polyarchy), by(regime_no_vdem)
replace democracy_vdem=. if v2x_polyarchy==. | v2reginfo==""
replace democracy_vdem=0 if democracy_vdem<=0.4
replace democracy_vdem=1 if democracy_vdem>0.4 & democracy_vdem!=.
replace regime_no_vdem=regime_no_vdem[_n-1] if rchange_vdem==100 & country[_n-1]==country
gen democratization_vdem=1 if democracy_vdem==1 & democracy_vdem[_n-1]==0 & democracy_vdem!=. & country==country[_n-1]
replace democratization_vdem=0 if democratization_vdem!=1 & democracy_vdem==0
replace democratization_vdem=democratization_vdem*100
gen demreverse_vdem=1 if democracy_vdem==0 & democracy_vdem[_n-1]==1 & country==country[_n-1]
replace demreverse_vdem=0 if demreverse_vdem!=1 & v2x_poly!=.
replace demreverse_vdem=. if democracy_vdem==0 & demreverse_vdem!=1
replace demreverse_vdem=demreverse_vdem*100
gen new_regime_vdem=0
gen autoregime_no_vdem=0
replace new_regime_vdem=1 if democratization_vdem[_n-1]==100 | demreverse_vdem[_n-1]==100
replace new_regime_vdem=1 if year!=year[_n-1]+1
replace new_regime_vdem=1 if iso3!=iso3[_n-1]
replace new_regime_vdem=1 if iso3==iso3[_n-1] & year==year[_n-1]+1 & v2x_polyarchy!=. & v2x_polyarchy[_n-1]==.
replace autoregime_no_vdem=autoregime_no_vdem[_n-1]+new_regime_vdem if autoregime_no_vdem[_n-1]!=.
replace autoregime_no_vdem=autoregime_no_vdem[_n+1] if democratization_vdem[_n-1]==. & democratization_vdem==0 & country[_n+1]==country[_n-1]
replace autoregime_no_vdem=. if v2x_polyarchy==.
egen regime_length_vdem=sum(ones), by(autoregime_no_vdem)
gen durdem_vdem=democratization_vdem
replace durdem_vdem=0 if democratization_vdem==100 & regime_length_vdem[_n+1]<10
replace durdem_vdem=0 if democracy_vdem==1 & democracy_vdem!=. & regime_length_vdem[_n+1]<10
replace new_regime_vdem=0 if durdem_vdem!=. & durdem_vdem[_n-1]!=. & iso3==iso3[_n-1]
gen durautoregime_no_vdem=autoregime_no_vdem if autoregime_no_vdem[_n-1]==. & iso3==iso3[_n-1]
replace durautoregime_no_vdem=autoregime_no_vdem if iso3!=iso3[_n-1]
replace durautoregime_no_vdem=autoregime_no_vdem if durdem_vdem[_n-1]==100 & iso3==iso3[_n-1]
replace durautoregime_no_vdem=durautoregime_no_vdem[_n-1] if durautoregime_no_vdem==. & iso3==iso3[_n-1]
replace durautoregime_no_vdem=. if durdem_vdem==.
drop new_regime* ones
// MERGE CORRELATES OF WAR (COW) DATA
//Merge COW material capabilites
merge m:1 ccode year using "jtg_data_raw/COW_NMC-60-abridged.dta", keepusing(milex milper tpop)
drop if _merge==2
drop _merge
replace milex=. if milex<0
replace milper=. if milper<0
xtset ccode year
ipolate milex year, by(ccode) gen(milex_i)
ipolate milper year, by(ccode) gen(milper_i)
replace milex=milex_i
replace milper=milper_i
drop milex_i milper_i
//Merge COW interstate wars
preserve
clear
use "jtg_data_raw/COW_interstate_wars.dta"
expand 195
sort warnum ccode
egen year=seq(), by(warnum ccode side)
replace year=year+1815
gen interstatewar=1 if year>=startyear1 & year<=endyear1
replace interstatewar=1 if year>=startyear2 & year<=endyear2 & endyear2!=.
collapse (max) interstatewar, by(ccode year)
save "jtg_data/temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace interstatewar=0 if interstatewar==. & tpop!=. //code 0 if no war, missing if not in CoW data
//Merge COW militarized disputes
preserve
clear
use "jtg_data_raw/COW_militarized_disputes.dta"
expand 195
sort dispnum3 ccode
egen year=seq(), by(dispnum3 ccode side)
replace year=year+1815
gen mildispute=1 if year>=styear & year<=endyear
collapse (max) mildispute, by(ccode year)
save "jtg_data/temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace mildispute=0 if mildispute==. & tpop!=. //code 0 if no dispute, missing if not in CoW data
//Merge COW intrastarte conflicts
preserve
clear
use "jtg_data_raw/COW_intrastatewar_v51.dta"
expand 195
rename CcodeA ccode
sort WarNum ccode
egen year=seq(), by(WarNum ccode)
replace year=year+1815
gen civilwar=1 if year>=StartYr1 & year<=EndYr1
replace civilwar=1 if year>=StartYr2 & year<=EndYr2 & EndYr2!=.
replace civilwar=1 if year>=StartYr3 & year<=EndYr3 & EndYr3!=.
replace civilwar=1 if year>=StartYr4 & year<=EndYr4 & EndYr4!=.
gen civilwar_central=civilwar if WarType==4
collapse (max) civilwar*, by(ccode year)
save "jtg_data\temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace civilwar=0 if civilwar==.
replace civilwar_central=0 if civilwar_central==. & tpop!=. //code 0 if no war, missing if not in CoW data
//Merge COW international trade
merge m:1 ccode year using "jtg_data_raw/COW_trade_4.dta", keepusing(imports exports)
drop if _merge==2
drop _merge
replace imports=. if imports==-9
replace exports=. if exports==-9
gen temp=ln(imports+exports) if imports!=. & exports!=.
ipolate temp year, gen(lntrade) by(ccode)
drop temp
gen trade=exp(lntrade)
//Merge COW Alliances
preserve
clear
use "jtg_data_raw/COW_alliances.dta"
gen ally_USA=1 if state_name1=="United States of America"
gen ally_Russia=1 if state_name1=="Russia"
collapse (mean) ally_*, by(ccode2 year)
rename ccode2 ccode
save "jtg_data/temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace ally_USA=0 if ally_USA==.
replace ally_Russia=0 if ally_Russia==.
replace ally_USA=1 if country=="United States"
replace ally_Russia=1 if country=="Russian Federation"
*MERGE SIPRI DATA
merge 1:1 iso3 year using "jtg_data_raw/sipri_arms_trade.dta"
drop if _merge==2
drop _merge
local tivvars "any us russia france uk"
xtset ccode year
foreach x of local tivvars {
replace tiv_`x'=0 if tiv_`x'==. & year>=1950
gen tivdum_`x'=tiv_`x'
replace tivdum_`x'=1 if tiv_`x'>0 & tiv_`x'!=.
gen tivakk_`x'=0 if year>=1949
replace tivakk_`x'=tiv_`x'+tivakk_`x'[_n-1] if country==country[_n-1] & year>=1950
}
//MERGE UN AGREEMENT DATA
preserve
clear
use "jtg_data_raw/UN_agreement_extract.dta"
keep ccode1 ccode2 agree year
reshape wide agree, i(ccode1 year) j(ccode2)
rename agree2 agree_USA
rename agree365 agree_Russia
replace agree_USA=1 if ccode1==2
replace agree_Russia=1 if ccode1==365
rename ccode1 ccode
save "jtg_data\temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
//MERGE FOREIGN AID DATA
gen countrycode=iso3
merge 1:1 countrycode year using "jtg_data_raw/aid_dac_countries.dta"
gen lnaid=ln(aid)
replace lnaid=0 if lnaid==.
drop if _merge==2
drop _merge
//MERGE COLONIAL RELATIONSHIPS FROM CEPII
preserve
clear
use "jtg_data_raw/dist_cepii.dta"
rename iso_o iso3
gen colony_we=colony if iso_d=="FRA" | iso_d=="DEU" | iso_d=="GBR" | iso_d=="PRT" | iso_d=="NLD" | iso_d=="ITA"
replace colony_we=0 if colony_we==.
gen colony_ussr=colony if iso_d=="RUS"
replace colony_ussr=0 if colony_ussr==.
keep iso3 colony colony_we colony_ussr
collapse (max) colony*, by(iso3)
replace iso3="ROU" if iso3=="ROM"
replace iso3="SRB" if iso3=="YUG"
save "jtg_data\temp.dta", replace
restore
merge m:1 iso3 using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace colony=0 if colony==.
replace colony_we=0 if colony_we==.
replace colony_ussr=0 if colony_ussr==.
gen temp1=1 if democracy!=. & year==1946 //code independence in 1946, colony variables only consider postwar period
egen temp2=max(temp1), by(iso3)
replace colony=0 if temp2==1 | country=="Germany" | country=="Israel" | country=="Taiwan, Province of China"
replace colony_we=0 if temp2==1 | country=="Germany" | country=="Israel" | country=="Taiwan, Province of China"
replace colony_ussr=0 if temp2==1
drop temp*
//MERGE NAVCO DATA
preserve
clear
use "jtg_data_raw/navco_v2.dta"
gen resistance=1 if prim_method==0 | prim_method==1
replace resistance=0 if resistance!=1 & prim_method!=.
replace resistance=0 if year>1944 & prim_method==.
gen vresistance=1 if prim_method==0
replace vresistance=0 if vresistance!=1 & prim_method!=.
replace vresistance=0 if year>1944 & prim_method==.
gen nresistance=1 if prim_method==1
replace nresistance=0 if nresistance!=1 & prim_method!=.
replace nresistance=0 if year>1944 & prim_method==.
gen resistance_onset=0
replace resistance_onset=1 if cyear==0
replace ccode = 818 if location=="Vietnam"
replace ccode = 315 if location=="Czechoslovakia"
replace ccode = 365 if location=="USSR"
replace ccode = 365 if location=="Russia"
replace ccode = 679 if location=="Yemen"
destring tccode, replace force
replace tccode=490 if target=="Mobutu regime"
drop if lccode!=tccode
replace camp_size=camp_size_est+1 if camp_size==. & camp_size_est!=.
replace camp_size=camp_size_est+1 if camp_size==-99 & camp_size_est!=.
replace camp_size=3 if id==9
collapse (max) resistance vresistance* nresistance progress success resistance_onset camp_size, by(ccode year)
save "jtg_data/temp.dta", replace
restore
merge 1:1 ccode year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
replace resistance=0 if year>1944 & resistance==.
replace vresistance=0 if year>1944 & vresistance==.
replace nresistance=0 if year>1944 & nresistance==.
replace resistance_onset=0 if year>1944 & resistance_onset==.
//MERGE HYDE POPULATION DATA
merge 1:1 iso3 year using "jtg_data_raw/hyde_pop.dta", keepusing(pop_hyde)
replace pop_hyde=tpop*1000 if country=="Maldives" //only country with missing data in hyde
replace pop_hyde=42380 if country=="Maldives" & year==1820 //data from clio infra
replace pop_hyde=72000 if country=="Maldives" & year==1910
replace pop_hyde=ln(pop_hyde)
ipolate pop_hyde year, by(iso3) gen(temp)
replace pop_hyde=exp(temp)
drop if _merge==2
drop _merge temp
//GENERATE SAMPLES
gen temp=1 if year>=1850 & democracy!=.
egen longsample=sum(temp), by(country)
replace longsample=0 if longsample<(2010-1850)
replace longsample=1 if longsample>0 & longsample!=.
replace longsample=. if year<1850
drop temp
gen temp=1 if year>=1920 & democracy!=.
egen mediumsample=sum(temp), by(country)
replace mediumsample=0 if mediumsample<(2010-1920)
replace mediumsample=1 if mediumsample>0 & mediumsample!=.
replace mediumsample=. if year<1920
drop temp
gen temp=1 if year>=1945 & democracy!=.
egen shortsample=sum(temp), by(country)
replace shortsample=0 if shortsample<(2010-1945)
replace shortsample=1 if shortsample>0 & shortsample!=.
replace shortsample=. if year<1945
drop temp
sort country year
*GENERATE ADDITIONAL VARIABLES
xtset ccode year
sort ccode year
gen gdp=exp(lngdpc)+pop_hyde
gen lnmilex=ln(milex)
gen lnmilex_pop=ln(milex)-ln(tpop)
gen milper_pop=milper/tpop
gen resistance_3y=max(resistance, L.resistance, L2.resistance)
gen vresistance_3y=max(vresistance, L.vresistance, L2.vresistance)
gen nresistance_3y=max(nresistance, L.nresistance, L2.nresistance)
gen civilwar_3y=max(civilwar, L.civilwar, L2.civilwar)
gen civilwar_central_3y=max(civilwar_central, L.civilwar_central, L2.civilwar_central)
gen mildispute_3y=max(mildispute, L.mildispute, L2.mildispute)
gen interstatewar_3y=max(interstatewar, L.interstatewar, L2.interstatewar)
gen agree_us_3y=(agree_USA+L.agree_USA+L2.agree_USA)/3
gen agree_russia_3y=(agree_Russia+L.agree_Russia+L2.agree_Russia)/3
gen us_rus_agree_diff=agree_us_3y-agree_russia_3y
drop agree_us_3y agree_russia_3y
replace us_rus_agree_diff= 0 if us_rus_agree_diff==. & year>1945
save "jtg_data/jtg_main.dta", replace
erase "jtg_data/temp.dta"
*###############################################################################
* 2 CODE NEIGHBORS AND DISTANCES
*###############################################################################
*This bit of code identifies neighbours, second neighbors and bilateral distances used to
*cosntruct the instrument and the controls for spatial spill-overs
*Get neighbours
clear
use "jtg_data_raw/COW_contiguity_2010.dta"
keep if conttype<4
keep state*no
save "jtg_data/temp.dta", replace
rename state1no ccode
rename state2no state1no
joinby state1no using "jtg_data/temp.dta"
expand 2, gen(new)
gen neighbour=state1no if new==0
gen neighbour_type=1 if new==0
replace neighbour=state2no if new==1
replace neighbour_type=2 if new==1
sort ccode neighbour neighbour_type
duplicates drop ccode neighbour, force
keep ccode neighbour neighbour_type
save "jtg_data/neighbours.dta", replace
*Get bilateral distances
clear
use "jtg_data_raw/dist_cepii.dta"
keep iso* distw
replace iso_o="ROU" if iso_o=="ROM"
replace iso_d="ROU" if iso_d=="ROM"
replace iso_o="SRB" if iso_o=="YUG"
replace iso_d="SRB" if iso_d=="YUG"
rename iso_o iso3
merge m:1 iso3 using "jtg_data_raw/country_codes.dta", keepusing(country COW_ccode region2)
drop if _merge!=3
drop _merge
rename COW_ccode ccode
rename iso3 iso_main
rename iso_d iso3
rename region2 region
merge m:1 iso3 using "jtg_data_raw/country_codes.dta", keepusing(COW_ccode region2)
drop if _merge!=3
drop _merge
rename COW_ccode neighbour
rename iso3 iso3_dyad
rename iso_main iso3
rename region2 region_neighbour
duplicates drop ccode neighbour, force
*merge back neighbour data on distances
merge 1:1 ccode neighbour using "jtg_data/neighbours.dta", keepusing(neighbour_type)
drop if _merge==2
drop _merge ccode neighbour
order country iso3 iso3_dyad neighbour_type distw
drop if iso3==iso3_dyad
gen year=2000
merge m:1 iso3 year using "jtg_data/jtg_main.dta"
drop if _merge!=3
keep country iso3 iso3_dyad neighbour_type distw
drop if distw==.
save "jtg_data/neighbours.dta", replace
erase "jtg_data/temp.dta"
*###############################################################################
* 3 CONSTRUCT INSTRUMENT
*###############################################################################
*This bit of code constructs the instrument (and the alternative instruments used in the appendix)
clear
use "jtg_data/jtg_main.dta"
replace independent="" if democracy==. // restrict sample to countries covered by both the Boix et al democracy data (equivalent to keeping only independent states) and the military tech data
keep country year iso3 pop_hyde ccode *_use independent
drop if year<1820
//Reshape
rename *_use use*
rename uses* use1*
rename usea* use2*
rename user* use3*
rename uset* use4*
rename usem* use5*
rename useh* use6*
reshape long use, i(country year iso3 pop_hyde independent) j(tech)
//SAVE MEMORY
//Drop observations prior to invention
gen temp=year if use==1
egen firstuse=min(temp), by(tech)
drop if year<firstuse-1
drop temp
*drop observations five years after full adoption
egen adoptionrate=mean(use), by(tech year)
gen temp=year if adoptionrate==1
egen lastyear=min(temp), by(tech)
drop if year>lastyear+5
drop lastyear temp
drop if iso3==""
save "jtg_data/temp.dta", replace
//GENERATE VARIABLES
levelsof tech, local(techs)
foreach x of local techs {
*foreach x of numlist 31 { // for debugging
clear
use "jtg_data/temp.dta"
keep if tech==`x'
sum year
scalar firstyear=`r(min)'
scalar lastyear=`r(max)'
clear
use "jtg_data/neighbours.dta"
expand lastyear-firstyear+1
egen dyad=group(iso3 iso3_dyad)
sort dyad
gen year=_n-(dyad-1)*(lastyear-firstyear+1)+firstyear-1
drop dyad
gen tech=`x'
merge m:1 iso3 year tech using "jtg_data/temp.dta", keepusing(independent) //eliminate observations when main country not independent to save time
drop if _merge!=3
drop _merge
rename iso3 iso3_main
rename iso3_dyad iso3
drop if independent!="yes"
drop independent
merge m:1 iso3 year tech using "jtg_data/temp.dta" //import use, population data for weights etc
drop if _merge!=3
drop _merge
rename iso3 iso3_neighbour
rename iso3_main iso3
gen bal_temp=1 if year==lastyear & use==.
egen missing=max(bal_temp), by(iso3_neighbour)
drop if missing==1
egen obsno=count(year), by(iso3 iso3_neighbour)
gen obs_dyad=1 if independent=="yes"
egen obsno_dyad=sum(obs_dyad), by(iso3 iso3_neighbour)
egen yindp=min(year) , by(iso3)
gen balance_indp=1 if obsno==obsno_dyad
*gen lnpop in startyear
gen temp=ln(pop_hyde) if year==firstyear
egen lnpop_firstyear=mean(temp), by(iso3_neighbour iso3)
drop temp
gen temp=ln(pop_hyde) if year==max(yindp,firstyear)
egen lnpop_yindp=mean(temp), by(iso3_neighbour iso3)
drop temp
*Generate variables (all both simple and ex neighbours): distance to nearest user , use in neighbours, distance-weighted use (how to calculate
drop if iso3_neighbour=="DEU" | iso3_neighbour=="FRA" | iso3_neighbour=="RUS" | iso3_neighbour=="GBR" | iso3_neighbour=="USA"
gen distweight_use1=use/distw
gen distweight_use2=use/distw if neighbour_type!=1
gen distweight_use1_bali=use/distw if balance_indp==1
gen distweight_use2_bali=use/distw if neighbour_type!=1 & balance_indp==1
gen distweight_use3_bali=use/distw if neighbour_type!=1 & balance_indp==1 & distw>500
gen distweight_use4_bali=use/distw if neighbour_type!=1 & balance_indp==1 & distw>750
gen distweight_use5_bali=use/distw if neighbour_type!=1 & balance_indp==1 & distw>1000
gen distweight_obs1=1/distw
gen distweight_obs2=1/distw if neighbour_type!=1
gen distweight_obs1_bali=1/distw if balance_indp==1
gen distweight_obs2_bali=1/distw if neighbour_type!=1 & balance_indp==1
gen distweight_obs3_bali=1/distw if neighbour_type!=1 & balance_indp==1 & distw>500
gen distweight_obs4_bali=1/distw if neighbour_type!=1 & balance_indp==1 & distw>750
gen distweight_obs5_bali=1/distw if neighbour_type!=1 & balance_indp==1 & distw>1000
gen distweight_usepop1_bali=distweight_use1_bali*lnpop_yindp
gen distweight_obspop1_bali=distweight_obs1_bali*lnpop_yindp
gen distweight_usepop2_bali=distweight_use2_bali*lnpop_yindp
gen distweight_obspop2_bali=distweight_obs2_bali*lnpop_yindp
collapse (sum) distw* , by(iso3 tech country year)
cd jtg_data
save temp`x'.dta , replace
cd ..
}
*Append
clear
use "jtg_data/temp11.dta"
drop if year!=9999
cd jtg_data
*foreach x of local techs {
foreach x of numlist 11 12 13 14 15 16 17 18 19 21 22 23 24 25 31 32 33 34 35 36 41 42 43 44 45 51 52 61 62 {
append using temp`x'.dta
erase temp`x'.dta
}
cd ..
save "jtg_data/temp.dta", replace
//Merge use data
clear
use "jtg_data/jtg_main.dta"
drop if independent!="yes"
keep country year iso3 region2 ccode *_use
//Reshape
rename *_use use*
rename uses* use1*
rename usea* use2*
rename user* use3*
rename uset* use4*
rename usem* use5*
rename useh* use6*
reshape long use, i(country year iso3 region2 ) j(tech)
merge 1:1 iso3 tech year using "jtg_data/temp.dta"
drop if _merge==2
drop _merge
save "jtg_data/temp.dta", replace
*Gen final IVs
clear
use "jtg_data/temp.dta"
set matsize 1000
gen iv_n1=distweight_use1_bali/distweight_obs1_bali
gen iv_n2=distweight_use2_bali/distweight_obs2_bali
gen iv_n1_pop=distweight_usepop1_bali/distweight_obspop1_bali
gen iv_n2_pop=distweight_usepop2_bali/distweight_obspop2_bali
gen iv_n2_500=distweight_use3_bali/distweight_obs3_bali
gen iv_n2_750=distweight_use4_bali/distweight_obs4_bali
gen iv_n2_1000=distweight_use5_bali/distweight_obs5_bali
*Fill out missing observaions before invention year and after year where all countries have adopted
gen temp=year if use==1
egen firstobs=min(temp), by(tech)
drop temp
gen temp=year if use==0
egen lastobs=max(temp), by(tech)
foreach x in iv_n1_pop iv_n2_pop iv_n1 iv_n2 iv_n2_500 iv_n2_750 iv_n2_1000 {
replace `x'=0 if year<firstobs
replace `x'=1 if year>lastobs
}
drop temp firstobs lastobs
*Reshape
keep country iso3 tech iv_* year
reshape wide iv_* , i(country iso3 year) j(tech)
foreach x in iv_n1_pop iv_n2_pop iv_n1 iv_n2 iv_n2_500 iv_n2_750 iv_n2_1000 {
rename `x'1* s*_`x'
rename `x'2* a*_`x'
rename `x'3* r*_`x'
rename `x'4* t*_`x'
rename `x'5* m*_`x'
rename `x'6* h*_`x'
}
*Generate IV version of various permutations of the military technology index
local categories "s a r t m h"
local stechs "1 2 3 4 5 6 7 8 9"
local atechs "1 2 3 4 5"
local rtechs "1 2 3 4 5 6"
local ttechs "1 2 3 4 5"
local mtechs "1 2"
local htechs "1 2"
foreach z in iv_n1_pop iv_n2_pop iv_n1 iv_n2 iv_n2_500 iv_n2_750 iv_n2_1000 {
gen mtech_`z'=0
foreach x of local categories {
gen mtech_`x'_`z'=0
foreach y of local `x'techs {
replace mtech_`z'=mtech_`z'+`x'`y'_`z'
replace mtech_`x'_`z'=mtech_`x'_`z'+`x'`y'_`z'
}
}
gen mtech_exf_`z'=mtech_a_`z'+mtech_r_`z'+mtech_t_`z'+mtech_m_`z'+mtech_h_`z'
gen mtech_exgen_`z'=mtech_`z'-r4_`z'-r5_`z'-r6_`z'-h2_`z'-t4_`z'-t5_`z'
}
*Drop variables not used in paper
keep country year iso3 mtech_iv_n2_pop mtech_iv_n1 mtech_iv_n2 mtech_exf_iv_n2 mtech_exgen_iv_n2 mtech_iv_n2_500 mtech_iv_n2_750 mtech_iv_n2_1000 m2_iv_n2 r3_iv_n2
save "jtg_data/instruments.dta", replace
erase "jtg_data/temp.dta"
*###############################################################################
* 4 CONSTRCUT CONTROLS FOR SPATIAL SPILL_OVERS
*###############################################################################
*This bit of code construct variables in neighboring countries as well as distance-weighted control variables
clear
use "jtg_data\neighbours.dta"
local dummies "interstatewar democratization democracy civilwar ally_USA ally_Russia tivdum_us tivdum_russia tivdum_uk tivdum_france resistance"
local cvars "gdp trade aid pop_hyde mtech agree_USA agree_Russia"
local allvars `dummies' `cvars'
expand 196
egen year=seq(), by(iso3 iso3_dyad)
replace year=year+1819
merge m:1 iso3 year using "jtg_data/jtg_main.dta", keepusing(democracy region3 durableregime_no)
drop if _merge!=3
drop if democracy==.
keep iso3 iso3_dyad neighbour_type distw year region3 durableregime_no country
rename iso3 iso3_main
rename iso3_dyad iso3
rename region3 region3_main
merge m:1 iso3 year using "jtg_data/jtg_main.dta", keepusing(`allvars' independent region3)
drop if _merge!=3
drop _merge
drop if independent!="yes"
rename iso3 iso3_neighbour
rename iso3_main iso3
gen majorpower=1 if country=="United Kingdom" | country=="France" | country=="Germany" | country=="United States" | country=="Russian Federation"
foreach x of local allvars {
gen n1_`x'=`x' if neighbour_type==1
gen n2_`x'=`x' if neighbour_type==2
}
*Generate # of neighbors
gen n1number=1 if neighbour_type==1
gen n2number=1 if neighbour_type==2
*Generate distance-weighted variables
foreach x of local allvars {
gen distw1_`x'=`x'/distw if majorpower!=1
gen distw1_`x'_obs=1/distw if `x'!=. & majorpower!=1
}
*Generate dummies for resistance in neighboring autocracies
gen n1_auto_resistance=resistance*(1-democracy) if neighbour_type==1
gen n2_auto_resistance=resistance*(1-democracy) if neighbour_type==2
*Generate Acemoglu et al (2019) style democracy iv and military technology iv
egen regime_firstyear=min(year), by(durableregime_no)
gen temp=1 if democracy==0 & year==regime_firstyear & region3_main==region3
egen balance=max(temp), by(iso3 iso3_neighbour durableregime_no)
replace balance=1 if iso3=="LBR" & region3=="Sub-Saharan Africa" //takes care of the fact that Liberia was the first independent state in the region covered by the democract data
gen democracy_iv_ANRR=democracy if balance==1
egen dyad_no=group(iso3 iso3_neighbour)
xtset dyad_no year
ipolate mtech year, by(dyad_no) gen(mtech_i)
gen mtech_iv_ANRR=mtech_i if balance==1
drop balance temp
*Gen acemoglu-style IV but with distance weights rather than regions
gen temp=1 if democracy==0 & year==regime_firstyear
egen balance=max(temp), by(iso3 iso3_neighbour durableregime_no)
gen democracy_iv_ANRR_distw=democracy/distw if balance==1
gen democracy_iv_ANRR_distw_obs=1/distw if balance==1
*Collapse dyadic data
keep *dist* n1* n2* iso3 year *ANRR*
collapse (sum) *dist* n1* n2* (mean) democracy_iv_ANRR mtech_iv_ANRR*, by(iso3 year)
*Generate averages
gen n1_democracy_avg= n1_democracy/n1number if n1number!=0
gen n2_democracy_avg= n2_democracy/n2number if n2number!=0
replace n1_democracy_avg=0 if n1number==0 & n1_democracy!=.
replace n2_democracy_avg=0 if n2number==0 & n2_democracy!=.
gen n1_agree_USA_avg=n1_agree_USA/n1number if n1number!=0
replace n1_agree_USA_avg=0 if n1number==0 & n1_agree_USA!=.
gen n1_agree_Russia_avg=n1_agree_Russia/n1number if n1number!=0
replace n1_agree_Russia_avg=0 if n1number==0 & n1_agree_Russia!=.
*Create dummies from sums
foreach x of local dummies {
replace n1_`x'=0 if n1_`x'==.
replace n2_`x'=0 if n2_`x'==.
replace n1_`x'=1 if n1_`x'>1
replace n2_`x'=1 if n2_`x'>1
}
*Generate log variables
foreach x of local cvars {
gen n1_ln`x'=ln(n1_`x')
gen n2_ln`x'=ln(n2_`x')
gen distw1_ln`x'=ln(distw1_`x')
}
*Rescale weighted vars
foreach x of local allvars {
replace distw1_`x'=distw1_`x'/distw1_`x'_obs
}
replace democracy_iv_ANRR_distw=democracy_iv_ANRR_distw/democracy_iv_ANRR_distw_obs
*Resistance in autocracies
replace n1_auto_resistance=0 if n1_auto_resistance==.
replace n2_auto_resistance=0 if n2_auto_resistance==.
replace n1_auto_resistance=1 if n1_auto_resistance>1
replace n2_auto_resistance=1 if n2_auto_resistance>1
drop *_obs n1number n2number *lnagree* *hyde* *lnmtech
save "jtg_data/diffusioncontrols.dta", replace
*###############################################################################
* 5 CREATE FINAL DATA SET FOR ANALYSIS
*###############################################################################
*This bit of code merges the intermediate data sets constructed above, deletes
*unneccessary variables, and renames the remaining ones. The final data set is
*saved in the folder jtg_data
clear
use "jtg_data/jtg_main.dta"
merge 1:1 iso3 year using "jtg_data/instruments.dta"
drop if _merge==2
drop _merge
merge 1:1 iso3 year using "jtg_data/diffusioncontrols.dta"
drop if _merge==2
drop _merge
drop *_use*
egen countryno=group(iso3)
xtset countryno year
sort countryno year
local lagvars "democratization interstatewar civilwar auto_resistance"
foreach x of local lagvars {
gen n1_`x'_3y=max(n1_`x', L.n1_`x', L2.n1_`x')
gen n2_`x'_3y=max(n2_`x', L.n2_`x', L2.n2_`x')
}
drop if year<1820
*Drop unnecessary variables (e.g., GDP in levels). Some of these variables are auxillary variables used to create final variables,
*others are redundant because they are so closely related to variables we already control for
drop region region3 continent country_text_id
drop countrycode series imports exports trade aid gdp *_trade *_aid *_gdp pop_hyde
drop distw1_ally_USA distw1_ally_Russia distw1_tivdum_us distw1_tivdum_russia distw1_tivdum_uk distw1_tivdum_france distw1_resistance distw1_mtech distw1_agree_USA distw1_agree_Russia
drop n2_ally_USA n2_ally_Russia n2_tivdum_us n2_tivdum_russia n2_tivdum_uk n2_tivdum_france n2_mtech n2_agree_USA n2_agree_Russia n1_agree_USA n1_agree_Russia n1_resistance n2_resistance n1_mtech n2_lntrade n2_lnaid
drop democracy_trans regime_length_polity demreverse_polity lastdem_polity demreverse_vdem regime_length_vdem independent regime_length milex milper distw
rename region2 region
rename continent2 continent
rename mtech_iv_n2 ivbaseline
// Add labels
label variable country "Country name"
label variable iso3 "ISO3 country code"
label variable countryno "Numerical country identifier based on ISO3"
label variable ccode "CoW country code"
label variable year "Year"
label variable mtech "Military technology index"
label variable mtech_exf "Military tech. index ex. small arms"
label variable mtech_exgen "Military tech. index ex. successive vintages of tanks and aircraft"
label variable continent "Continent"
label variable region "Region"
label variable lngdpc "Log GDP per capita (Maddison)"
label variable democracy "Democracy dummy (Boix et al)"
label variable polity2 "Polity 2 index of democracy"
label variable democratization "Democratization (Boix et al)"
label variable lastdem "Unreversed democratization (Boix et al)"
label variable demreverse "Democratic reversal (Boix et al)"
label variable regime_no "Autocracy-spell identifier (Boix et al)"
label variable durdem "Durable democratization (Boix et al)"
label variable durableregime_no "Autocracy-spell identifier, durable democratization analysis (Boix et al)"
label variable dregime_no "Democracy-spell identifier, (Boix et al)"
label variable democratization_polity "Democratization (polity2)"
label variable regime_no_polity "Autocracy-spell identifier (polity2)"
label variable durdem_polity "Durable democratization (polity2)"
label variable durableregime_no_polity "Autocracy-spell identifier, durable democratization analysis (polity2)"
label variable rchange_vdem "Regime change dummy (V-Dem)"
label variable regime_no_vdem "Regime identifier (V-Dem)"
label variable democracy_vdem "Democracy dummy (derived from V-Dem)"
label variable democratization_vdem "Democratization (V-Dem)"
label variable autoregime_no_vdem "Autocracy-spell identifier (V-Dem)"
label variable durdem_vdem "Durable Democratization (V-Dem)"
label variable durautoregime_no_vdem "Autocracy-spell identifier, durable democratization analysis (V-Dem)"
label variable tpop "Total Population (CoW)"
label variable interstatewar "Interstate war, dummy(CoW)"
label variable mildispute "Militarized dispute, dummy (CoW)"
label variable civilwar "Civil war, dummy (CoW)"
label variable civilwar_central "Civil war for central control, dummy (CoW)"
label variable lntrade "Log imports + exports in dollars (CoW)"
label variable ally_USA "Ally of USA, dummy (CoW)"
label variable ally_Russia "Allly of Russia/USSR, dummy (CoW)"
label variable tiv_any "Arms deliveries, total TIV (SIPRI)"
label variable tiv_us "Arms deliveries from USA, total TIV (SIPRI)"
label variable tiv_russia "Arms deliveries from Russia/USSR, total TIV (SIPRI)"
label variable tiv_france "Arms deliveries from France, total TIV (SIPRI)"
label variable tiv_uk "Arms deliveries from UK, total TIV (SIPRI)"
label variable tivdum_any "Arms deliveries, dummy (SIPRI)"
label variable tivdum_us "Arms deliveries from USA, dummy (SIPRI)"
label variable tivdum_russia "Arms deliveries from Russia/USSR, dummy (SIPRI)"
label variable tivdum_france "Arms deliveries from France, dummy (SIPRI)"
label variable tivdum_uk "Arms deliveries from UK, dummy (SIPRI)"
label variable tivakk_any "Accumulated arms deliveries, total TIV (SIPRI)"
label variable tivakk_us "Accumulated arms deliveries from USA, total TIV (SIPRI)"
label variable tivakk_russia "Accumulated arms deliveries from Russia/USSR, total TIV (SIPRI)"
label variable tivakk_france "Accumulated arms deliveries from France, total TIV (SIPRI)"
label variable tivakk_uk "Accumulated arms deliveries from UK, total TIV (SIPRI)"
label variable agree_USA "UN agreement with US"
label variable agree_Russia "UN agreement with Russia/USSR"
label variable us_rus_agree_diff "UN agreement US - Russia/USSR, 3y mavg"
label variable r3_iv_n2 "Distance-weighted adoption of jet fighters"
label variable m2_iv_n2 "Distance-weighted adoption of machine guns"
label variable mtech_iv_n2_pop "IV with population weights"
label variable mtech_iv_n1 "IV including neighbors"
label variable ivbaseline "IV baseline"
label variable mtech_exf_iv_n2 "IV for mtech ex. small arms"
label variable mtech_exgen_iv_n2 "IV for mtech ex. successive vintages of tanks and aircraft"
label variable mtech_iv_n2_500 "IV ex. countries within 500km"
label variable mtech_iv_n2_750 "IV ex. countries within 750km"
label variable mtech_iv_n2_1000 "IV ex. countries within 1000km"
label variable distw1_interstatewar "Distance-weighted interstate war abroad"
label variable distw1_civilwar "Distance-weighted civil war abroad"
label variable distw1_democracy "Distance-weighted democracy abroad"
label variable distw1_democratization "Distance-weighted democratization abroad"
label variable lnaid "Log foreign aid"
label variable colony "Former colony dummy"
label variable colony_we "Former Western European colony dummy"
label variable colony_ussr "Former USSR state"
label variable resistance "Resistance, dummy (NAVCO)"
label variable vresistance "Violent resistance, dummy (NAVCO)"
label variable nresistance "Nonviolent resistance, dummy (NAVCO)"
label variable progress "Resistance makes progress, dummy (NAVCO)"
label variable success "Resistance successful, dummy (NAVCO)"
label variable resistance_onset "Onset of resistance, dummy (NAVCO)"
label variable camp_size "Size of resistance campaign (NAVCO)"
label variable longsample "Belongs to balanced sample 1825-2010"
label variable mediumsample "Belongs to balanced sample 1918-2010"
label variable shortsample "Belongs to short balanced sample 1945-2010"
label variable lnmilex "Log military expenditure (CoW)"
label variable lnmilex_pop "Log military expenditure per capita (CoW)"
label variable milper_pop "Military personnel per capita (CoW)"
label variable resistance_3y "Resistance in past 3 years"
label variable vresistance_3y "Violent resistance in past 3 years"
label variable nresistance_3y "Nonviolent resistance in past 3 years"
label variable civilwar_3y "Civil war in past 3 years"
label variable civilwar_central_3y "Civil war for central control in past 3 years"
label variable mildispute_3y "Militarized dispute in past 3 years"
label variable interstatewar_3y "Interstate war in past 3 years"
label variable democracy_iv_ANRR "Democracy among regional peers"
label variable democracy_iv_ANRR_distw "Distance weighted democracy among peers"
label variable mtech_iv_ANRR "Military technology of regional peers"
label variable n1_interstatewar "Neighbor at war"
label variable n1_democratization "Neighbor democratizes"
label variable n1_democracy "Neighbor democratic"
label variable n1_civilwar "Neighbor in civil war"
label variable n1_ally_USA "Neighbor US ally"
label variable n1_ally_Russia "Neighbor Russia/USSR ally"
label variable n1_tivdum_us "Neighbor recieves arms from US"
label variable n1_tivdum_russia "Neighbor recieves arms from Russia/USSR"
label variable n1_tivdum_uk "Neighbor recieves arms from UK"
label variable n1_tivdum_france "Neighbor recieves arms from France"
label variable n1_auto_resistance "pro-democracy movement, neighbor"
label variable n2_interstatewar "2nd neighbor at war"
label variable n2_democratization "2nd neighbor democratizes"
label variable n2_democracy "2nd neighbor is democratic"
label variable n2_civilwar "2nd neighbor in civil war"
label variable n2_auto_resistance "Pro-democracy movement, 2nd neighbor"
label variable n1_democracy_avg "Share of democracies among neighbors"
label variable n2_democracy_avg "Share of democracies among 2nd neighbors"
label variable n1_agree_USA_avg "Neighbors' avg. UN agreement w. US"
label variable n1_agree_Russia_avg "Neighbors' avg. UN agreement w. Rus/USSR"
label variable n1_lngdp "Log GDP/cap. of neighbors"
label variable n2_lngdp "Log GDP/cap. of 2nd neighbors"
label variable n1_lntrade "Log intl. trade, neighbors"
label variable n1_lnaid "Log foreign aid, neighbors"
label variable n1_democratization_3y "Neighbor democratizes in past 3 yrs"
label variable n2_democratization_3y "2nd neighbor democratizes in past 3 yrs"
label variable n1_interstatewar_3y "Neighbor at war in past 3 yrs"
label variable n2_interstatewar_3y "2nd neighbor at war in past 3 yrs"
label variable n1_civilwar_3y "Neighbor in civil war in past 3 yrs"
label variable n2_civilwar_3y "2nd neighbor in civil war in past 3 yrs"
label variable n1_auto_resistance_3y "Pro-democracy movement in neighbor in past 3 yrs"
label variable n2_auto_resistance_3y "Pro-democracy movement in 2nd neighbor in past 3 yrs"
label variable distw1_lngdp "Log foreign distance-weighted GDP/capita"
label variable distw1_lntrade "Log foreign distance-weighted trade"
label variable distw1_lnaid "Log foreign distance-weighted foreign aid"
*save final data set and erase intermediate data sets generated by this do-file
save "jtg_data/jtg_main.dta", replace
erase "jtg_data/instruments.dta"
erase "jtg_data/diffusioncontrols.dta"
erase "jtg_data/neighbours.dta"