Announcement

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

  • xline above coefplot

    Hi,

    I am plotting a coefplot with rarea for the confidence intervals. My problem is that I want to plot a xline above the area of the confidence intervals and the option xline in coefplot plots it behind. I know that in regular graphs you can use twoway and specify the order in which you want the graphs to plot so you choose which one goes above, but coefplot does not work with twoway. I post the code for an example:

    Code:
    sysuse auto
    reg price mpg trunk turn gear_ratio
    coefplot, vertical drop(_cons) ciopts(recast(rarea)) xline(3)
    This graphs an xline but it appears behind the shaded area, anyone knows how to make it appear above it? I also upload two images: the first is what I'm getting and the second one is what I want to obtain.

    Thanks!

    Click image for larger version

Name:	WhatIGet.png
Views:	1
Size:	10.7 KB
ID:	1470465 Click image for larger version

Name:	WhatIWant.png
Views:	1
Size:	59.1 KB
ID:	1470466

  • #2
    Dear Santiago,
    Possibly this is a 'brute force' solution:
    Code:
    sysuse auto
    reg price mpg trunk turn gear_ratio
    * Manually inspect the CI's largest upper bound value, then create two auxiliary variables
    * and set the value to largest / smallest upper bound value or somewhat above / below, like:
    gen xx=.
    gen yy=.
    replace xx=3 in 1
    replace yy=2000 in 1
    replace xx=3 in 2
    replace yy=-2350 in 2
    coefplot, vertical drop(_cons) ciopts(recast(rarea)) addplot(con yy xx, m(i) lc(red) lw(*1.3))
    but, the result is what you are looking for:
    Click image for larger version

Name:	How_to_draw_xline_On_Top_of_coefplot.png
Views:	1
Size:	44.6 KB
ID:	1470488

    http://publicationslist.org/eric.melse

    Comment

    Working...
    X