Announcement

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

  • Can truncating and recasting CIs on coefplot disrupt grstyle set ?

    Dear list members,

    this is probably a query I could have forwarded privately to the author of the two commands under consideration, coefplot and grstyle (ssc describe coefplot ssc describe grstyle), but I guess others may be able to contribute and benefit from reading perhaps.

    One the one side, when using coefplot, a combination of the options transform(), if() and copts(recast()) (or cirecast()) can be used to identify confidence intervals that are too large by some chosen measure, truncate them and place an arrow at the truncation to flag it for the reader. An example is here.

    On the other side, when introducing grstyle, Jann(2018) warns that some commands may override and disrupt the pre-specified style settings. The full quote is:

    Another reason why your style settings may not have an effect is that some of
    the higher-level graph commands (that is, commands other than graph that internally
    call graph) apply explicit style settings to certain elements and, hence, override the
    defaults provided by grstyle. An example is marginsplot, which internally applies
    option pstyle(p1) (or pstyle(p2), pstyle(p3), etc., depending on context) to the
    confidence intervals so that point estimates and confidence intervals are displayed using
    the same style. This makes it difficult to modify point estimates and confidence intervals
    individually. For example, if you apply option recastci(rarea) to marginsplot so that
    the confidence intervals are displayed as areas instead of capped spikes, using grstyle
    to set the attributes of elements p1area and p1arealine will have no effect unless you
    also add option ci1opts(astyle(p1area)) to marginsplot. If your graph contains
    multiple series of estimates and you want all confidence areas to look the same, it is
    probably easiest to set the attributes of the ci elements (see help scheme ci plots)
    and then add option ciopts(astyle(ci)) to marginsplot.
    I was wondering if anyone knows if this can also be the case with coefplot when specifying recast(pcarrow) to place arrowheads on truncated CIs.

    If so, I would also like to know if, rather than setting schemes (which I am not familiar with) it is possible to solve the issue by using the more intuitive grstyle set. In particular, I'm having problems with plot color settings.
    I'm using StataNow/MP 18.5

  • #2
    Yes, I believe coefplot also applies explicit pstyle() options internally, similar to marginsplot.

    Comment


    • #3
      Thanks Ben Jann . May I ask you, if not too busy at the moment, to use the CI truncation and recast example from your website to illustrate here how you would ensure that options set by grstyle set, for example
      Code:
      grstyle set symbol default, select(1 2 3 4 5 7 8 9 10)
      grstyle set color okabe, drop(5)
      is not disrupted? I've been trying various ways but -frustratingly- without success.

      Many thanks in advance.
      I'm using StataNow/MP 18.5

      Comment


      • #4
        Not really clear to me what exactly you want. For me, grstyle works well with the truncated CIs in coefplot. Example:

        Code:
        sysuse nlsw88, clear
        regress wage ibn.occupation if union==0, nocons
        est sto nonunion
        regress wage ibn.occupation if union==1, nocons
        est sto union
        
        grstyle init
        grstyle set symbol default, select(2 3)
        grstyle set color okabe, select(2 3)
        
        local o1 pstyle(p1) offset(.15)
        local o2 pstyle(p2) offset(-.15)
        local nl if(@ll>2&@ul<12)
        local ul if(@ll>2&@ul>=12)  ciopts(recast(pcarrow)) nokey
        local ll if(@ll<=2&@ul<12)  ciopts(recast(pcrarrow)) nokey
        local bl if(@ll<=2&@ul>=12) ciopts(recast(pcbarrow)) nokey
        coefplot (union,    `o1' `nl') ///
                 (union,    `o1' `ul')  ///
                 (union,    `o1' `ll') ///
                 (union,    `o1' `bl') ///
                 (nonunion, `o2' `nl') ///
                 (nonunion, `o2' `ul')  ///
                 (nonunion, `o2' `ll') ///
                 (nonunion, `o2' `bl') ///
            , nooffset transform(* = min(max(@,2),12)) grid(between)
        Result in Stata 17:

        Click image for larger version

Name:	Graph.png
Views:	1
Size:	69.0 KB
ID:	1718021
        ben

        Comment


        • #5
          Many thanks Ben Jann - problem partially solved. Part of the problem lied in the fact that I did not specify the pstyle() option to ensure that, within each plot, every pair of potential "renderings" for each model (truncated vs not truncated) is given one fixed style.

          Unfortunately, while this fixes the disruption of colorstyle, I still have a problem with markers. At the outset I specify
          Code:
          grstyle set symbol default, select(1 2 3 4 5 7 8 9 10)
          where 5 is the X.

          However, as the image shows and the graph editor confirms, I get a small x (sic). Modifying from the editor doesn't work: the setting goes back to small x. But the option large X, which I guess is just the X of symbolstyle with larger size and not a different symbol, does work - but I don't know how to specify it in advance via grstyle set symbol. Is this about trying to specify unequal sizes for different markers at the outset?

          I read that my code, which does not specify elements, by default assigns the chosen properties to p. Adding plots() also doesn't solve the problem. I might try to extract and simplify the relevant part of my code, although it's not that simple.



          Attached Files
          Last edited by Matteo Pinna Pintor; 23 Jun 2023, 03:27. Reason: new information
          I'm using StataNow/MP 18.5

          Comment


          • #6
            The issue was indeed solved by first realizing that a msize() option was specified in coefplot, thereby overriding any previous related setting, and then using grstyle set symbolsize to give the X a larger size than the one given to other symbols in the chosen symbolpalette.
            I'm using StataNow/MP 18.5

            Comment

            Working...
            X