coefplot: Putting names of regressions on y-axis

前端 未结 1 587
无人及你
无人及你 2021-01-28 01:47

The following code will generate a coefficient plot:

sysuse auto, clear
regress price mpg trunk length turn if foreign==0
estimates store D
regress price mpg tru         


        
相关标签:
1条回答
  • 2021-01-28 01:52

    I think this is a terrible idea. If you keep repeating Domestic/Foreign, then there is no way for the reader to know which pair corresponds to each variable.

    Here's a better approach:

    sysuse auto, clear
    estimates clear 
    
    regress price mpg trunk length turn if foreign==0
    estimates store D
    
    regress price mpg trunk length turn if foreign==1
    estimates store F
    
    coefplot (D, asequation(Domestic) \ F, asequation(Foreign)), drop(_cons) xline(0) 
    

    Alternatively:

    coefplot (D, asequation \ F, asequation), drop(_cons) xline(0) ///
    eqlabels("Domestic" "Foreign", asheadings)
    


    EDIT:

    The only way you can achieve what you want is by using the following hack:

    coefplot D F, drop(_cons mpg length turn) ///
    coeflabels(trunk = `""Domestic -" " " " " " " " " " " " " " " "Foreign -""') ///
    ylabel(, notick labgap(0)) xline(0) legend(off)
    

    You will obviously have to adapt it for your different use cases.

    0 讨论(0)
提交回复
热议问题