Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using coefplot: How to align headings and coeflabels on the left-hand side [Stata 18.0]

    Hi everyone,

    I did 'regress' two times (5 input variables each) and need to show results in two separate graphs using coefplot.
    First graph will show results for variables 'fem' and 'age' and second will show 'edu' and 'rel' and 'rel_lvl'.
    Headings and coefficient labels are supposed to be aligned on the left-hand side of the graph. Have to use Times New Roman font.
    The x-axis scale is supposed to be the exact same in size for both graphs for comparability.

    I've tried
    - Making all headings and labels the same length by adding blank spaces.
    - Graph Dimensions are standardized by using 'xsize' and 'ysize'
    - using 'yscale(alt)' with negative labgaps plus graphregion(margin(l=50)) to make space for the headings and labels on the left-hand side. 'yscale(alt)' with negative labgaps seems to work, but then headings show in inner plot and once I shift them further to the left, they disappear. graphregion did not have an effect.

    This is the code for the first graph:

    Code:
     coefplot ///
                  (Mrule2Efem, baselevels drop(1.treatment#?.fem _cons) label(Baseline) msize(small) mcolor("152 137 26*1.20") mlcolor("152 137 26*1.4") msymbol(triangle) ciopts(lcolor("113 118 10*1.20") lwidth(thin) recast(rspike)) offset(0.35)) ///  
                  (Mrule2Efem, baselevels drop(0.treatment#?.fem _cons) label(PT) msize(small) mcolor("64 0 128*1.2") mlcolor("64 0 128*1.2") msymbol(Th) ciopts(lcolor("64 0 128*1.2") lwidth(thin) recast(rspike)) rename(1.treatment#0.fem=0.treatment#0.fem 1.treatment#1.fem=0.treatment#1.fem) offset(0.15)) ///
                  (Mrule2Eage, baselevels drop(1.treatment#?.age _cons) label(Baseline) msize(small) mcolor("152 137 26*1.20") mlcolor("152 137 26*1.4") msymbol(triangle) ciopts(lcolor("113 118 10*1.20") lwidth(thin) recast(rspike)) offset(0.35))   ///
                  (Mrule2Eage, baselevels drop(0.treatment#?.age _cons) label(PT) msize(small) mcolor("64 0 128*1.2") mlcolor("64 0 128*1.2") msymbol(Th)  ciopts(lcolor("64 0 128*1.2") lwidth(thin) recast(rspike)) offset(0.15) rename(1.treatment#0.age=0.treatment#0.age 1.treatment#1.age=0.treatment#1.age 1.treatment#2.age=0.treatment#2.age 1.treatment#3.age=0.treatment#3.age 1.treatment#4.age=0.treatment#4.age 1.treatment#5.age=0.treatment#5.age)) ///            
                                 , bylabel(East) || ///
                  (Mrule2Wfem, baselevels drop(1.treatment#?.fem _cons) label(Baseline)) ///
                  (Mrule2Wfem, baselevels drop(0.treatment#?.fem _cons) label(PT) rename(1.treatment#0.fem=0.treatment#0.fem 1.treatment#1.fem=0.treatment#1.fem)) ///
                  (Mrule2Wage, baselevels drop(1.treatment#?.age _cons) label(Baseline))   ///
                  (Mrule2Wage, baselevels drop(0.treatment#?.age _cons) label(PT) rename(1.treatment#0.age=0.treatment#0.age 1.treatment#1.age=0.treatment#1.age 1.treatment#2.age=0.treatment#2.age 1.treatment#3.age=0.treatment#3.age 1.treatment#4.age=0.treatment#4.age 1.treatment#5.age=0.treatment#5.age)) ///
                                 , bylabel(West) || ///
                   ,headings(0.treatment#0.fem= "{bf:    Gender}" 0.treatment#0.age="{bf:Age      }", labcolor(purple) labgap(7) nogap) order(0.treatment#0.fem 0.treatment#1.fem 0.treatment#0.age 0.treatment#1.age 0.treatment#2.age 0.treatment#3.age 0.treatment#4.age 0.treatment#5.age, labgap(1)) coeflabels(0.treatment#0.fem=`"{bf:Male}"' 0.treatment#1.fem=`"{bf:Female}"' 0.treatment#0.age=`"{bf:18 - 24}"' 0.treatment#1.age=`"{bf:25 - 34}"' 0.treatment#2.age=`"{bf:35 - 44}"' 0.treatment#3.age=`"{bf:45 - 54}"' 0.treatment#4.age=`"{bf:55 - 64}"' 0.treatment#5.age=`"{bf:65 - }"' , notick labgap(2)) legend( order(2 "Group-Base" 4 "Group-PT" ) rows(1) region(lcolor(bg) lstyle(none) fc(gs15)) bm(small) bplace(7)) xscale(r(0 60)) xlabel(0 10 20 30 40 50 60) subtitle(, color(black) fcolor(pink*0.10) lcolor(pink*0.10)) bgcol(white) scheme(s2mono) ysize(4) xsize(3.9)
    Maybe anyone has any idea.

    Thank you!

  • #2
    Can you provide some reproducible example (not necessarily with your data)? coefplot is from SSC (FAQ Advice #12).

    Comment


    • #3
      Thank you so much for taking the time to reply. I'm not sure I understand 100%. Do you mean using an example data set and re-writing the code so it refers to said data set and then posting it here, so other people will be able to reproduce it?

      Comment


      • #4
        Correct. Refer to FAQ Advice #12 for details: https://www.statalist.org/forums/help#stata.

        Comment

        Working...
        X