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

Dim*_*rov 1 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
Run Code Online (Sandbox Code Playgroud)

是否有可能获得传说中的标题(甚至变量标签),而不是估计的名字(即WeightPrice,而不是est1est2)?

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

Pea*_*cer 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
Run Code Online (Sandbox Code Playgroud)

同样,使用a list和a for循环:

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
Run Code Online (Sandbox Code Playgroud)

您当然可以使用两个不同lists的变量名称和"标签".