【发布时间】:2016-01-28 01:13:15
【问题描述】:
在 Stata 中,我使用 coefplot 包尝试在同一个图上绘制来自多个回归的一个系数(换句话说,会有多个系数,但每个系数来自不同的回归)。
这里是代码(与Plotting same coefficient over time 相关)当每个回归中的系数具有相同名称时:
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 之间切换。
一种解决方案是使用矩阵,但如果可能的话,我想避免走这条路。
【问题讨论】:
标签: plot graphics stata coefficients