使用社区提供的 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)
是否有可能获得传说中的标题(甚至变量标签),而不是估计的名字(即Weight和Price,而不是est1和est2)?
我知道如何手动完成,但我无法弄清楚如何使用许多模型自动执行此操作.
使用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的变量名称和"标签".
| 归档时间: |
|
| 查看次数: |
218 次 |
| 最近记录: |