让coefplot使用估计标题或结果标签

时间:2017-08-23 05:51:01

标签: stata coefplot

使用社区提供的 Stata命令coefplot来考虑以下玩具示例:

sysuse auto

reg weight i.foreign
eststo, title("Weight"): margins, eydx(foreign) post

reg price i.foreign
eststo, title("Price"): margins, eydx(foreign) post

coefplot est1 est2, horizontal

是否可以获取图例中的标题(甚至是变量标签),而不是估计名称(即WeightPrice而不是est1和{{1 }})?

我知道如何手动完成,但我无法弄清楚如何使用许多模型自动执行此操作。

1 个答案:

答案 0 :(得分:5)

使用estimates store代替eststo可以解决问题:

clear
sysuse auto

reg weight i.foreign
margins, eydx(foreign) post
estimates store weight

reg price i.foreign
margins, eydx(foreign) post
estimates store price

coefplot weight price, horizontal

同样,使用listfor循环:

local list_of_names weight price

foreach item of local list_of_names {
    reg `item' i.foreign
    margins, eydx(foreign) post
    estimates store `item'      
}

coefplot `list_of_names', horizontal

当然,您可以为变量名称和“标签”使用两个不同的lists