Announcement

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

  • Margins for different percentiles

    Dear Statalist,

    I am trying to do a margin for an interaction depending on different values. I would like to do something like the next graph I will show. This is a toy model with the interactions I want to plot.
    Code:
     mixed innprod L.offshoring L.c.Boffshoring##L.c.newlnBS_offshoring##L.c.newlnBS_offshoring  ||new_xactin: ||ident: L.offshoring , cov(unstructure)
    Thereafter, I want the margins for the 25 and 75 percentiles of Boffshoring, that is, I need two different curves (25th and 75th) for several values of the other variable. But instead, it just give me for the 75th.
    Code:
     margins,  at(L.newlnBS_offshoring = (0 (0.8) 4) (p25)(p75)L.Boffshoring)
    
    Predictive margins                              Number of obs     =     93,036
    
    Expression   : Linear prediction, fixed portion, predict()
    
    1._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =           0
    
    2._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =          .8
    
    3._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =         1.6
    
    4._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =         2.4
    
    5._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =         3.2
    
    6._at        : L.Boffshor~g    =           0 (p75)
                   L.newlnBS_~g    =           4
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             _at |
              1  |   .6513781   .1626375     4.01   0.000     .3326143    .9701418
              2  |   .6424268   .2395786     2.68   0.007     .1728614    1.111992
              3  |   .6149054   .3314346     1.86   0.064    -.0346945    1.264505
              4  |   .5688139   .4381152     1.30   0.194    -.2898761    1.427504
              5  |   .5041523   .5595803     0.90   0.368    -.5926049     1.60091
              6  |   .4209207   .6958102     0.60   0.545    -.9428422    1.784684
    ------------------------------------------------------------------------------
    
    marginsplot, xdim(L.newlnBS_offshoring)
    Is there any way to do something like the next graph?
    Many thanks in advance.
    Click image for larger version

Name:	Captura.PNG
Views:	1
Size:	45.5 KB
ID:	1491309

  • #2
    While margins will work with percentiles, I often just do a su on the variables and use actual values:

    margins, at(x1=(1(1)17) x2 =(.207 .574 .853))

    marginsplot ,recast(line) noci plot1opts(lpattern(line) lcolor(black) ) ///
    plot2opts(lpattern("--")lcolor(blue) ) plot3opts(lpattern("-..-..") lcolor(red) ) /// ///
    ytitle("Predicted OEE + Offset") ylabel(69(2)85) ///
    legend(on order(1 "10th %tile" 2 "50th %tile" 3 "90th %tile" )) ///
    title(Predicted OEE at Different Capacity Utilization Levels)

    Comment


    • #3
      Thanks for the answer Phil, I will do a summary and get values from there as you suggest.

      Comment

      Working...
      X