bil*_*999 2 graphics plot stata coefficients
在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)
Run Code Online (Sandbox Code Playgroud)
这一切都很好,花花公子.但是,当每个回归的系数与不同的变量相关时,我怎么能完成同样的事情呢?例如:
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)
Run Code Online (Sandbox Code Playgroud)
当我只想要一个图时,这会产生三个单独的图.我需要做些什么才能做到这一点?我想要的是有一个带有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)
Run Code Online (Sandbox Code Playgroud)
除了通常之外help,请查看命令作者Ben Jann的这份文件.