May 16, 2018

Random graphs (132): Distributions


// Open ESS 2006 data
use ESS3e03_6.dta, clear

// Prepare variables
kountry cntry, from(iso2c) 
rename NAMES_STD country

recode agea (999 = .)
recode ygcdbyr (6666/9999 = .)
recode inwyye (9999 = .)
recode gndr (9 = .)

// Generate relevant variables
generate yearborn = inwyye - agea
gen grandparent =  ygcdbyr - yearborn

//Plot figure
twoway kdensity grandparent if gndr == 1, by(country, title(Men  , justification(left) span) note("")) xline(50) ylabel(0 .05 .10, format(%6.2f)) ytitle("Density") xtitle("") /*xtitle("Age at grandparenthood")*/ name(men, replace) nodraw
twoway kdensity grandparent if gndr == 2, by(country, title(Women, justification(left) span) note("")) xline(50) ylabel(0 .05 .10, format(%6.2f)) ytitle("Density") xtitle("Age at grandparenthood") name(women, replace) nodraw

graph combine men women, col(1) ysize(8) note("{it:Note:} Vertical line indicates age 50", size(vsmall))