I would like to display the coefficients (with their confidence intervals) of two regressions beneath one another.
Using Ben Jann's nice coefplot
(ssc install coefplot
), I can create a graph with one subgraph only where all coefficients from all models are included, but I do not succeed in ordering the coefficients by model rather than by coefficient.
Alternatively, I can create a graph with several subgraphs by coefficient, which is not I need: there should be one subgraph only, and a common scale for the coefficients.
Here comes a minimum example illustrating my needs and what I just described:
sysuse auto.dta, clear
reg price mpg rep78
eststo model1
reg price mpg rep78 weight
eststo model2
*what do I have: 2 models with 2 coefficients each (plus constant)
*what do I want: 1 graph with 2 models beneath one another,
*2 coefficients per model, 1 colour and legend entry per coefficient (not model!)
*common scale
*what is easy to get:
coefplot model1 model2, ///1 graph with all coefficients and models,
keep(mpg rep78) //but order is by coefficient, not by model
//how to add model names as ylabels?
*or 1 graph with 2 subgraphs by coefficient:
coefplot model1 || model2, ///
keep(mpg rep78) bycoefs
Can anyone help me in getting the graph I want optimally using coefplot
?
As you can read from the notes in the example, the perfect solution would include one colour and legend entry per coefficient (not model) and the ylabels using the model names, but this is secondary.
I already tried a couple of the coefplot
options, but it seems to me that most of them are for several equations from one model rather than for coefficients from different models.