REPRO-Bench / 35 /replication_package /dofiles /07_MainFigures.do
anonymous-submission-acl2025's picture
add 35
f7e17b7
***********************************************************************************
// Replication Files
**********************************************************************************
/*
HOW DO BELIEFS ABOUT THE GENDER WAGE GAP AFFECT THE DEMAND FOR PUBLIC POLICY?
Sonja Settele
AEJ:pol
*/
**********************************************************************************
***********************************************************************************
**** Generate Figures 2-3 in main paper
***********************************************************************************
***********************************************************************************
// Figure 2: Treatment effect on signatures for real online petitions
***********************************************************************************
/* Number of potential signatures for Petitions I and II per treatment group correspond to the number of respondents assigned to either treatment group
The numbers of actual signatures for Petitions I and II are all "manually" retrieved from the White House Petition Website.
*/
// PETITION I
/* Run prtesti for a two-sided proportion test for Petition I.
Input: Total number of potential signatures in T74 (1531)
Number of actual signatures in T74 (259)
Total number of potentila signatures in T94 (1500)
Number of actual signatures in T94 (220)
Output: Proportion of signatures in T74 (incl. 95% CI)
Proportion of signatures in T94 (incl. 95% CI)
P-value of two-sided proportion test
--> Output entered manually below
*/
prtesti 1531 259 1500 220, count
clear all
set scheme s2mono
global legend = `"label(1 "T{sup:74}") label(2 "T{sup:94}") order(1 2) size(large)"'
**** Set numbers for bar graph in a matrix
* Petition I:
mat R=J(2,6,.)
local pvalue1 = 0.09 //2-sided test
* Means
mat R[1,1] = 0.16917 // All T74
mat R[2,1] = 0.14667 // All T94
* Lower bounds
mat R[1,2] = 0.1504 // All T74
mat R[2,2] = 0.1288 // All T94
* Upper bounds
mat R[1,3] = 0.1879 // All T74
mat R[2,3] = 0.1646 // All T94
mat R[1,4]=1
mat R[2,4]=2
mat R[1,5] = 1
mat R[2,5] = 1
mat R[1,6] = 1
mat R[2,6] = 1
preserve
clear
svmat R
tempfile Pet1
save `Pet1'
restore
// PETITION II
/* Run prtesti for a two-sided proportion test for Petition II.
Input: Total number of potential signatures in T74 (1531)
Number of actual signatures in T74 (19)
Total number of potentila signatures in T94 (1500)
Number of actual signatures in T94 (35)
Output: Proportion of signatures in T74 (incl. 95% CI)
Proportion of signatures in T94 (incl. 95% CI)
P-value of two-sided proportion test
--> Output entered manually below
*/
prtesti 1531 19 1500 35, count
**********************************
* Petition II
local pvalue2 = 0.02 //2-sided test
* Means
mat R[1,1] = 0.01241 // All T74
mat R[2,1] = 0.02333 // All T94
* Lower bounds
mat R[1,2] = 0.0069 // All T74
mat R[2,2] = 0.0157 // All T94
* Upper bounds
mat R[1,3] = 0.01796 // All T74
mat R[2,3] = 0.031 // All T94
mat R[1,4]=1
mat R[2,4]=2
mat R[1,5] = 1
mat R[2,5] = 1
mat R[1,6] = 2
mat R[2,6] = 2
preserve
clear
svmat R
tempfile Pet2
save `Pet2'
restore
* Save bar graph matrix as dataset
clear
local numcats = "1 2 "
foreach a of local numcats {
append using `Pet`a''
}
* For alignment along the x-axis
gen s1 = R6
gen s2 = .
replace s2 = s1 - 0.2 if R6 == 1
replace s2 = s1 - 0.6 if R6 == 2
replace s2 = s1 - 1.0 if R6 == 3
replace s2 = s1 - 1.4 if R6 == 4
replace s2 = s1 - 1.8 if R6 == 5
gen p1 = (s2 - 0.1) - .6
gen p2 = s2 + 0.1 - .6
* This recovers the group means with which to label each bar.
local i = 0
foreach pgrade of local numcats {
forval rel = 1/2 {
local ++i
sum R1 if R4 == `rel' & R6 == `pgrade'
local barval`i' = trim("`: di %9.2f r(mean)'")
}
}
* Set positions of elements in graph
*if "$grades" == "separate" {
global barlabels `" " 0.8 " " "'
global pvalues `"0.22 0.2 "p-value = `pvalue1'" 0.22 0.8 "p-value = `pvalue2'" "'
global grouplabels `"0.27 0.2 "Petition I:" 0.27 0.8 "Petition II:""'
global grouplabels2 `"0.258 0.2 "Increase rep. requirements" 0.258 0.8 "Decrease rep. requirements""'
global barvalues = `"0.04 0.1 "`barval1'" 0.04 0.3 "`barval2'" 0.04 0.7 "`barval3'" 0.04 0.9 "`barval4'" "'
*}
twoway (bar R1 p1 if R4 == 1, barw(0.18) fi(inten50) lc(black) lw(medium)) (bar R1 p2 if R4 == 2, barw(0.18) fi(inten20) lc(black) lw(medium)) ///
(rcap R3 R2 p1 if R4 == 1, lc(gs5)) (rcap R3 R2 p2 if R4 == 2, lc(gs5)), legend(${legend}) graphregion(color(white)) ///
yscale(range(0.3)) yla(0(0.05)0.3) xla(none) text($pvalues, size(4.0)) text($grouplabels, size(4.0)) text($grouplabels2, size(4.0)) text($barvalues, size(4.0)) ///
ytitle("Fraction of respondents who signed", height(5) size(4.2))
graph export "$output\fig_petitions_combined.pdf", replace
***********************************************************************************
// Figure 3: Incentivized vs. non-incentivized prior beliefs.
***********************************************************************************
set scheme s2mono
use "$path\data\SurveyStageI_AB_final.dta", clear
keep prior prior1 pweight wave democrat republican indep otherpol gender midwest south west age1 age2 age3 age4 anychildren loghhinc associatemore fulltime parttime selfemp unemp student
gen priormen=prior if gender==0
gen priorwoman=prior if gender==1
gen priorrepub=prior if republican==1
gen priordem = prior if democrat==1
lab var priormen "Men"
lab var priorwoman "Women"
lab var priorrepub "Republican"
lab var priordem "Democrat"
rename prior1 incentive
global legend = `"label(1 "No incentive") label(2 "Incentive") order(1 2) size(small)"'
gen notincentive = 1-incentive
local gender = "$gender"
if "$gender" == "male" local genval = 0
if "$gender" == "female" local genval = 1
local group1 = "priormen"
local group2 = "priorwoman"
local group3 = "priorrepub"
local group4 = "priordem"
local numcats = "1 2 3 4"
**** Calculate numbers for bar graph matrix
* Group 1: Men
* Set up matrix
mat R=J(2,5,.)
* Store means by incentive condition
local row=1
foreach X in notincentive incentive{
mean `group1' if `X' == 1 [pweight=pweight]
mat R[`row',1] = e(b)
local ++row
}
* Calculate and store mean belief in no-incentive condition
mean `group1' if notincentive == 1 [pweight=pweight]
matrix meannoin=e(b)
* Calculate and store incentive coeficient and p-value
reg `group1' incentive [pweight=pweight], robust
local pvalue1 = trim("`: di %9.3f 2*ttail(e(df_r), abs(_b[incentive]/_se[incentive]))'")
local row=1
foreach X in notincentive incentive {
mat R[`row',2]= meannoin[1,1] + _b[incentive]-1.96*_se[incentive]
mat R[`row',3]= meannoin[1,1] + _b[incentive]+1.96*_se[incentive]
mat R[`row',4]=`row'
mat R[`row',5] = 1
local ++row
}
preserve
clear
svmat R
tempfile cat1
save `cat1'
restore
* Group 2: Women
* Set up matrix
mat R=J(2,5,.)
* Store means by incentive condition
local row=1
foreach X in notincentive incentive{
mean `group2' if `X' == 1 [pweight=pweight]
mat R[`row',1] = e(b)
local ++row
}
* Calculate and store mean belief in no-incentive condition
mean `group2' if notincentive == 1 [pweight=pweight]
matrix meannoin=e(b)
* Calculate and store incentive coeficient and p-value
reg `group2' incentive [pweight=pweight], robust
local pvalue2 = trim("`: di %9.3f 2*ttail(e(df_r), abs(_b[incentive]/_se[incentive]))'")
local row=1
foreach X in notincentive incentive {
mat R[`row',2]= meannoin[1,1] + _b[incentive]-1.96*_se[incentive]
mat R[`row',3]= meannoin[1,1] + _b[incentive]+1.96*_se[incentive]
mat R[`row',4]=`row'
mat R[`row',5] = 2
local ++row
}
preserve
clear
svmat R
tempfile cat2
save `cat2'
restore
* Group 3: Republicans
* Set up matrix
mat R=J(2,5,.)
* Store means by incentive condition
local row=1
foreach X in notincentive incentive{
mean `group3' if `X' == 1 [pweight=pweight]
mat R[`row',1] = e(b)
local ++row
}
* Calculate and store mean belief in no-incentive condition
mean `group3' if notincentive == 1 [pweight=pweight]
matrix meannoin=e(b)
* Calculate and store incentive coeficient and p-value
reg `group3' incentive [pweight=pweight], robust
local pvalue3 = trim("`: di %9.3f 2*ttail(e(df_r), abs(_b[incentive]/_se[incentive]))'")
local row=1
foreach X in notincentive incentive {
mat R[`row',2]= meannoin[1,1] + _b[incentive]-1.96*_se[incentive]
mat R[`row',3]= meannoin[1,1] + _b[incentive]+1.96*_se[incentive]
mat R[`row',4]=`row'
mat R[`row',5] = 3 // group
local ++row
}
preserve
clear
svmat R
tempfile cat3
save `cat3'
restore
* Group4: Democrats
* Set up matrix
mat R=J(2,5,.)
* Store means by incentive condition
local row=1
foreach X in notincentive incentive{
mean `group4' if `X' == 1 [pweight=pweight]
mat R[`row',1] = e(b)
local ++row
}
* Calculate and store mean belief in no-incentive condition
mean `group4' if notincentive == 1 [pweight=pweight]
matrix meannoin=e(b)
* Calculate and store incentive coeficient and p-value
reg `group4' incentive [pweight=pweight], robust
local pvalue4 = trim("`: di %9.3f 2*ttail(e(df_r), abs(_b[incentive]/_se[incentive]))'")
local row=1
foreach X in notincentive incentive {
mat R[`row',2]= meannoin[1,1] + _b[incentive]-1.96*_se[incentive]
mat R[`row',3]= meannoin[1,1] + _b[incentive]+1.96*_se[incentive]
mat R[`row',4]=`row'
mat R[`row',5] = 4 // group
local ++row
}
preserve
clear
svmat R
tempfile cat4
save `cat4'
restore
* Save bar graph matrix as dataset
clear
foreach a of local numcats {
append using `cat`a''
}
* For alignment along the x-axis
gen s1 = R5
gen s2 = .
replace s2 = s1 - 0.2 if R5 == 1
replace s2 = s1 - 0.6 if R5 == 2
replace s2 = s1 - 1.0 if R5 == 3
replace s2 = s1 - 1.4 if R5 == 4
gen pgrade1 = (s2 - 0.1) - .6
gen pgrade2 = s2 + 0.1 - .6
* This recovers the group means with which to label each bar.
local i = 0
foreach pgroup of local numcats {
forval rel = 1/2 {
local ++i
sum R1 if R4 == `rel' & R5 == `pgroup'
local barval`i' = trim("`: di %9.2f r(mean)'")
}
}
global barlabels `"0.2 "Men" 0.8 "Women" 1.4 "Republicans" 2.0 "Democrats""'
global pvalues `"95 0.2 "p-value = `pvalue1'" 95 0.8 "p-value = `pvalue2'" 95 1.4 "p-value = `pvalue3'" 95 2.0 "p-value = `pvalue4'""'
global barvalues = `"65 0.1 "`barval1'" 65 0.3 "`barval2'" 65 0.7 "`barval3'" 65 0.9 "`barval4'" 65 1.3 "`barval5'" 65 1.5 "`barval6'" 65 1.9 "`barval7'" 65 2.1 "`barval8'""'
twoway (bar R1 pgrade1 if R4 == 1, barw(0.18) fi(inten50) lc(black) lw(medium)) (bar R1 pgrade2 if R4 == 2, barw(0.18) fi(inten20) lc(black) lw(medium)) ///
(rcap R3 R2 pgrade2 if R4 == 2, lc(gs5)), legend(${legend}) graphregion(color(white)) ///
yscale(range(98)) yla(60(20)100) xla($barlabels, labsize(3.5)) text($pvalues, size(3.5)) text($barvalues, size(3.5)) ///
ytitle("Prior belief", size (4) height(5))
graph export "$output\fig_motbeliefs1_truncABcont.pdf", replace