我想要显示两个回归的系数(以及它们的置信区间)。使用Ben Jann的nice coefplot (ssc install coefplot),我可以创建一个只有一个子图的图,其中包含来自所有模型的所有系数,但我不能成功地按模型而不是按系数对系数进行排序。
或者,我可以通过系数创建一个包含多个子图的图,这不是我所需要的:应该只有一个子图,以及系数的公共比例。
这里有一个最小的例子来说明我的需求和我刚才描述的内容:
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 有没有人能帮我优化使用coefplot得到我想要的图形
正如您可以从示例中的注释中读到的,完美的解决方案将包括每个系数(而不是模型)的一个颜色和图例条目,以及使用模型名称的标签,但这是次要的。
我已经尝试了几个coefplot选项,但在我看来,它们中的大多数是针对来自一个模型的多个方程,而不是针对来自不同模型的系数。
发布于 2017-04-20 06:06:48
我不确定如何处理模型名称,但对于您问题的第一部分,在我看来,您可以这样做:
sysuse auto.dta, clear
reg price mpg rep78
eststo m1
reg price mpg rep78 weight
eststo m2
coefplot (m1) || (m2), ///
drop(_cons) byopts(row(2)) keep(mpg rep78)还是我误解了你想要什么?
https://stackoverflow.com/questions/43502247
复制相似问题