Monday, July 5, 2021

Coefplot - how to get mlabels similar to sorted ylabels?

Dear Statalister,

I'm trying to substitute ylabels with mlabels, but can't get the mlabels to sort in the same way as the ylabels.

I know how to do this "manually" using
Code:
margins, saving()
and then twoway, but would very much like to do it in Ben Jann's coefplot.


A small example that replicates my problem:


Code:
ssc install coefplot
sysuse lifeexp, clear  
encode country, gen(c)
keep if c<20
reg lexp i.c if c<10 //my data consist of two categories
margins c, post
est store m1
reg lexp i.c if c>9
margins c, post
est store m2

coefplot m1 m2, sort mlab(c) nooffset //ylabs are correct, mlabels incorrect (se image below)
coefplot m1 m2, sort mlab(c) nooffset ylab("") //this is my preferred outcome, but I need the mlabels to be correct

Array

I would very much appreciate your help.

No comments:

Post a Comment