anonymous-submission-acl2025's picture
add 37
14e8be8
**********
* Immigration and Redistribution
* Alesina, Miano, Stantcheva
* RESTUD
* Tables 2 and 3
* The command appendfile should be installed before running this dofile. Type "ssc install appendfile".
**********
clear all
* Specify directory of the replication package
global dir "/Users/armandomiano/Dropbox/AMS_Redistribution/Data/Survey_Data/Replication RESTUD sharing"
cd "$dir"
* Declare output sub-directory
global outdir "Out/Tables"
* Load survey + local data
use "Data/survey_analysis.dta", clear
* Countries included in the analysis
global countries US IT FR DE SE UK
* Generate flags - To ensure answers quality
gen flag_1=0
gen flag_2=0
bysort country treatment_recod: egen min_duration = pctile(duration), p(2)
bysort country treatment_recod: egen max_duration = pctile(duration), p(98)
replace flag_1=1 if duration<min_duration
replace flag_2=1 if duration>max_duration
* Drop respondents that have spent too little or too much time (top/bottom 2%)
keep if flag_1==0 & flag_2==0
*Drop variables that were used to exclude innatentive respondents
drop flag_1 flag_2 min_duration max_duration
* Add data on actual immigrants and non-immigrants statistics and generate misperceptions *
do "Do/misperceptions.do"
*** Keep only control group ***
keep if control==1
****************
* Gen controls *
****************
* Gen Left-Right variables *
* Based on vote or voting intensions
gen left=(party_voted==4 | party_voted==5)
replace left=. if party_voted==. | party_voted==6 | party_voted==0
gen right=(party_voted==1 | party_voted==2)
replace right=. if party_voted==. | party_voted==6 | party_voted==0
gen center=(party_voted==3)
replace center=. if party_voted==. | party_voted==6 | party_voted==0
label var left "Left-wing"
label var right "Right-wing"
label var center "Center"
foreach i in left right center{
label val `i' binary
}
* Gen controls *
* Young
gen young=(age<45)
label var young "Age 18-45"
label val young binary
* Gender
gen female=(sex==2)
label var female "Female"
label val female binary
* Immigrant parent
gen immigrant_parent=(q_parent_same==2)
replace immigrant_parent=. if q_parent_same==.
label var immigrant_parent "Immigrant parent"
label val immigrant_parent binary
* Top income
gen top_income=0
foreach x in $countries{
su household_income if country=="`x'", d
replace top_income=1 if household_income>r(p75) & country=="`x'"
}
label var top_income "High Income"
label val top_income binary
* Gen variables for HI sectors, with college/no college
gen sector_dummy_h=sector_dummy*university_degree
gen sector_dummy_l=sector_dummy*(1-university_degree)
label var sector_dummy_h "H. Imm. Sect. College"
label var sector_dummy_l "H. Imm. Sect. No College"
label val sector_dummy_h binary
label val sector_dummy_l binary
* Gen additional variables entering the indices
* Dummy = 1 if Mohammad receives more on net from the state (either receives more transfers and pays same or less taxes or receives same transfers but pays less taxes)
gen moh_more=(Moh_transfers<3 & Moh_tax>2)
replace moh_more=1 if Moh_transfers==3 & Moh_tax>3
replace moh_more=. if Moh_tax==. | Moh_transfers==.
la var moh_more "Mohammad receives more transfers and/or pay less taxes than John"
label val moh_more binary
* Transfers
gen imm_tra_more=(transfers_imm==10 | transfers_imm==11 |transfers_imm==12 |transfers_imm==13)
la var imm_tra_more "Immigrants receive more transfers"
replace imm_tra_more=. if transfers_imm==.
label val imm_tra_more binary
*******
* Declare controls to be included in regressions *
global controls_index right female young immigrant_parent university_degree top_income sector_dummy_l sector_dummy_h
**********
*** Gen indices ***
* Cultural distance, Economic circumstances, Free riding *
foreach var in mis_share_foreign mis_share_LA mis_share_AS mis_share_AF mis_share_E mis_share_NA ///
mis_unemp_imm_nn mis_loweduc_imm_nn mis_higheduc_imm_nn effort_poor moh_more imm_tra_more{
reg `var' $controls_index
su `var' if e(sample)==1
local `var'mc: display %5.3f `r(mean)'
su `var' if e(sample)==1
local `var'sdc: display %5.3f `r(sd)'
gen `var'_ind=(`var'-``var'mc')/``var'sdc'
replace `var'_ind=(``var'mc'-``var'mc')/``var'sdc' if `var'==. // This is to avoid dropping entirely from the analysis respondents who have just one missing component of the index
}
gen culture_index = (mis_share_LA_ind + mis_share_AS_ind + mis_share_AF_ind - mis_share_E_ind - mis_share_NA_ind)/5
gen econ_index = (mis_unemp_imm_nn_ind + mis_loweduc_imm_nn_ind - mis_higheduc_imm_nn_ind)/3
gen free_riding_index = (effort_poor_ind + moh_more_ind + imm_tra_more_ind)/3
foreach var in mis_share_foreign mis_share_LA mis_share_AS mis_share_AF mis_share_E mis_share_NA ///
mis_unemp_imm_nn mis_higheduc_imm_nn effort_poor moh_more imm_tra_more mis_loweduc_imm_nn {
drop `var'_ind
}
label var culture_index "Perceived cultural distance index"
label var econ_index "Perceived economic weakness index"
label var free_riding_index "Perceived free-riding index"
******
* Gen actual local cultural distance index and other indices *
foreach var in share_foreign_lc share_LatinAmerica_lc share_Asia_lc share_Africa_lc share_Europe_lc share_NorthAmerica_lc college_imm_lc loweduc_imm_lc unemp_imm_lc{
su `var'
local `var'mc: display %5.3f `r(mean)'
su `var'
local `var'sdc: display %5.3f `r(sd)'
gen `var'_ind=(`var'-``var'mc')/``var'sdc'
replace `var'_ind=(``var'mc'-``var'mc')/``var'sdc' if `var'==.
}
gen culture_index_act = (-share_LatinAmerica_lc_ind+share_Asia_lc_ind +share_Africa_lc_ind -share_Europe_lc_ind - share_NorthAmerica_lc_ind)/5
gen econ_index_act = (loweduc_imm_lc_ind -college_imm_lc_ind +unemp_imm_lc_ind)/3
drop share_foreign_lc_ind share_LatinAmerica_lc_ind share_Asia_lc_ind share_Africa_lc_ind share_Europe_lc_ind college_imm_lc_ind unemp_imm_lc_ind loweduc_imm_lc_ind share_NorthAmerica_lc_ind
label var culture_index_act "Actual local cultural distance index"
label var econ_index_act "Actual local economic circumstances index"
* Standardize indices *
foreach var in culture_index econ_index free_riding_index culture_index_act econ_index_act{
reg `var' $controls_index
su `var' if e(sample)==1
local `var'mc: display %5.3f `r(mean)'
local `var'sdc: display %5.3f `r(sd)'
replace `var'=(`var'-``var'mc')/``var'sdc'
}
**********************************************************
*** Table 2: Perception vs. Actual Indices
**********************************************************
* Regressions *
global table_name "$outdir/table_local_indices"
* Table start
file open holder using $table_name.tex, write replace text
file write holder "\begin{tabular}{lcccc} " _n
file write holder "\\ \\ & All & Perc. Cultural Distance & Perc. Econ. Weakness & Perc. Free Riding \\" _n
file write holder "& Immigrants (misp.) & Index & Index & Index \\" _n
file write holder "& (1) & (2) & (3) & (4) \\ \hline" _n
file close holder
* Table end
file open holder using temp_end.tex, write replace text
file write holder "\hline \end{tabular}" _n
file close holder
eststo clear
foreach var in mis_share_foreign{
eststo: xi: reg `var' share_foreign_lc $controls_index i.country, robust
su `var' if e(sample)==1
local `var'mc: display %5.2f `r(mean)'
}
foreach var in culture_index{
eststo: xi: reg `var' culture_index_act $controls_index i.country, robust
su `var' if e(sample)==1
local `var'mc: display %5.2f abs(`r(mean)') // Abs is used to correct stata's rounding error
}
foreach var in econ_index{
eststo: xi: reg `var' econ_index_act $controls_index i.country, robust
su `var' if e(sample)==1
local `var'mc: display %5.2f abs(`r(mean)')
}
foreach var in free_riding_index{
eststo: xi: reg `var' $controls_index i.country, robust
su `var' if e(sample)==1
local `var'mc: display %5.2f abs(`r(mean)')
}
esttab using temp1.tex, replace fragment booktabs keep(share_foreign_lc culture_index_act econ_index_act $controls_index) order(share_foreign_lc culture_index_act econ_index_act $controls_index) noconst label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* Table middle
file open holder using temp_mid1.tex, write replace text
file write holder "Control mean & `mis_share_foreignmc' & `culture_indexmc' & `econ_indexmc' & `free_riding_indexmc' \\" _n
file close holder
appendfile temp1.tex $table_name.tex
appendfile temp_mid1.tex $table_name.tex
appendfile temp_end.tex $table_name.tex
erase temp1.tex
erase temp_end.tex
erase temp_mid1.tex
*******************************************
* Table 3: Correlation matrix
*******************************************
global controls right female young immigrant_parent university_degree top_income sector_dummy_l sector_dummy_h
global Y perc_share_foreign perch_share_LA perc_share_AF perc_share_AS perc_share_E perc_share_NA perc_unemp_imm perc_loweduc_imm perc_higheduc_imm
global X share_foreign_lc share_LatinAmerica_lc share_Asia_lc share_Africa_lc share_Europe_lc college_imm_lc unemp_imm_lc unemp_nat_lc college_nat_lc poor_lc black_cz hispanic_cz
preserve
* Perceptions
gen perc1 = perc_share_foreign
gen perc2 = perc_share_LA
gen perc3 = perc_share_AF
gen perc4 = perc_share_AS
gen perc5 = perc_share_E
gen perc6 = perc_unemp_imm
gen perc7 = perc_loweduc_imm
gen perc8 = perc_higheduc_imm
* National only
gen perc9 = perc_poverty_imm
gen perc10 = perc_share_mu
* Actual local
gen act_l1 = share_foreign_lc
gen act_l2 = share_LatinAmerica_lc
gen act_l3 = share_Africa_lc
gen act_l4 = share_Asia_lc
gen act_l5 = share_Europe_lc
gen act_l6 = unemp_imm_lc
gen act_l7 = loweduc_imm_lc
gen act_l8 = college_imm_lc
gen act_natl6 = unemp_nat_lc
gen act_natl7 = loweduc_nat_lc
gen act_natl8 = college_nat_lc
gen act_natl9 = poor_lc
gen act_diffl6 = unemp_imm_lc - unemp_nat_lc
gen act_diffl7 = loweduc_imm_lc - loweduc_nat_lc
gen act_diffl8 = college_imm_lc - college_nat_lc
* Actual national
gen act_n1 = share_foreign
gen act_n2 = share_LA
gen act_n3 = share_NAF + share_SA
gen act_n4 = share_ME + share_A
gen act_n5 = share_WE + share_EE
gen act_n6 = unemp_imm
gen act_n7 = loweduc_imm
gen act_n8 = higheduc_imm
gen act_n9 = poverty_imm
gen act_n10 = share_muslim
gen act_natn6 = unemp_nat
gen act_natn7 = loweduc_nat
gen act_natn8 = higheduc_nat
gen act_natn9 = poverty_nat
gen act_diffn6 = unemp_imm - unemp_nat
gen act_diffn7 = loweduc_imm - loweduc_nat
gen act_diffn8 = higheduc_imm - higheduc_nat
gen act_diffn9 = poverty_imm - poverty_nat
* Natives
* Perceptions
gen percn1 = perc_unemp_nat
gen percn2 = perc_loweduc_nat
gen percn3 = perc_higheduc_nat
gen percn4 = perc_poverty_nat
* Actual local
gen actn_l1 = unemp_nat_lc
gen actn_l2 = loweduc_nat_lc
gen actn_l3 = college_nat_lc
gen actn_l4 = poor_lc
* Actual national
gen actn_n1 = unemp_nat
gen actn_n2 = loweduc_nat
gen actn_n3 = higheduc_nat
gen actn_n4 = poverty_nat
* Regressions *
global table_name "$outdir/corr_matrix"
* Table start
file open holder using $table_name.tex, write replace text
file write holder "\begin{tabular}{lcccccccccc} " _n
file write holder "& \multicolumn{8}{l}{\textbf{Panel A: Correlation of Perceived Immigrants Characteristics with Actual Immigrants Characteristics}} \\" _n
file write holder "& Share of & Imm. from Latin & Imm. from & Imm. from & Imm. from & Unemployment & No High & College-educated & Poverty & Muslim \\" _n
file write holder "& Immigrants & America & Africa & Asia & Europe & Imm. & School Imm. & Imm. & Imm. & Imm. \\" _n
file write holder "& (1) & (2) & (3) & (4) & (5) & (6) & (7) & (8) & (9) & (10) \\ \hline" _n
file close holder
* Table end
file open holder using temp_end.tex, write replace text
file write holder "\hline \end{tabular}" _n
file close holder
* Local
gen act_l=.
label var act_l "Local correlation"
eststo clear
forval i=1(1)8 {
replace act_l=act_l`i'
eststo: xi: reg perc`i' act_l $controls i.country, robust
}
esttab using temp_1.tex, replace fragment booktabs keep(act_l) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* National
gen act_n=.
label var act_n "National correlation"
eststo clear
forval i=1(1)10 {
replace act_n=act_n`i'
eststo: xi: reg perc`i' act_n $controls, robust
}
esttab using temp_2.tex, replace fragment booktabs keep(act_n) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* Table middle
file open holder using temp_mid1.tex, write replace text
file write holder "\\ & \multicolumn{10}{l}{\textbf{Panel B: Correlation of Perceived Immigrants Characteristics with Actual Non-immigrants Characteristics}} \\" _n
file write holder "& Unemployment & No High & College-educated & Poverty \\" _n
file write holder "& Imm. & School Imm. & Imm. & Imm. \\" _n
file write holder "& (1) & (2) & (3) & (4) \\ \hline" _n
file close holder
* Natives - Local
gen act_natl=.
label var act_natl "Local correlation"
eststo clear
forval i=6(1)9 {
replace act_natl=act_natl`i'
eststo: xi: reg perc`i' act_natl $controls i.country, robust
}
esttab using temp_3.tex, replace fragment booktabs keep(act_natl) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* Natives - National
gen act_natn=.
label var act_natn "National correlation"
eststo clear
forval i=6(1)9 {
replace act_natn=act_natn`i'
eststo: xi: reg perc`i' act_natn $controls, robust
}
esttab using temp_4.tex, replace fragment booktabs keep(act_natn) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* Table middle
file open holder using temp_mid2.tex, write replace text
file write holder "\\ & \multicolumn{10}{l}{\textbf{Panel C: Correlation of Perceived Immigrants Characteristics with Actual Immigrants - Non-immigrants Differences}} \\" _n
file write holder "& Unemployment & No High & College-educated & Poverty \\" _n
file write holder "& Imm. & School Imm. & Imm. & Imm. \\" _n
file write holder "& (1) & (2) & (3) & (4) \\ \hline" _n
file close holder
* Imm-Natives diff - Local
gen act_diffl=.
label var act_diffl "Local correlation"
eststo clear
forval i=6(1)8 {
replace act_diffl=act_diffl`i'
eststo: xi: reg perc`i' act_diffl $controls i.country, robust
}
esttab using temp_5.tex, replace fragment booktabs keep(act_diffl) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* Imm-Natives diff - National
gen act_diffn=.
label var act_diffn "National correlation"
eststo clear
forval i=6(1)9 {
replace act_diffn=act_diffn`i'
eststo: xi: reg perc`i' act_diffn $controls, robust
}
esttab using temp_6.tex, replace fragment booktabs keep(act_diffn) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
** Natives **
* Table middle
file open holder using temp_mid3.tex, write replace text
file write holder "\\ & \multicolumn{10}{l}{\textbf{Panel D: Correlation of Perceived Non-immigrants Characteristics with Actual Non-immigrants Characteristics}} \\" _n
file write holder "& Unemployment & No High & College-educated & Poverty \\" _n
file write holder "& Nat. & School Nat. & Nat. & Nat. \\" _n
file write holder "& (1) & (2) & (3) & (4) \\ \hline" _n
file close holder
* Local
gen actn_l=.
label var actn_l "Local correlation"
eststo clear
forval i=1(1)4 {
replace actn_l=actn_l`i'
eststo: xi: reg percn`i' actn_l $controls i.country, robust
}
esttab using temp_7.tex, replace fragment booktabs keep(actn_l) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
* National
gen actn_n=.
label var actn_n "National correlation"
eststo clear
forval i=1(1)4 {
replace actn_n=actn_n`i'
eststo: xi: reg percn`i' actn_n $controls, robust
}
esttab using temp_8.tex, replace fragment booktabs keep(actn_n) noconst noobs label ///
star(* .1 ** .05 *** .01) se nonumbers nomtitles nolines nocon compress
appendfile temp_1.tex $table_name.tex
appendfile temp_2.tex $table_name.tex
appendfile temp_mid1.tex $table_name.tex
appendfile temp_3.tex $table_name.tex
appendfile temp_4.tex $table_name.tex
appendfile temp_mid2.tex $table_name.tex
appendfile temp_5.tex $table_name.tex
appendfile temp_6.tex $table_name.tex
appendfile temp_mid3.tex $table_name.tex
appendfile temp_7.tex $table_name.tex
appendfile temp_8.tex $table_name.tex
appendfile temp_end.tex $table_name.tex
forval i=1(1)8{
erase temp_`i'.tex
}
erase temp_mid1.tex
erase temp_mid2.tex
erase temp_mid3.tex
erase temp_end.tex
restore