考虑以下使用社区贡献的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
有没有可能在图例中获得标题(甚至是变量标签),而不是估计名称(即Weight
和Price
而不是est1
和est2
)?
我知道如何手动操作,但我不知道如何在许多模型中自动完成此操作。
发布于 2018-04-15 20:39:33
使用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
类似地,使用list
和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
当然,您可以为变量名和‘lists
’使用两种不同的标签。
https://stackoverflow.com/questions/45831575
复制相似问题