Announcement

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

  • twoway scatter with vertical lines connecting min and max

    Hi,

    I'm doing a twoway scatterplot, let's say:
    graph twoway scatter GDP assets

    Now, GDP is a coefficient from a previous regression. I also saved the values limiting the 90% confidence intervall, i.e. GDPup90 and GDPlow90

    Now, I want to plot
    graph twoway scatter GDP GDPup90 GDPlow90 assets

    and I want the dots for GDPup90 GDPlow90 to be connected with GDP in between.

    How can I achieve this?

    Thanks in advance!

  • #2
    Combining rcap and scatter may work:

    Code:
    clear
    input gdp assets
    1 1
    2 2
    3 2.5
    4 4
    5 3.2
    end
    
    gen width = runiform()*3
    gen lc = gdp - width
    gen uc = gdp + width
    
    twoway (rcap lc uc assets)(scatter gdp assets)
    Adding two more scatter layers can also conceal the end of the whiskers, if that's what you are aiming for.

    Code:
    twoway (rcap lc uc assets)(scatter gdp assets)(scatter lc assets)(scatter uc assets)

    Comment


    • #3
      Perfect! Thanks a lot!

      Comment

      Working...
      X