/************************************************************************** Stata code for Self-deception Created by: Zeeshan Samad, zeeshan.samad@vanderbilt.edu ----------------- Table of Contents ----------------- 1. Import + Clean (delete/rename/label etc) 2. Summary Statistics T-tests (includes mann whitney test) 3. Figures Fig 1. bar chart with error bars Fig 2. pie chart Fig 3. kernel density plots Fig 4. Distribution (histogram + fitted normal) 4. Regression tables 5. Appendix figures ***************************************************************************/ clear all set more off global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results global tables C:\Users\Zeeshan\Box Sync\Self deception\Paper\Tables global pictures C:\Users\Zeeshan\Box Sync\Self deception\Paper\Pictures /*************************** 1. Import and Cleaning ****************************/ // Import data global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results import excel "$data\Data.xls", sheet("Sheet1") firstrow clear // drop unneeded obs and variables keep if treat=="ambig/ giving (T)" // keeps only sessions 9 and 10 keep if charity_lottery ==1 | charity_lottery ==2 // drops session 9 subjects who did not take charity lottery drop if switch_row>=11 | switch_row<=1 // preferences dont make sense (50 for sure > 120 for sure) drop if passed ==0 drop q_motivation additional_comments inmturkdata receipt_email drop passed particip_fee bonus Totalpayoff treat x selfish endowment /// x_low x_high x_chosen charity_lottery belief urban charity_payoff code rename revealed_p true_p rename stated_p adopted_p // some values of revealed p are showing up as 0.500000001 instead of 0.50 replace true_p = true_p *100 - 5 tostring true_p, replace force replace true_p = true_p +"nnnn" replace true_p = subinstr(true_p , "nnnn", "",.) destring true_p , replace replace adopted_p = adopted_p *100 tostring adopted_p, replace force replace adopted_p = adopted_p +"nnnn" replace adopted_p = subinstr(adopted_p , "nnnn", "",.) destring adopted_p , replace //making a macro in case I want to change this value later global threshold 10 // define manipulative & honest subjects gen manipulative = 0 replace manipulative = 1 if true_p - adopted_p > $threshold replace manipulative = 1 if true_p - adopted_p < -$threshold //label label define manip_label 0 "Honest Subjects" 1 "Manipulative Subjects" label values manipulative manip_label // define size of manipulation gen diff_p = true_p - adopted_p // define direction of manipulation (pessimistic or optimistic) gen claim=0 replace claim=-1 if diff_p < -$threshold replace claim= 1 if diff_p > $threshold //label label define claim_label 0 "Honest" 1 "Pessimistic" -1 "Optimistic" label values claim claim_label // define subject type gen type = "SH" if altruist==0 & manipulative==0 replace type = "SM" if altruist==0 & manipulative==1 replace type = "AH" if altruist==1 & manipulative==0 replace type = "AM" if altruist==1 & manipulative==1 // Label Variables and values of variables // altruistic type label define altruism_label 0 "Selfish Subjects" 1 "Altruistic Subjects" label values altruist altruism_label // race replace race="3" if race=="1,3" replace race="5" if race=="1,5" replace race="4" if race=="3,4" destring race, replace label define race_label 1 "White" 2 "Black" 3 "Hispanic" 4 "Asian" 5 "Native American" 6 "Other" label values race race_label gen race_white= (race==1) // dummy variable for white // age category rename age age_cat label define age_label 1 "Under 18" 2 "18-25" 3 "25-35" 4 "35-45" 5 "45-55" 6 "55+" label values age_cat age_label // charity name rename charity charity_name label define charity_label 1 "Domestic Violence Intrvn Srvc" 2 "American Red Cross" /// 3 "World Wildlife Fund" 4 "UNICEF USA" 5 "Feeding America" 6 "Doctors Without Borders" /// 7 "American Heart Assoc." 8 "Smithsonian Institution" 9 "Direct Relief" /// 10 "United Way Worldwide" 11 "Teach for America" label values charity_name charity_label // occupation destring occupation, replace label define occupation_label 1 "Unemployed" 2 "Student" 3 "Employed" 4 "Other" label values occupation occupation_label label var adopted_p "Adopted Belief about P" label var true_p "True Belief about P" label var income_cat "Income Category (1-7)" label var education "Years of Education" label var religious "Religiousness (0-3)" label var age_cat "Age Category (1-6)" label var female "Female" label var q_image_concern "Care about being generous (0-5)" label var q_altruism "Care about cause(0-5)" label var q_selfish "Care about own payoff(0-5)" label var altruist "Altruistic" label var diff_p "True P - Adopted P" label var race "1=W, 2=B, 3=H, 4=A, 5=NA, 6=Other" label var race_white "If Race=white" label var charity_name "Charity Chosen" label var manipulative "If manipulative" label var type "Subject's Type" label var claim "0=honest, 1=pessimistic, -1=optimistic" save "$data\Final Data.dta", replace ******** ******** ******** ******** ******** ******** ******** /********************************* 2. Summary statistics table *********************************/ global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results global tables C:\Users\Zeeshan\Box Sync\Self deception\Paper\Tables use "$data\Final Data.dta", clear //2a. First 2 columns of Summary statistics table global sum_vars adopted_p true_p income_cat education religious age_cat female /// q_image_concern q_altruism q_selfish mean $sum_vars if altruist==0 eststo selfish mean $sum_vars if altruist==1 eststo altruist esttab selfish altruist using "$tables\summary_statistics.csv", replace se nostar noobs label /// mtitle("Selfish Subjects" "Generous Subjects") eststo clear // 2b. Adding p-values to summary statistics table (column 3) foreach x of varlist $sum_vars { ttest `x', by(altruist) estadd scalar pval_`x' = r(p) *eststo, addscalars(pval_`x' r(p)) } global pval_sum_vars pval_adopted_p pval_true_p pval_income_cat pval_education /// pval_religious pval_age pval_female pval_q_image_concern pval_q_altruism pval_q_selfish esttab using "$tables\summary_statistics_p.csv", scalars($pval_sum_vars) noobs sfmt(3) replace //2c. other tests (these are written in results > statistical test) // t test ttest adopted_p, by(altruist) ttest true_p, by(altruist) //mann whitney test (variable has the same distribution in both groups) ranksum adopted_p , by(altruist) ranksum true_p, by(altruist) // nonparametric K-sample test on the equality of medians median adopted_p , by(altruist) median true_p , by(altruist) // check for correlation between manipulative and altruist ttest manipulative, by(altruist) ranksum manipulative, by(altruist) median manipulative, by(altruist) /********************* 3. Figures **********************/ global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results global tables C:\Users\Zeeshan\Box Sync\Self deception\Paper\Tables global pictures C:\Users\Zeeshan\Box Sync\Self deception\Paper\Pictures use "$data\Final Data.dta", clear // Fig 1. bar chart with error bars preserve gen mean_true = true_p gen se_true = true_p gen mean_adopted = adopted_p gen se_adopted = adopted_p gen n = 1 collapse (mean) mean_adopted mean_true (semean) se_true se_adopted (count) n, by(altruist) gen ci_upper_true = mean_true + invttail(n-1,0.025)*se_true gen ci_lower_true = mean_true - invttail(n-1,0.025)*se_true gen ci_upper_adopted = mean_adopted + invttail(n-1,0.025)*se_adopted gen ci_lower_adopted = mean_adopted - invttail(n-1,0.025)*se_adopted reshape long mean se ci_lower ci_upper, i(altruist) j(x) string replace x ="1" if x =="_adopted" replace x ="2" if x =="_true" destring x , replace label define belief_label 1 "Adopted Beliefs" 2 "True Beliefs" label values x belief_label gen label = round(mean,0.1) tostring label, replace force replace label = " " + ustrleft(label , 4) + "%" //actual fig, contains 3 charts: bar chart, error bars, value label (scatter) twoway (bar mean x, fcolor(gs8) lcolor(gs4) barwidth(.85)) /// (scatter mean x, msymbol(none) mlabel(label) mlabposition(1) mlabgap(zero)) /// (rcap ci_lower ci_upper x, lcolor(gs3)), /// ytitle("Belief about p (%)") ylabel(0(10)70, nogrid angle(zero)) /// xtitle("") xscale(line fextend) xlabel(1(1)2, valuelabel tlength(zero)) /// by(altruist, note("") legend(off) imargin(zero)) scheme(s1mono) /// subtitle(, size(large) position(6) nobox) /// plotregion(margin(bargraph) lcolor(none)) graph export "$pictures\fig1.eps", as(eps) preview(off) replace restore // Fig 2. pie chart graph pie, over(claim) line(lcolor(white) lwidth(thin)) intensity(inten80) /// plabel(1 percent) plabel(1 name, gap(8) size(small)) /// plabel(2 percent) plabel(2 name, gap(-8) size(small)) /// plabel(3 percent) plabel(3 name, gap(8) size(small)) /// by(altruist, note("") legend(off)) scheme(s1mono) /// subtitle(, size(large) position(6) ring(0) nobox) plotregion(lcolor(none)) graph export "$pictures\fig2.eps", as(eps) preview(off) replace // Fig 3. Kernel density Plots // 3a. kernel density plots for true_p twoway (kdensity true_p if altruist==1, kernel(gaussian) bwidth(5) lcolor(black)) /// (kdensity true_p if altruist==0, kernel(gaussian) bwidth(5) lcolor(black) lpattern(dash)), /// plotregion(lcolor(none)) scheme(s1mono) title("True Beliefs: Kernel Density Plot") /// ytitle(Kernel Density) ylabel(none) xtitle("True Belief (%)") xlabel(0(20)100, tposition(inside)) /// legend(order(1 "Altruistic Subjects" 2 "Selfish Subjects") rows(4) size(small) position(1) ring(0) region(fcolor(none) margin(bottom) lpattern(blank)) ) graph export "$pictures\kernel_1.eps", as(eps) preview(off) replace // 3b. kernel density plots for adopted_p twoway (kdensity adopted_p if altruist==1, kernel(gaussian) bwidth(5) lcolor(black)) /// (kdensity adopted_p if altruist==0, kernel(gaussian) bwidth(5) lcolor(black) lpattern(dash)), /// plotregion(lcolor(none)) scheme(s1mono) title("Adopted Beliefs: Kernel Density Plot") /// ytitle(Kernel Density) ylabel(none) xtitle("Adopted Belief (%)") xlabel(0(20)100, tposition(inside)) /// legend(order(1 "Altruistic Subjects" 2 "Selfish Subjects") rows(4) size(small) position(1) ring(0) region(fcolor(none) margin(bottom) lpattern(blank)) ) graph export "$pictures\kernel_2.eps", as(eps) preview(off) replace // Fig 4. Histograms/Normal distribution // 4a. adopted p, for selfish and manipulative subjects histogram adopted_p, discrete percent ytitle("Percentage of Subjects (%)") /// ylabel(0(10)70, angle(zero) ticks tposition(inside) nogrid) /// xtitle("Adopted Beliefs (%)") xlabel(0(20)100, noticks) /// scheme(s1mono) normal subtitle(, nobox) plotregion(margin(bargraph) lcolor(none)) /// by(manipulative, iyaxes noixtick legend(off) title("Distribution of Adopted Beliefs") note("")) graph export "$pictures\histogram_1.eps", as(eps) preview(off) replace // 4b. True p, for selfish and manipulative subjects histogram true_p, discrete percent ytitle("Percentage of Subjects (%)") /// ylabel(0(10)70, angle(zero) ticks tposition(inside) nogrid) /// xtitle("True Beliefs (%)") xlabel(0(20)100, noticks) /// scheme(s1mono) normal subtitle(, nobox) plotregion(margin(bargraph) lcolor(none)) /// by(manipulative, iyaxes noixtick legend(off) title("Distribution of True Beliefs") note("")) graph export "$pictures\histogram_2.eps", as(eps) preview(off) replace /*************** 4. Regressions ****************/ global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results global tables C:\Users\Zeeshan\Box Sync\Self deception\Paper\Tables global pictures C:\Users\Zeeshan\Box Sync\Self deception\Paper\Pictures use "$data\Final Data.dta", clear xtset redcap_id // Regression 1: y = altruistic behavior (table 2) // ols regress altruist true_p female religious education income_cat age_cat estimates store reg1a, title("OLS") // ols with fixed effects for occupation & charity_name **NOTE: if you get an error here, first install this: -ssc install reghdfe- reghdfe altruist true_p female religious education income_cat age_cat, absorb(occupation charity_name) estimates store reg1b, title("OLS w/ FE") // probit probit altruist true_p female religious education income_cat age_cat estimates store reg1c, title("Probit") esttab reg1a reg1b reg1c using "$tables\reg1.csv", replace label se mtitles /// star(* 0.10 ** 0.05 *** 0.01) nonumbers /// title("Dependent Variable: Altruistic Behavior") // Regression 2: y = diff_p (table 3) // ols regress diff_p true_p altruist female religious education income_cat age_cat estimates store reg3a, title("OLS") // ols with fixed effects for occupation & charity_name reghdfe diff_p true_p altruist female religious education income_cat age_cat, absorb(occupation charity_name) estimates store reg3b, title("OLS with FE") esttab reg3a reg3b using "$tables\reg3.csv", replace label se mtitles /// star(* 0.10 ** 0.05 *** 0.01) nonumbers /// title("Dependent Variable: Size of Manipulation") // Regression 3: y = adopted_p (table 4) // ols regress adopted_p true_p female religious education income_cat age_cat estimates store reg2a, title("OLS") // ols with fixed effects for occupation & charity_name reghdfe adopted_p true_p female religious education income_cat age_cat, absorb(occupation charity_name) estimates store reg2b, title("OLS with FE") esttab reg2a reg2b using "$tables\reg2.csv", replace label se mtitles /// star(* 0.10 ** 0.05 *** 0.01) nonumbers /// title("Dependent Variable: adopted Belief About P") // Regression 4: y = altruism, x=diff_p (to put in appendix?) // ols regress altruist diff_p true_p female religious education income_cat age_cat estimates store reg4a, title("OLS") // ols with fixed effects for occupation & charity_name reghdfe altruist diff_p true_p female religious education income_cat age_cat, absorb(occupation charity_name) estimates store reg4b, title("OLS") // probit probit altruist diff_p true_p female religious education income_cat age_cat estimates store reg4c, title("OLS") esttab reg4a reg4b reg4c using "$tables\reg4.csv", replace label se mtitles /// star(* 0.10 ** 0.05 *** 0.01) nonumbers /// title("Dependent Variable: Altruistic Behavior") /********************************* 5. Appendix Figures *********************************/ global data C:\Users\Zeeshan\Box Sync\Self deception\Experiment\Results global tables C:\Users\Zeeshan\Box Sync\Self deception\Paper\Tables global pictures C:\Users\Zeeshan\Box Sync\Self deception\Paper\Pictures use "$data\Final Data.dta", clear // Fig A1. Charity chosen histogram charity_name, discrete percent /// ytitle("Percentage of Subjects") /// ylabel(0(5)25, angle(zero) ticks tposition(inside)) /// xlabel(#11, labsize(vsmall) angle(forty_five) valuelabel noticks) /// scheme(s1mono) plotregion(margin(bargraph) lcolor(none)) graph export "$pictures\histogram_3.eps", as(eps) preview(off) replace // Fig A2. Bar chart (but wihtout error bars, instead showing a table below) graph bar (mean) altruist, over(claim) blabel(bar, format(%3.2f)) /// ytitle("% of Altruistic Subjects") /// ylabel(0(0.1)1, angle(zero) ticks tposition(inside) nogrid format(%3.2f)) /// note("Nature of Adopted Belief", size(medium) position(6) margin(top)) /// scheme(s1mono) plotregion(margin(bargraph) lcolor(none)) graph export "$pictures\bar_graph_claim.eps", as(eps) preview(off) replace // These t-tests go underneath the bar chart in Fig A2 ereturn clear // pessimistic vs optimistic ttest altruist if claim!=0, by(claim) estadd scalar p1 = r(p) estadd scalar t1 = r(t) // honest vs optimistic ttest altruist if claim!=1, by(claim) estadd scalar p2 = r(p) estadd scalar t2 = r(t) // honest vs pessimistic ttest altruist if claim!=-1, by(claim) estadd scalar p3 = r(p) estadd scalar t3 = r(t) esttab using "$tables\ttest_claim.csv", replace cells("t p") /// stats(t1 p1 t2 p2 t3 p3, layout("@ @" "@ @" "@ @") /// labels("Pessimistic vs Optimistic" "Optimistic vs Honest" "Pessimistic vs Honest")) // Other figures (not yet included in appendix) // kernel density for adopted_p if adopted_p =/= 50 twoway (kdensity adopted_p if altruist==1, kernel(gaussian) bwidth(5)) /// (kdensity adopted_p if altruist==0, kernel(gaussian) bwidth(5)) if adopted_p!=50, /// ytitle(Kernel Density) ylabel(, labsize(vsmall) ticks tposition(inside)) /// xtitle("Adopted P (%)") xlabel(, labsize(small) tposition(inside)) /// title("Adopted Beliefs - Only Deceptive Subjects") /// subtitle(Kernel Density Plot) legend(order(1 "Generous Subjects" /// 2 "Selfish Subjects") rows(4) size(vsmall) region(fcolor(none) /// margin(bottom) lpattern(blank)) position(1) ring(0)) scheme(s1mono) graph export "$pictures\kernel_3.eps", as(eps) preview(off) replace // kernel density plots for true_p if adopted_p =/= 50 twoway (kdensity diff_p if altruist==1, kernel(gaussian) bwidth(5)) /// (kdensity diff_p if altruist==0, kernel(gaussian) bwidth(5)) if adopted_p!=50, /// ytitle(Kernel Density) ylabel(, labsize(vsmall) ticks tposition(inside)) /// xtitle("True belief - Adopted belief (%)") xlabel(, labsize(small) /// tposition(inside)) title("Extent of Belief Manipulation") /// subtitle(Kernel Density Plot) legend(order(1 "Generous Subjects" 2 /// "Selfish Subjects") rows(4) size(vsmall) region(fcolor(none) margin(bottom) /// lpattern(blank)) position(1) ring(0)) scheme(s1mono) graph export "$pictures\kernel_diff.eps", as(eps) preview(off) replace // histogram for diff_p histogram diff_p, discrete percent width(10) xlabel(-40(10)70) ylabel(0(10)50, nogrid) /// xtitle("True Belief - Adopted Belief (%)") ytitle("Percentage of Subjects (%)") scheme(s1mono) /// title("Distribution of Size of Manipulation") graph export "$pictures\histogram_3.eps", as(eps) preview(off) replace // histogram of true belief, for selfish and altruist subjects histogram true_p, discrete percent width(10) xlabel(0(10)100) ylabel(0(10)50, nogrid) /// xtitle("True Belief (%)") ytitle("Percentage of Subjects (%)") /// by(, legend(off)) by(altruist) subtitle(, nobox) scheme(s1mono) /// by(,title("Distribution of True Beliefs About P") note("")) graph export "$pictures\histogram_1a.eps", as(eps) preview(off) replace // histogram of adopted belief, for selfish and altruist subjects histogram adopted_p, discrete percent width(10) xlabel(0(10)100) ylabel(0(10)50, nogrid) /// xtitle("Adopted Belief (%)") ytitle("Percentage of Subjects (%)") /// by(altruist, legend(off) title("Distribution of Manipulated (Adopted) Beliefs About P") note("")) /// subtitle(, nobox) scheme(s1mono) graph export "$pictures\histogram_1b.eps", as(eps) preview(off) replace * END OF DO FILE