********************************************************************************
* STEP 2: GENERATE FIGURES AND TABLES FOR PAPER AND ADDITIONAL MATERIALS
* 
*   Preparatory steps (setup, paths, colors, controls)
*   FIGURE 1:     Map of differences in inflation expectations
*   FIGURE 2a:    Share of individuals in traditional households and inflation expectations
*   FIGURE 2b:    Household organization and inflation expectations
*   TABLE  1 + S12 + S13: Gender dummy and family organization
*   FIGURE 3 + TABLE S15: Important product categories
*   FIGURE 4 + TABLE S16: Relation between traditional norms and attention to product categories
*   FIGURE S1:    Map of inflation expectations 
*   FIGURE S2:    Map of gender difference in inflation expectations (relative)
*   FIGURE S3:    Map of women with children in traditional households
*   FIGURE S4:    Histogram of inflation expectations by gender
*   TABLE S1:     Descriptive statistics for general inflation expectations
*   TABLE S2:     Descriptive statistics for food inflation expectations
*   TABLE S3:     Descriptive statistics for energy inflation expectations
*   TABLE S4:     Descriptive statistics for gender norms and information sources
*   TABLE S5:     Descriptive statistics for background variables
*   TABLE S6-S10: Demographics by country
*   TABLE S14:    Controlling for food and energy price expectations
*   TABLE S17:    Alternative explanations
*   TABLE S18:    Sensitivity with Huber robust regression
*   TABLE S19:    Sensitivity only for married or cohabiting respondents in households up to 4 people
*   TABLE S20:    Relation to social norms questions
********************************************************************************


/*====================================================================
   Preparatory steps
  ====================================================================*/

    // standard setup
    clear all
    set maxvar 30000
    set more off
    
    // set paths
    global path    = "PATH/TO/YOUR/FOLDER"
    global dofiles = "$path/do"
	global data    = "$path/dta"
    global results = "$path/results"
    global map     = "$path/world_map"
    
    // set graph scheme    
    adopath + "$path"
    set scheme fabian_graphs
    
    // determine colors
    global color1 = "0 77 153"
    global color2 = "234 128 28"
    
    global color3 = "160 160 160"
    global color4 = "41 140 140"
    global color5 = "160 0 0"
    
    // define controls
    global controls  = "i.q3 i.q2 i.q4_group i.q5 i.q7 i.q11 i.q10 ib1.fin_lit i.country_num"
    global controls2 = "i.q3 i.q2 i.q4_group i.q5 i.q7 i.q11 i.q10 i.country_num"
	
	// geoplot package required; install if not already installed
	* ssc install geoplot
    
    
    
/*====================================================================
   FIGURE 1: Map of differences in inflation expectations
  ====================================================================*/
    
    // use dataset
    use "$data/infl_gender.dta", clear
    
    // code inflation questions into different variables by gender
    gen q18_women = q18_win if q1 == 2
    gen q18_men   = q18_win if q1 == 1
    
    // collapse and save
    collapse q18_women q18_men, by(country)
    gen interest = q18_women - q18_men
    rename country ISO_A3_EH
    merge 1:m ISO_A3_EH using "$map/world.dta", keepusing(_ID)
    save "$data/temp.dta", replace
    
    // draw figure
    geoframe create "$map/countries", replace
    geoframe create "$data/temp.dta", replace nodescribe current
    frame countries: geoframe copy temp interest, id(_ID)
    geoplot ///
        (area countries interest, color(viridis, reverse) cuts(0.5 1.5 2.5 3 3.5 5.5) ///
         lc(gs8) lw(0.1) missing(color(gs15) nolabel)) ///
        (area countries interest if _ID == 141, lc(gs8) lw(0.1) missing(color(gs15) nolabel)), ///
        tight legend(position(7) size(3) rowgap(1) region(color(gs15))) ///
        grid(tight lw(0.08) lc(gs10)) project(robinson)
		
	// export figure
    graph export "$results/figure_1.png", replace
    
    
