假设您想要制作回归系数图,其中交互被分组和重命名。按照-coefplot- paper(Jann,2014)中的示例,以下代码允许您对交互进行分组:
* BEGIN *
sysuse auto, clear
keep if rep78>=3
//run regression
quietly regress mpg headroom i.rep78#i.foreign
eststo model
//plot results
coefplot model, ///
xline(0) omitted baselevels ///
headings( 3.rep78#0.foreign = "{bf:Interaction Effects}") ///
drop(_cons)
* END *
以下允许您重命名交互(为了简洁起见,只有一个):
* BEGIN *
coefplot model, ///
xline(0) omitted baselevels ///
rename( 3.rep78#0.foreign = "new name") ///
drop(_cons)
* END *
但结合两种方法
* BEGIN *
coefplot model, ///
xline(0) omitted baselevels ///
rename( 3.rep78#0.foreign = "new name") ///
headings( 3.rep78#0.foreign = "{bf:Interaction Effects}") ///
drop(_cons)
* END *
不会产生预期的结果。
对于我的数据,我也使用groups()选项,所以我想找到一个解决方案,我可以将headings()和rename()结合起来。任何指针都非常感谢。
答案 0 :(得分:2)
使用coeflabels()
选项:
*----- example data -----
sysuse auto, clear
keep if rep78>=3
//run regression
quietly regress mpg headroom i.rep78#i.foreign
eststo model
*----- what you want -----
coefplot model, ///
xline(0) omitted baselevels ///
coeflabels(3.rep78#0.foreign = "new name") ///
headings(3.rep78#0.foreign = "{bf:Interaction Effects}") ///
drop(_cons)