如何在同一张图上获得多个系数
How to get multiple coefficients on same graph
在 Stata 中,我正在使用 coefplot
包来尝试绘制一个来自多元回归的系数(换句话说,会有多个系数,但每个系数都来自不同的回归)剧情.
这是实现此功能的代码(与 相关)当每个回归中的系数具有相同的名称时:
ssc install coefplot
sysuse auto, clear
estimates clear
regress price mpg if foreign==0
est sto t1
regress price mpg if foreign==1
est sto t2
regress price mpg if rep78==5
est sto t3
coefplot t1 || t2 || t3, drop(_cons) vertical bycoefs yline(0)
一切都很好,很漂亮。但是,当每个回归的系数与不同的变量相关时,我如何才能完成同样的事情呢?例如:
estimates clear
regress price mpg if foreign==0
est sto t1
regress price trunk if foreign==1
est sto t2
regress price weight if rep78==5
est sto t3
coefplot t1 || t2 || t3, drop(_cons) vertical bycoefs yline(0)
当我只想要一个图时,这会生成三个独立的图。我需要做什么才能做到这一点?我想要的是有一个图,其中的系数来自 mpg
(t1
)、truck
(t2
) 和 weight
(t3
) 都绘制在同一个图上。最好知道如何在标记这些系数 mpg, truck, weight
和 t1, t2, t3
.
之间切换
一种解决方案是使用矩阵,但我想尽可能避免走这条路。
注意:coefplot
是一个 user-written 命令。
下面的例子:
sysuse auto, clear
estimates clear
regress price mpg if foreign==0
est sto t1
regress price trunk if foreign==1
est sto t2
regress price weight if rep78==5
est sto t3
coefplot (t1\t2\t3), drop(_cons) xline(0)
除了通常的 help
,还请查看命令作者 Ben Jann 的 this document。
在 Stata 中,我正在使用 coefplot
包来尝试绘制一个来自多元回归的系数(换句话说,会有多个系数,但每个系数都来自不同的回归)剧情.
这是实现此功能的代码(与
ssc install coefplot
sysuse auto, clear
estimates clear
regress price mpg if foreign==0
est sto t1
regress price mpg if foreign==1
est sto t2
regress price mpg if rep78==5
est sto t3
coefplot t1 || t2 || t3, drop(_cons) vertical bycoefs yline(0)
一切都很好,很漂亮。但是,当每个回归的系数与不同的变量相关时,我如何才能完成同样的事情呢?例如:
estimates clear
regress price mpg if foreign==0
est sto t1
regress price trunk if foreign==1
est sto t2
regress price weight if rep78==5
est sto t3
coefplot t1 || t2 || t3, drop(_cons) vertical bycoefs yline(0)
当我只想要一个图时,这会生成三个独立的图。我需要做什么才能做到这一点?我想要的是有一个图,其中的系数来自 mpg
(t1
)、truck
(t2
) 和 weight
(t3
) 都绘制在同一个图上。最好知道如何在标记这些系数 mpg, truck, weight
和 t1, t2, t3
.
一种解决方案是使用矩阵,但我想尽可能避免走这条路。
注意:coefplot
是一个 user-written 命令。
下面的例子:
sysuse auto, clear
estimates clear
regress price mpg if foreign==0
est sto t1
regress price trunk if foreign==1
est sto t2
regress price weight if rep78==5
est sto t3
coefplot (t1\t2\t3), drop(_cons) xline(0)
除了通常的 help
,还请查看命令作者 Ben Jann 的 this document。