Announcement

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

  • Coefplot with second y-axis

    Dear All,
    I am running a fixed effect neg binomial regression and want to plot some of the regression coefficients with 95% CI using coefplot.

    Code:
    . eststo raw11: xtnbreg sumnalaxone  int3-int4 int6-int9 i.year i.treat age if year>2012, fe  exposure(exposure)   /* WORKS*/
    note: 2281 groups (2281 obs) dropped because of only one obs per group
    note: 2529 groups (6872 obs) dropped because of all zero outcomes
    
    Iteration 0:   log likelihood = -394.85682  
    Iteration 1:   log likelihood = -378.89183  
    Iteration 2:   log likelihood = -373.71977  
    Iteration 3:   log likelihood = -373.29432  
    Iteration 4:   log likelihood = -373.28541  
    Iteration 5:   log likelihood = -373.28387  
    Iteration 6:   log likelihood = -373.28352  
    Iteration 7:   log likelihood = -373.28343  
    Iteration 8:   log likelihood = -373.28342  
    
    Conditional FE negative binomial regression     Number of obs     =        685
    Group variable: studypersonid                   Number of groups  =        220
    
                                                    Obs per group:
                                                                  min =          2
                                                                  avg =        3.1
                                                                  max =          7
    
                                                    Wald chi2(14)     =      86.89
    Log likelihood  = -373.28342                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
     sumnalaxone |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            int3 |   1.150222   1434.497     0.00   0.999    -2810.411    2812.712
            int4 |   -.650432   1.213165    -0.54   0.592    -3.028191    1.727327
            int6 |   2.006028   .5589152     3.59   0.000     .9105741    3.101481
            int7 |   2.109025   .5748433     3.67   0.000     .9823525    3.235697
            int8 |   2.130793   .5859116     3.64   0.000     .9824274    3.279159
            int9 |   2.272671   .7126006     3.19   0.001     .8759997    3.669343
                 |
            year |
           2014  |   14.12338   638.2786     0.02   0.982     -1236.88    1265.126
           2015  |   14.04019   638.2786     0.02   0.982    -1236.963    1265.043
           2016  |   14.69761   638.2786     0.02   0.982    -1236.305    1265.701
           2017  |   14.98768   638.2786     0.02   0.981    -1236.015    1265.991
           2018  |   15.10221   638.2786     0.02   0.981    -1235.901    1266.105
           2019  |   14.59542   638.2787     0.02   0.982    -1236.408    1265.599
                 |
         1.treat |  -.3597424   .6071373    -0.59   0.554     -1.54971    .8302249
             age |   -.041732   .0211664    -1.97   0.049    -.0832173   -.0002467
           _cons |  -22.66602   638.2789    -0.04   0.972     -1273.67    1228.338
    ln(exposure) |          1  (exposure)
    ------------------------------------------------------------------------------
    
    . coefplot, keep(int3 int4 int6 int7 int8 int9) mcol(cranberry) msym(o) ciopts(lcolor(gs8)) ///
    >  coeflabels( int3="2013" int4="2014" int6="2016" int7="2017" int8="2018" int9="2019" , angle(45))  mlabsize(huge) ///
    >  title("", color(black) size(large)) ysc(r(-4 4) noext) ///
    >  yline(0, lcol(black)) xline(2.5, lwidth(2.2) lcolor(gs10))   ///
    >  ytitle(Estimated coefficient, size(medium) margin(small)) vertical omitted
    Since the CI on int3 is so large, we cannot see the CI of remaining coefficients. Is there a way I could plot int3 on yaxis(1) and the others on yaxis(2)? Will be grateful for any guidance to modify the coefplot code to utilize both y-axes.
    Many thanks.
    Sumedha.
    Click image for larger version

Name:	Graph.png
Views:	1
Size:	32.0 KB
ID:	1585278

  • #2
    You could place 2013 and 2014-2019 into separate graphs and then combine them, something like this:
    Code:
    sysuse auto
    regress price weight mpg turn trunk
    coefplot ., keep(weight) vertical fxsize(25) name(a, replace)
    coefplot ., keep(mpg turn trunk) vertical name(b, replace)
    graph combine a b
    Alternatively, some hints on how one could clip CIs are given at http://repec.sowi.unibe.ch/stata/coe...vals.html#h-7.

    Comment

    Working...
    X