Announcement

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

  • Significance stars into the coefplot

    Dear stata users,

    is there a way how to include the significance stars into the coefplot?
    The problem is that sometimes the magnitudes of my coefficients are quite small and it is hard to see whether they are significant.
    Thank you.
    Best,
    Barbora

  • #2
    coefplot is from Stata Journal, as you are asked to explain (FAQ Advice #12).

    Code:
    sysuse auto, clear
    reg mpg weight displacement turn gear_ratio foreign
    coefplot, mlabel(cond(@pval<.001, "<0.001" + "***", ///
    cond(@pval<.01, string(@pval,"%9.3f") + "**", ///
    cond(@pval<.05, string(@pval,"%9.3f") + "*", ///
    string(@pval,"%9.3f"))))) drop(_cons) scheme(s1color) ///
    note("p-values shown alongside markers" "* p<0.05, ** p<0.01, *** p<0.001")
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	32.8 KB
ID:	1570319


    Last edited by Andrew Musau; 27 Aug 2020, 08:12.

    Comment


    • #3
      Hi,

      I am writing because I'm trying to do something similar, but it's not working. Basically, I want the label to be in a different position if the value is positive or negative, plus I want to add stars. I was trying something like this:
      Code:
      coefplot, vertical citop ciopts(recast(rcap) lcolor(black)) recast(bar) barwidt(0.3) addplot( (scatter  @b @at if @b>0,   mlabpos(2) mlabel(@b)  mlabformat("%5.3f") mlabcolor(black) ms(i)) (scatter  @b @at if @b<0,   mlabpos(4) mlabel(@b)  mlabformat("%5.3f") mlabcolor(black) ms(i)))
      With addplot I cannot use the function string() in mlabel. Or at least if I do this:
      Code:
      coefplot, vertical citop ciopts(recast(rcap) lcolor(black)) recast(bar) barwidt(0.3) addplot( (scatter @b @at if @b>0, mlabpos(2) mlabel(string(@b,"%5.3f"))  mlabcolor(black) ms(i))
      I get the error: factor-variable and time-series operators not allowed
      r(101);

      Is there any work-around?

      Comment


      • #4
        I do not see much correspondence between your code and #2 as there is no -addplot()- option specified in the latter. Therefore, this counts as a new question in which case I would recommend that you start a new thread and include a reproducible example that illustrates the problem.

        Comment

        Working...
        X