Plot 如何在同一个图上得到多个系数

Plot 如何在同一个图上得到多个系数,plot,graphics,stata,coefficients,Plot,Graphics,Stata,Coefficients,在Stata中,我使用coefplot包尝试在同一个图上绘制多元回归中的一个系数(换句话说,将有多个系数,但每个系数来自不同的回归) 以下是在每个回归中系数具有相同名称时实现此目的的代码(与相关): 这一切都很好。但是,当每个回归的系数与不同的变量相关时,我怎么能完成同样的事情呢?例如: estimates clear regress price mpg if foreign==0 est sto t1 regress price trunk if foreign==1 est sto t2 r

在Stata中,我使用
coefplot
包尝试在同一个图上绘制多元回归中的一个系数(换句话说,将有多个系数,但每个系数来自不同的回归)

以下是在每个回归中系数具有相同名称时实现此目的的代码(与相关):

这一切都很好。但是,当每个回归的系数与不同的变量相关时,我怎么能完成同样的事情呢?例如:

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
是用户编写的命令

下面是一个例子:

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)

除了通常的
帮助
,还可以查看命令作者Ben Jann的帮助。

Super!是否有方法将系数标记为
t1
t2
t3
,而不是
里程(mpg)
,等等?是的。检查
coeflabels()
asequation
选项。谢谢!我发现这种组合起到了作用:
asequation swapnames noeqlabels
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)