I've produced the below two graphs using coefplot (graphs are based on margins produced after running linear regression models):
graph 1:
Code:
regress bmi14 c.sdmh14##c.sdmh14 i.peducation2 i.incomeq3 i.ethnic5cat if sex==1 margins , at(sdmh14=(-6(1)6)) post est store age14males regress bmi14 c.sdmh14##c.sdmh14 i.peducation2 i.incomeq3 i.ethnic5cat if sex==2 margins , at(sdmh14=(-6(1)6)) post est store age14fem coefplot age14males age14fem, at ytitle(BMI(kg/m2)) xtitle(SD mental health) recast(line) lwidth(*1) noci
Code:
regress bmi17 c.sdmh17##c.sdmh17 i.peducation2 i.incomeq3 i.ethnic5cat if sex==1 margins , at(sdmh17=(-6(1)6)) post est store age17males regress bmi17 c.sdmh17##c.sdmh17 i.peducation2 i.incomeq3 i.ethnic5cat if sex==2 margins , at(sdmh17=(-6(1)6)) post est store age17fem coefplot age17males age17fem, at ytitle(BMI(kg/m2)) xtitle(SD mental health) recast(line) lwidth(*1) noci
I'm stuck with (this combines both graphs together in the same plot) this obviously wrong code:
Code:
coefplot (age14males \ age17males , label (boys)) /// (age14fem \ age17fem , label (girls)), at ytitle(BMI(kg/m2)) xtitle(SD mental health) recast(line) lwidth(*1) noci
Many Thanks
/Amal
0 Response to Combining 2 coefplots (based on margins from linear regression models) to have a panel graph
Post a Comment