结合 headings() 和 rename() 与 coefplot (Stata)
Combining headings() and rename() with coefplot (Stata)
假设您要绘制回归系数图,其中对交互作用进行了分组和重命名。按照 -coefplot- 论文(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() 的解决方案。非常感谢任何指针。
使用 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)
假设您要绘制回归系数图,其中对交互作用进行了分组和重命名。按照 -coefplot- 论文(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() 的解决方案。非常感谢任何指针。
使用 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)