Combining headers () and renaming () with coefplot (Stata)

Let's say you want to create a regression coefficient plot where interactions are grouped and renamed. Following an example from the -coefplot-paper (Jann, 2014), the following code allows for grouping interactions:

* 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 *

      

and the following allows you to rename the interaction (just one for brevity):

* BEGIN *
coefplot model, /// 
    xline(0) omitted baselevels ///
    rename( 3.rep78#0.foreign = "new name") /// 
    drop(_cons)
* END *

      

but combining the two methods

* 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 *

      

does not give the desired result.

For my data, I also use the groups () parameter, so I would like to find a solution where I can combine headers () and rename (). Any pointers are appreciated.

+3


source to share


1 answer


Use the parameter 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)

      

+2


source







All Articles