一个使用两个类别(而不是时间)的荒谬示例可以很容易地适应:
clear
set more off
sysuse auto
reg price weight rep78 if foreign
estimates store foreign
reg price weight rep78 if !foreign
estimates store not_foreign
matrix at = (1 / 2)
coefplot foreign || not_foreign, drop(rep78 _cons) vertical bycoefs
您可以使用local
. 然后喂给coefplot
. 准确地说,我的意思是类似于示例语法:
year1 || year2 || ... || yearn
最终命令看起来像:
coefplot `allyears', drop(<some_stuff>) vertical bycoefs
一个涉及时间的完整示例:
clear
set more off
use http://www.stata-press.com/data/r12/nlswork.dta
forvalues i = 70/73 {
regress ln_w grade age if year == `i'
estimates store year`i'
local allyears `allyears' year`i' ||
local labels `labels' `i'
}
// check
display "`allyears'"
display `"`labels'"'
coefplot `allyears', keep(grade) vertical bycoefs bylabels(`labels')
如果coefplot
结果不够灵活,您可以随时尝试使用statsby
和graph
命令 ( help graph
)。