我想显示两个回归之下的系数(带有置信区间)。
使用Ben Jann的漂亮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
以最佳方式获取我想要的图表吗?
正如您可以从示例中的注释中读到的那样,完美的解决方案将包括每个系数(不是模型)的一个颜色和图例条目以及使用模型名称的y标签,但这是次要的。
我已经尝试了几个coefplot
选项,但在我看来,大多数选项都来自一个模型的几个方程,而不是来自不同模型的系数。
答案 0 :(得分:0)
我不知道如何处理模型名称,但对于问题的第一部分,在我看来,你可以做一些像:
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)
或者我误解了你想要的东西?