use gndr fcldbrn yrbrn health agea ///
fltdpr flteeff slprl wrhpp fltlnl enjlf fltsd cldgng cntry ///
using ESS3e03_5.dta, clear
// Gender variable
gen female = (gndr == 2) if gndr !=9
// Calculate age at first birth
recode fcldbrn (6666 = .a "NA") ///
(7777 = .b "Refusal") ///
(8888 = .c "Don't know") ///
(9999 = .d "No answer") ///
, gen(yrfirstbirth)
recode yrbrn (7777 = .b "Refusal") ///
(8888 = .c "Don't know") ///
(9999 = .d "No answer") ///
, gen(yrbirth)
generate afb = yrfirstbirth - yrbirth
qui centile afb, centile(.5 99) // Truncate
replace afb = r(c_1) if afb < r(c_1)
replace afb = r(c_2) if afb >= r(c_2) & !missing(afb)
// Self-rated health variable
recode health ( 1 = 4 "Very good") ///
( 2 = 3 "Good") ///
( 3 = 2 "Fair") ///
( 4 = 1 "Bad") ///
( 5 = 0 "Very bad") ///
( 7 = .a "Refusal") ///
( 8 = .b "Don't know") ///
( 9 = .c "No answer") ///
, generate(srh)
// Depression variable
recode fltdpr flteeff slprl wrhpp fltlnl ///
enjlf fltsd cldgng ///
(7 = .a) (8 = .b) (9 = .c)
recode wrhpp enjlf (1 = 4) (2 = 3) (3 = 2) (4 = 1) (. = .)
scores depression = mean(fltdpr flteeff slprl wrhpp fltlnl enjlf fltsd cldgng)
// Age variable
recode agea (999 = .a)
// Models and plots
regress srh i.afb i.agea if female == 1, cluster(cntry)
qui margins, over(afb)
marginsplot, ytitle("Predicted self-rated health") xtitle("Age at first birth") ///
name(womensrh, replace) recastci(rarea) ciopts(color(gs12)) xsize(3) ///
title("") ylabel(2 (.2) 3.2, format(%6.1f)) nodraw
regress depression i.afb i.agea if female == 1, cluster(cntry)
qui margins, over(afb)
marginsplot, ytitle("Predicted depression") xtitle("Age at first birth") ///
name(womendep, replace) recastci(rarea) ciopts(color(gs12)) xsize(3) ///
title("") ylabel(1.2 (.2) 2.4, format(%6.1f)) nodraw
regress srh i.afb i.agea if female == 0, cluster(cntry)
qui margins, over(afb)
marginsplot, ytitle("Predicted self-rated health") xtitle("Age at first birth") ///
name(mensrh, replace) recastci(rarea) ciopts(color(gs12)) xsize(3) ///
title("") ylabel(2 (.2) 3.2, format(%6.1f)) nodraw
regress depression i.afb i.agea if female == 0, cluster(cntry)
qui margins, over(afb)
marginsplot, ytitle("Predicted depression") xtitle("Age at first birth") ///
name(mendep, replace) recastci(rarea) ciopts(color(gs12)) xsize(3) ///
title("") ylabel(1.2 (.2) 2.4, format(%6.1f)) nodraw
graph combine womensrh womendep, col(1) ysize(8) name(a, replace) ///
title("Women", span) nodraw
graph combine mensrh mendep, col(1) ysize(8) name(b, replace) ///
title("Men", span) nodraw
graph combine a b, col(2) ysize(8) xsize(8) ycommon xcommon ///
note("{it:Source:} European Social Survey, round 3." ///
"{it:Note:} All models control for age as dummy variables. 95% CI's based on robust SE's", span size(*.9))
May 29, 2016
Random graphs (88): Model predictions
Labels:
centile,
European Social Survey,
marginsplot,
Random graphs,
scores