/*====================================================================
   FIGURE 2a: Share of individuals in traditional households and inflation expectations
  ====================================================================*/

    // use dataset
    use "$data/infl_gender.dta", clear    
    
	// code relevant questions
    gen y_var = q18_win
    gen x_var = q16_trad
        		
	// collapse and reshape
    collapse (mean) y_var (mean) x_var, by(q1 country)    
    reshape wide y_var x_var, i(country) j(q1)
    gen diff = y_var2 - y_var1
    gen share = x_var2
    
	// get regression results
    reg diff share, beta
    local t = _b[share]/_se[share]
    local p =2*ttail(e(df_r),abs(`t'))
    local rho = trim("`: display %10.2f e(beta)[1,1]'")
    local p = trim("`: display %10.4f `p''")
    
	// draw figure
    tw  (lfit diff share, color(cranberry) lwidth(medthick) range(0.4 0.8)) ///
        (scatter diff share, mlabel(country) color("$color1") mcolor("$color1") mlabcolor("$color1")), ///
        xlabel(0.4(0.1)0.8) ylabel(0(1)5) ///
        xtitle("Share of women with children in traditional households") ytitle("F-M-Difference Inflation Expectations (in pp)") ///
        legend(label(2 "Data") label(1 "Regression line") order(2 1)) ///
        text(4.9 0.5 "Correlation {it:{&rho} = `rho'} (p-value: {it:`p'})}")
		
	// export figure
    graph export "$results/figure_2a.pdf", replace
    
    
/*====================================================================
   FIGURE 2b: Household organization and inflation expectations
  ====================================================================*/

    // use dataset
    use "$data/infl_gender.dta", clear    
    
	// generate group variables
    gen group = q16_trad+0.15
    replace group = -1 if mi(group)
    
    // collapse data and generate standard errors
    collapse (mean) q18_win (semean) SE = q18_win (count) N = q18_win, by(group q1)
    generate ci_high = q18_win + invttail(N-1, 0.025)*SE
    generate ci_low  = q18_win - invttail(N-1, 0.025)*SE
    
    // adjust for men and women
    replace group = group-0.2 if q1 == 2
    replace group = group+0.2 if q1 == 1
    
    // draw figure
    tw (bar q18_win group if q1 == 2, color("$color1") fintensity(60) barwidth(0.4) lwidth(medthick)) ///
       (bar q18_win group if q1 == 1, color("$color2") fintensity(60) barwidth(0.4) lwidth(medthick)) ///
       (rcap ci_high ci_low group if q1 == 2, lcolor("$color1") msize(huge) lwidth(medthick)) ///
       (rcap ci_high ci_low group if q1 == 1, lcolor("$color2") msize(huge) lwidth(medthick)) , ///
        xlabel(-1 `" "no children" "present" "' 0.15 `" "with children:" "modern roles" "' 1.15 `" "with children:" "traditional roles" "') ///
        xline(-0.425, lcolor(black) lwidth(thin)) ///
        ylabel(10(1)18) yscale(range(9.6 18))  ///
        xtitle(" ") ytitle("Inflation expectation (in %)") ///
        legend(label(1 "Women") label(2 "Men") order(1 2))
		
	// export figure
    graph export "$results/figure_2b.pdf", replace
    
    
/*====================================================================
   TABLE 1 + S12 + S13: Gender dummy and family organization
  ====================================================================*/
  
    // use dataset
    use "$data/infl_gender.dta", clear
	
	// generate variable for organization of family
    gen orga = .
    label define orga ///
            0  "Modern" ///
            1  "Traditional"
    label values orga orga
    label variable orga "Organization of family life"        
        
    // baseline regression only dummy and country fixed effects
    reg q18_win i.q1 i.country_num, robust
    eststo R1
    
    // add financial literacy
    reg q18_win i.q1##i.children i.country_num , robust
    eststo R2
    
    // add controls
    reg q18_win i.q1##i.children $controls, robust
    eststo R3
    
    // only people with children: organization of the family : cooking
    replace orga = .
    replace orga = q16_1_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_1_trad), robust
    eststo R4
    
    // only people with children: organization of the family: leisure activities
    replace orga = .
    replace orga = q16_2_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_2_trad), robust
    eststo R5
    
    // only people with children: organization of the family: staying home when children sick
    replace orga = .
    replace orga = q16_3_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad), robust
    eststo R6
    
    // only people with children: organization of the family: combined
    replace orga = .
    replace orga = q16_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad), robust
    eststo R7
    	
	// write regression table files
    esttab R1 R2 R3 R4 R5 R6 R7 using "$results/table_1.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 order(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)", prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
    
    
    esttab R1 R2 R3 using "$results/table_S12.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps wide varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.children 2.q1#1.children *.q3 *.q4_group *.q5 *.q2 *.q7 *.q11 *.q10 *.fin_lit) ///
                 order(2.q1 1.children 2.q1#1.children *.q3 *.q4_group *.q5 *.q2 *.q7 *.q11 *.q10 *.fin_lit) ///
                 mlabels("(1)" "(2)" "(3)", prefix("{") suffix("}")) ///
                 indicate("Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
                 
                 
    esttab R4 R5 R6 R7 using "$results/table_S13.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps wide varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.orga 2.q1#1.orga *.q3 *.q2 *.q4_group *.q5 *.q7 *.q11 *.q10 *.fin_lit) ///
                 order(2.q1 1.orga 2.q1#1.orga *.q3 *.q4_group *.q5 *.q2 *.q7 *.q11 *.q10 *.fin_lit) ///
                 mlabels( "(4)" "(5)" "(6)" "(7)", prefix("{") suffix("}")) ///
                 indicate("Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
				 
                 
    
/*====================================================================
   FIGURE 3 + TABLE S15: Important product categories
  ====================================================================*/
    
    // use dataset
    use "$data/infl_gender.dta", clear
        
    // do regressions
    reg q18_win i.q1 $controls, robust
    eststo R1
    
    reg q18_win i.q1 i.q1#i.(q21_1_dummy-q21_10_dummy) $controls, robust
    eststo R2
    
    // write regression table file
    esttab R1 R2 using "$results/table_S15.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted baselevels nofloat nogaps wide varwidth(45) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 *.q1#1.q21_*_dummy) ///
                 mlabels("(1)" "(2)" , prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
    
    
    // copy regression results into new dataset
    clear
    
    gen gender = .
    gen category = .
    gen infl_exp = .
    gen stderr = .
    
    insobs 1
    replace gender = 1 if mi(gender)
    replace category = 0 if mi(category)
    replace infl_exp = _b[2.q1] if mi(infl_exp)
    replace stderr = _se[2.q1] if mi(stderr)
    
    forvalues g = 1/2 {
        forvalues c = 1/10 {
            insobs 1
            replace gender = `g' if mi(gender)
            replace category = `c' if mi(category)
            replace infl_exp = _b[`g'.q1#1.q21_`c'_dummy] if mi(infl_exp)
            replace stderr = _se[`g'.q1#1.q21_`c'_dummy] if mi(stderr)
        }
    }
    
    // get error bounds
    generate ci_high = infl_exp + invttail(`e(N)'-`e(df_m)', 0.025)*stderr
    generate ci_low  = infl_exp - invttail(`e(N)'-`e(df_m)', 0.025)*stderr
    
	// label categories
    label define categories ///
            0    "Female" ///
            1    "Eggs" ///
            2    "Fresh food/Veggies" ///
            3    "Dairy/Milk" ///
            4    "Meat/Poultry" ///
            5    "Bread" ///
            6    "Rent" ///
            7    "Clothing" ///
            8    "Travel/Flight prices" ///
            9    "Gasoline/Fuel/Petroleum" ///
           10    "Heating"
    label values category categories
    label variable category "Product categories"
    
    label define gender ///
            1  "Male" ///
            2  "Female"
    label values gender gender
    label variable gender "Gender"
    
	// readjust for gender
    drop if category == 0
    gen xvals = .
    replace xvals = category-0.2 if gender == 2
    replace xvals = category+0.2 if gender == 1
    label values xvals categories    
    replace xvals = xvals + 0.5 if category > 5
    replace xvals = xvals + 0.5 if category > 8	
		
	// draw figure (with CIs)
    tw (bar infl_exp xvals if gender == 2, color("$color1") fintensity(60) barwidth(0.4) lwidth(medthick)) ///
       (bar infl_exp xvals if gender == 1, color("$color2") fintensity(60) barwidth(0.4) lwidth(medthick)) ///
	   (rcap ci_high ci_low xvals if gender == 2, lcolor("$color1") msize(small) lwidth(medium)) ///
       (rcap ci_high ci_low xvals if gender == 1, lcolor("$color2") msize(small) lwidth(medium)) ///
       (scatteri 2.5 0.5 2.5 5.5, recast(line) lw(medium) mc(none) lc(gs7) lp(solid)) ///
       (scatteri 2.5 6.0 2.5 9.0, recast(line) lw(medium) mc(none) lc(gs7) lp(solid)) ///
       (scatteri 2.5 9.5 2.5 11.5, recast(line) lw(medium) mc(none) lc(gs7) lp(solid)), ///
        xlabel(1 "Eggs" 2 "Fresh food/Veggies"    3 "Dairy/Milk" 4 "Meat/Poultry" 5 "Bread" 6.5 "Rent" 7.5 "Clothing" 8.5 "Travel/Flight prices" 10 "Gasoline/Fuel/Petroleum" 11 "Heating", angle(30)) ylabel(-1(0.5)3.5) /// 
        xtitle("") ytitle("Change in inflation expectation (in %)") ///
        legend(label(1 "Women") label(2 "Men") order(1 2) position(2) ring(0)) ///
        text(2.55 3.0 "Food", color(gs7) placement(north)) ///
        text(2.55 7.5 "Family Expenses", color(gs7) placement(north)) ///
        text(2.55 10.5 "Energy", color(gs7) placement(north))
    
	// export figure
	graph display, xsize(*1.2)
    graph export "$results/figure_3.pdf", replace
    
    
    
/*====================================================================
   FIGURE 4 + TABLE S16: Relation between traditional norms and attention to product categories
  ====================================================================*/
    
	// use dataset
    use "$data/infl_gender.dta", clear
    	
	// calculate group
    gen group = q16_trad+1
    replace group = 0 if mi(group)
    
	// get label
    label define group ///
            0    "no children" ///
            1    "with children: modern" ///
            2    "with children: traditional"
    label values group group
    label variable group "Family type"
    
    // run regressions and create output table
    local i = 1
    foreach c of newlist food expenses energy {
      reg q21_`c' ib1.q1##ib0.group $controls, robust
      eststo R`i'
      local i = `i' + 1
    }
    
    // write regression table file
    esttab R1 R2 R3 using "$results/table_S16.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps wide varwidth(45) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 *.group *.q1#*.group _cons) ///
                 mlabels("(1)" "(2)" "(3)" , prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
            
    
	// now generate figure
	matrix define B = J(3, 3, 0)
	matrix define S = J(3, 3, 0)
    local i = 1
    foreach c of newlist food expenses energy {
      reg q21_`c' ib0.group 2.q1#ib0.group $controls, robust
      
	  matrix B[`i', 1] = _b[2.q1#0.group]*100
      matrix B[`i', 2] = _b[2.q1#1.group]*100
      matrix B[`i', 3] = _b[2.q1#2.group]*100
	  
	  matrix S[`i', 1] = _se[2.q1#0.group]*100
      matrix S[`i', 2] = (_se[2.q1#1.group])*100
      matrix S[`i', 3] = (_se[2.q1#2.group])*100
      local i = `i' + 1
    }
	
	
	// copy regression results into new dataset
    clear
    
    gen family = .
    gen category = .
    gen attention = .
	gen ci_high = .
	gen ci_low = .
    
    forvalues t = 1/3 {
        forvalues c = 1/3 {
            insobs 1
            replace family = `t' if mi(family)
            replace category = `c' if mi(category)
            replace attention = B[`c', `t'] if mi(attention)
			replace ci_high = B[`c', `t'] + invttail(`e(N)'-`e(df_m)', 0.025)*S[`c', `t'] if mi(ci_high)
			replace ci_low  = B[`c', `t'] - invttail(`e(N)'-`e(df_m)', 0.025)*S[`c', `t'] if mi(ci_low)
        }
    }
    
    // get labels for categories
    label define categories ///
            1  "Food" ///
            2  "Family expenses" ///
            3  "Energy"
    label values category categories
    label variable category "Product categories"
    
	// get labels for family types
    label define family ///
            0  "No Children" ///
            1  "Children: Modern" ///
            2  "Children: Traditional"
    label values family family
    label variable family "Organization of family life"
    
	// readjust for gender
    drop if category == 0
    gen xvals = .
    replace xvals = category-0.25 if family == 1
    replace xvals = category      if family == 2
    replace xvals = category+0.25 if family == 3
    label values xvals categories
    
    // draw figure
    tw (bar attention xvals if family == 1, color("$color3") fintensity(60) barwidth(0.25) lwidth(medthick)) ///
       (bar attention xvals if family == 2, color("$color4") fintensity(60) barwidth(0.25) lwidth(medthick)) ///
       (bar attention xvals if family == 3, color("$color5") fintensity(60) barwidth(0.25) lwidth(medthick)) ///
	   (rcap ci_high ci_low xvals if family == 1, color("$color3") msize(medium) lwidth(medium)) ///
       (rcap ci_high ci_low xvals if family == 2, color("$color4") msize(medium) lwidth(medium)) ///
	   (rcap ci_high ci_low xvals if family == 3, color("$color5") msize(medium) lwidth(medium)), ///
        xlabel(1(1)3, valuelabel) ylabel(-4(1)6) /// 
        xtitle("") ytitle("{&Delta}F-M in attention to product groups (in %)", height(5)) ///
        yline(0, lcolor(black) lwidth(thin)) ///
        legend(label(1 "No Children") label(2 "Children: Modern") label(3 "Children: Traditional") order(1 2 3) rows(1))
    
	// export figure
	graph display, xsize(*1.2)
    graph export "$results/figure_4.pdf", replace

    
    
/*====================================================================
   ADDITIONAL FIGURES AND TABLES
  ====================================================================*/

  
/*====================================================================
   FIGURE S1: Map of inflation expectations 
  ====================================================================*/

    // use dataset
    use "$data/infl_gender.dta", clear
	
	// get variable of interest
    rename q18_win interest
    
    // collapse and save
    collapse interest, by(country)
    rename country ISO_A3_EH
    merge 1:m ISO_A3_EH using "$map/world.dta", keepusing(_ID)
    save "$data/temp.dta", replace
    
    // draw figure
    geoframe create "$map/countries", replace
    geoframe create "$data/temp.dta", replace nodescribe current
    frame countries: geoframe copy temp interest, id(_ID)
    geoplot ///
        (area countries interest, color(viridis, reverse) cuts(8 9 10 11 12 13 14 15 16 35) ///
         lc(gs8) lw(0.1) missing(color(gs15) nolabel)) ///
        (area countries interest if _ID == 141, lc(gs8) lw(0.1) missing(color(gs15) nolabel)), ///
        tight legend(position(7) size(3) rowgap(1) region(color(gs15))) ///
        grid(tight lw(0.08) lc(gs10)) project(robinson)
		
    // export figure
    graph export "$results/figure_S1.png", replace
    
    
/*====================================================================
   FIGURE S2: Map of gender difference in inflation expectations (relative)
  ====================================================================*/

    // use data
    use "$data/infl_gender.dta", clear
	
	// get variable of interest
    gen q18_women = q18_win if q1 == 2
    gen q18_men = q18_win if q1 == 1
    
    // collapse and save
    collapse q18_women q18_men q18_win, by(country)
    gen interest = (q18_women - q18_men)/q18_win*100
    rename country ISO_A3_EH
    merge 1:m ISO_A3_EH using "$map/world.dta", keepusing(_ID)
    save "$data/temp.dta", replace
    
    // draw figure
    geoframe create "$map/countries", replace
    geoframe create "$data/temp.dta", replace nodescribe current
    frame countries: geoframe copy temp interest, id(_ID)
    geoplot ///
        (area countries interest, color(viridis, reverse) cuts(2 11 15 17 20 25 30 40 45) ///
         lc(gs8) lw(0.1) missing(color(gs15) nolabel)) ///
        (area countries interest if _ID == 141, lc(gs8) lw(0.1) missing(color(gs15) nolabel)), ///
        tight legend(position(7) size(3) rowgap(1) region(color(gs15))) ///
        grid(tight lw(0.08) lc(gs10)) project(robinson)
	
	// export figure
    graph export "$results/figure_S2.png", replace   
	
	
/*====================================================================
   FIGURE S3: Map of women with children in traditional households
  ====================================================================*/

    // use dataset
    use "$data/infl_gender.dta", clear
	
	// get variable of interest
	rename q16_trad interest
	keep if q1 == 2 & !mi(interest)
	
	// collapse and save
	collapse interest, by(country)
	rename country ISO_A3_EH
	merge 1:m ISO_A3_EH using "$map/world.dta", keepusing(_ID)
	save "$data/temp.dta", replace
	
	// draw figure
	geoframe create "$map/countries", replace
	geoframe create "$data/temp.dta", replace nodescribe current
	frame countries: geoframe copy temp interest, id(_ID)
	geoplot ///
        (area countries interest, color(viridis, reverse) cuts(0.4 0.5 0.55 0.6 0.65 0.7 0.75 0.8) ///
	     lc(gs8) lw(0.1) missing(color(gs15) nolabel)) ///
	    (area countries interest if _ID == 141, lc(gs8) lw(0.1) missing(color(gs15) nolabel)), ///
        tight legend(position(7) size(3) rowgap(1) region(color(gs15))) ///
        grid(tight lw(0.08) lc(gs10)) project(robinson)
		
	// export figure
	graph export "$results/figure_S3.png", replace
	
	
/*====================================================================
   FIGURE S4: Histogram of inflation expectations by gender
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	tw (hist q18_win if q1 == 1, width(2.5) color("$color1") fintensity(30) fraction) ///
	   (hist q18_win if q1 == 2, width(2.5) color(cranberry%60) fcolor(cranberry%30) fraction), ///
	    xlabel(0(10)100) ///
        ylabel(0(0.05)0.25) ///
        xtitle("Inflation expectation (in %)") ytitle("Share in data") ///
        legend(label(1 "Men") label(2 "Women") order(2 1))
		
	// export figure
    graph export "$results/figure_S4.pdf", replace
    
    
/*====================================================================
   TABLE S1: Descriptive statistics for general inflation expectations
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	// generate gender specific variables
    gen q18_m = q18_win if q1 == 1
    gen q18_w = q18_win if q1 == 2
	
	// collapse to country dataset
    collapse q18_win q18_w q18_m (median) med = q18_win (min) min = q18_win (max) max = q18_win, by(country)
    gen q18_diff = q18_w - q18_m
    gen q18_rel  = (q18_w - q18_m)/q18_win*100
    
	// write table to screen
    table country, stat(mean q18_win med min max q18_w q18_m q18_diff q18_rel) nformat("%10.2f")

	
	
/*====================================================================
   TABLE S2: Descriptive statistics for food inflation expectations
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	// winzorize q23 at same thresholds as q18
	sum q18_win, det
	
	foreach v of varlist q23 {
        gen `v'_win = `v'
		replace `v'_win = `r(min)' if `v' < `r(min)'
		replace `v'_win = `r(max)' if `v' > `r(max)'
    }
	
	// generate gender specific variables
    gen q23_m = q23_win if q1 == 1
    gen q23_w = q23_win if q1 == 2
	
	// collapse to country dataset
    collapse q23_win q23_w q23_m (median) med = q23_win (min) min = q23_win (max) max = q23_win, by(country)
    gen q23_diff = q23_w - q23_m
    gen q23_rel  = (q23_w - q23_m)/q23_win*100
    
	// write table to screen
    table country, stat(mean q23_win med min max q23_w q23_m q23_diff q23_rel) nformat("%10.2f")
	
	
/*====================================================================
   TABLE S3: Descriptive statistics for energy inflation expectations
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	// winzorize q24 at same thresholds as q18
	sum q18_win, det
	
	foreach v of varlist q24 {
        gen `v'_win = `v'
		replace `v'_win = `r(min)' if `v' < `r(min)'
		replace `v'_win = `r(max)' if `v' > `r(max)'
    }
	
	// generate gender specific variables
    gen q24_m = q24_win if q1 == 1
    gen q24_w = q24_win if q1 == 2
	
	// collapse to country dataset
    collapse q24_win q24_w q24_m (median) med = q24_win (min) min = q24_win (max) max = q24_win, by(country)
    gen q24_diff = q24_w - q24_m
    gen q24_rel  = (q24_w - q24_m)/q24_win*100
    
	// write table to screen
    table country, stat(mean q24_win med min max q24_w q24_m q24_diff q24_rel) nformat("%10.2f")
	
	
/*====================================================================
   TABLE S4: Descriptive statistics for gender norms and information sources
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	// caring for children (cooking)
	tab q16_1 q1, column nofreq
	
	// caring for children (leisure activities)
	tab q16_2 q1, column nofreq
	
	// caring for children (leisure activities)
	tab q16_3 q1, column nofreq
	
	// traditional role model
	tab q16_trad q1, column nofreq
	
	// products relevant for forecasting
	table q1, stat(fvpercent  q21_*_dummy)
	
	
/*====================================================================
   TABLE S5: Descriptive statistics for background variables
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear
	
	// gender
	tab q1
	
	// children present
	tab q9
	
	// family status
	tab q3
	
	// age group
	tab q4_group
	
	// education distribution
	tab q5
	
	// wealth distribution
	tab q7
	
	// employment status
	tab q2
	
	// homeownership
	tab q11
	
	// liquid resources
	tab q10
	
	// financial literacy
	tab fin_lit
    
	
/*====================================================================
   TABLE S6-S10: Demographics by country
  ====================================================================*/
  
    // use data
    use "$data/infl_gender.dta", clear

	// education
	gen education = .
	replace education = 1 if q5 == 1 | q5 == 2
	replace education = 2 if q5 == 3 | q5 == 4
	replace education = 3 if q5 == 99
	
	label variable education "Education"
	label define education_label ///
            1 "Low + middle eductaion" ///
            2 "High Education" ///
            3 "Don't know"
	label values education education_label
	
	// family status
	generate family = .
	replace family = 1 if q3 == 1
	replace family = 2 if q3 == 2 | q3 == 6
	replace family = 3 if q3 == 3 | q3 == 4 | q3 == 5
	
	label variable family "Family Status"
	label define family_label ///
            1 "Single" ///
            2 "Married / with partner" ///
            3 "Separated / Divorced / Widowed"
	label values family family_label
	
	levelsof country_num, local(countries)

	foreach c of local countries {

		xi, noomit: estpost summarize i.q1 i.q4_group i.family q8 children i.education if country_num == `c'

		esttab . using "$results/table_S6_S10_country`c'.tex", replace ///
			cells("mean(fmt(%9.4f) label(Share))") ///
			booktabs label nonumber nomtitle noobs ///
			stats(N, fmt(a5)) ///
			title("Summary statistics, country `c'\label{tab:sum`c'}")
	}
	
	
/*====================================================================
   TABLE S14: Controlling for food and energy price expectations
  ====================================================================*/
  
    // use dataset
    use "$data/infl_gender.dta", clear
	
	// generate variable for organization of family
    gen orga = .
    label define orga ///
            0  "Modern" ///
            1  "Traditional"
    label values orga orga
    label variable orga "Organization of family life"   
	
	// winzorize q23 and q24 at same thresholds as q18
	sum q18_win, det
	
	foreach v of varlist q23 q24 {
        gen `v'_win = `v'
		replace `v'_win = `r(min)' if `v' < `r(min)'
		replace `v'_win = `r(max)' if `v' > `r(max)'
    }
    
    // baseline regression from Table 1 column (3)
    reg q18_win i.q1##i.children $controls, robust
    eststo R1
	
	// add controls for shopping behavior
	reg q18_win i.q1##i.children i.q1#ib2.q13 $controls, robust
	eststo R2
	
	// add controls for food inflation expectations by gender
	reg q18_win i.q1##i.children i.q1#c.q23_win $controls, robust
	eststo R3
	
	// add controls for energy inflation expectations by gender
	reg q18_win i.q1##i.children i.q1#c.q24_win $controls, robust
	eststo R4
	
	// add controls for both food and energy inflation expectations by gender
	reg q18_win i.q1##i.children i.q1#c.q23_win i.q1#c.q24_win $controls, robust
	eststo R5
	
	reg q18_win i.q1##i.children i.q1#ib2.q13 i.q1#c.q23_win i.q1#c.q24_win $controls, robust
	eststo R6
    	
	// write regression table files
    esttab R1 R2 R3 R4 R5 R6 using "$results/table_S14.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nofloat nogaps varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.children 2.q1#1.children 1.q1#*.q13 2.q1#*.q13 1.q1#c.q23_win 2.q1#c.q23_win 1.q1#c.q24_win 2.q1#c.q24_win) ///
                 mlabels("(1)" "(2)" "(3)" "(4)", prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))

	
    
/*====================================================================
   TABLE S17: Alternative explanations
  ====================================================================*/
  
	// use dataset
    use "$data/infl_gender.dta", clear
    
	// determine confidence measure
    gen confidence = q20_win - q19_win    
    
    // baseline regression with confidence
    reg q18_win i.q1 $controls2, robust
    eststo R1
    
    // financial literacy with controls
    reg q18_win i.q1 i.q1#ib1.fin_lit $controls2, robust
    eststo R2
    
    // + forecast confidence
    reg q18_win i.q1 i.q1#ib1.fin_lit i.q1#c.confidence  $controls2, robust
    eststo R3
    
    // plus product categories
    reg q18_win i.q1 i.q1#ib1.fin_lit i.q1#c.confidence  i.q1#i.(q21_1_dummy-q21_10_dummy) $controls2, robust
    eststo R4
    
    // write regression table file
    esttab R1 R2 R3 R4 using "$results/table_S17.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted baselevels nofloat nogaps varwidth(45) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 *.q1#0.fin_lit  *.q1#2.fin_lit *.q1#c.confidence) ///
                 mlabels("(1)" "(2)" "(3)" "(4)" "(5)" , prefix("{") suffix("}")) ///
                 indicate("Product categories=*.q21_1_dummy" "Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
				 


/*====================================================================
   TABLE S18: Sensitivity with Huber robust regression
  ====================================================================*/
  
    // use dataset
    use "$data/infl_gender.dta", clear
	
	// generate variable for organization of family
    gen orga = .
    label define orga ///
            0  "Modern" ///
            1  "Traditional"
    label values orga orga
    label variable orga "Organization of family life"
	
	    
    // baseline regression only dummy and country fixed effects
    rreg q18_win i.q1 i.country_num, genwt(weight_var)
    eststo R1
	
	// examine the weight distribution
	tab q1 if weight_var == 0
	bysort q1: sum weight_var, det
    
    // add financial literacy
    rreg q18_win i.q1##i.children i.country_num
    eststo R2
    
    // add controls
    rreg q18_win i.q1##i.children $controls
    eststo R3
    
    // only people with children: organization of the family : cooking
    replace orga = .
    replace orga = q16_1_trad
    rreg q18_win i.q1##ib0.orga $controls if !mi(q16_1_trad)
    eststo R4
    
    // only people with children: organization of the family: leisure activities
    replace orga = .
    replace orga = q16_2_trad
    rreg q18_win i.q1##ib0.orga $controls if !mi(q16_2_trad)
    eststo R5
    
    // only people with children: organization of the family: staying home when children sick
    replace orga = .
    replace orga = q16_3_trad
    rreg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad)
    eststo R6
    
    // only people with children: organization of the family: combined
    replace orga = .
    replace orga = q16_trad
    rreg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad)
    eststo R7
	
	// write regression table files
    esttab R1 R2 R3 R4 R5 R6 R7 using "$results/table_S18.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 order(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)", prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q3" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
				 
				 
				 
/*====================================================================
   TABLE S19: Sensitivity only for married or cohabiting respondents in households up to 4 people
  ====================================================================*/
  
    // use dataset
    use "$data/infl_gender.dta", clear
	
	// keep only married and cohabiting
	keep if q3 == 2 | q3 == 6
	
	// keep only up to 4 people
	keep if q8 > 1 & q8 <= 4
	
	// generate variable for organization of family
    gen orga = .
    label define orga ///
            0  "Modern" ///
            1  "Traditional"
    label values orga orga
    label variable orga "Organization of family life"        
        
    // baseline regression only dummy and country fixed effects
    reg q18_win i.q1 i.country_num, robust
    eststo R1
    
    // add financial literacy
    reg q18_win i.q1##i.children i.country_num , robust
    eststo R2
    
    // add controls
    reg q18_win i.q1##i.children $controls, robust
    eststo R3
    
    // only people with children: organization of the family : cooking
    replace orga = .
    replace orga = q16_1_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_1_trad), robust
    eststo R4
    
    // only people with children: organization of the family: leisure activities
    replace orga = .
    replace orga = q16_2_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_2_trad), robust
    eststo R5
    
    // only people with children: organization of the family: staying home when children sick
    replace orga = .
    replace orga = q16_3_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad), robust
    eststo R6
    
    // only people with children: organization of the family: combined
    replace orga = .
    replace orga = q16_trad
    reg q18_win i.q1##ib0.orga $controls if !mi(q16_3_trad), robust
    eststo R7
    	
	// write regression table files
    esttab R1 R2 R3 R4 R5 R6 R7 using "$results/table_S19.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 order(2.q1 1.children 2.q1#1.children 1.orga 2.q1#1.orga) ///
                 mlabels("(1)" "(2)" "(3)" "(4)" "(5)" "(6)" "(7)", prefix("{") suffix("}")) ///
                 indicate("Detailed controls= 2.q2" "Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
				 
				 
/*====================================================================
   TABLE S20: Relation to social norms questions
  ====================================================================*/
  
	// use dataset
    use "$data/infl_gender.dta", clear
	
	// recode norms into traditional and standardize
	egen q32_1_trad = std(6-q32_1)
	egen q32_2_trad = std(  q32_2)
	egen q32_3_trad = std(6-q32_3)
	egen q32_4_trad = std(6-q32_4)
	egen q32_5_trad = std(  q32_5)
	egen q32_6_trad = std(  q32_6)
	egen q32_7_trad = std(  q32_7)
	
	// study their correlation structure
	corr q32_?_trad
	
	// on Lickert scale
	reg q16_trad q32_1_trad q32_2_trad q32_3_trad q32_4_trad q32_5_trad q32_6_trad q32_7_trad, robust
    eststo R1
	
	// including country fixed effects
	reg q16_trad q32_1_trad q32_2_trad q32_3_trad q32_4_trad q32_5_trad q32_6_trad q32_7_trad i.country_num, robust
    eststo R2
	
	
	// write regression table files
    esttab R1 R2 using "$results/table_S20.tex", replace ///
                 se(%7.3f) b(%7.3f) r2 compress label nonotes nonumbers nomtitles noomitted nobaselevels nofloat nogaps varwidth(50) ///
                 star(* 0.10 ** 0.05 *** 0.01) ///
                 keep(q32_?_trad) ///
                 mlabels("(1)" "(2)", prefix("{") suffix("}")) ///
                 indicate("Country FE= 2.country_num" , labels("{Yes}" "{No}")) ///
                 stats(N r2, layout({@} {@}) fmt(a3 %5.3f) labels("Number of Cases" "R-Square"))
	
	
	
