coefplot:使用垂直选项放置回归名称

时间:2019-01-28 20:02:41

标签: stata

当前,我有以下代码:

sysuse auto, clear
estimates clear 

gen year=.
replace year=1988 if foreign==0
replace year=1989 if foreign==1 

regress price mpg trunk length turn if year==1988
estimates store Year1988

regress price mpg trunk length turn if year==1989
estimates store Year1989

coefplot Year1988 Year1989, vertical keep(trunk) xline(0) xlabel("")

这将生成:

enter image description here

但是,我想为每个存储的回归结果集(如:

)添加自定义名称

enter image description here

我该怎么做?我尝试了xtickxlabel,但没有用。

请注意:here可以找到没有vertical选项的答案。

1 个答案:

答案 0 :(得分:1)

想法是相同的:

sysuse auto, clear
estimates clear 

gen year=.
replace year=1988 if foreign==0
replace year=1989 if foreign==1 

regress price mpg trunk length turn if year==1988
estimates store Year1988

regress price mpg trunk length turn if year==1989
estimates store Year1989

local gap1 : display _dup(45) " "
local gap2 : display _dup(40) " "

coefplot Year1988 Year1989, vertical keep(trunk) xline(0) ///
coeflabels(trunk = `""|`gap1'|""1988`gap2'1989""') ///
xlabel(, notick labgap(0)) xline(0) legend(off)

enter image description here