Announcement

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

  • Twoway scatter with horizontal confidence intervals

    Dear all,

    my data looks the following:
    observation treatment north mean_v1 yu_v1 yl_v1 mean_v2 yu_v2 yl_v2
    1 0 0
    2 0 1
    3 1 0
    4 1 1
    where
    - yu= upper confidence level
    - yl = lower confidence level
    for the respective mean



    I need to plot this graph:
    Click image for larger version

Name:	drawing graph two var.png
Views:	3
Size:	90.1 KB
ID:	1761030


    My code so far is:
    Code:
    gen y_v2 = 1
    gen y_v1 = 2
    
    //// so that I can adjust shape and color etc separately by treatment later on:
    separate mean_v1, by(treatment)
    separate mean_v2, by(treatment)
    separate yu_v1, by(treatment)
    separate yu_v2, by(treatment)
    separate yl_v1, by(treatment)
    separate yl_v2, by(treatment)
    
    twoway ((scatter y_v1 mean_v10) (scatter y_v1 mean_v11) (scatter y_v2 mean_v20) (scatter y_v2 mean_v21)), by(north)
    Usually, I'd add the confidence intervals with rcap() but that only works vertically as far as I know.
    Does anyone have an idea? Am I entirely on the wrong path?

    Best

    Anna
    Attached Files

  • #2
    I've been told that my way of providing data is not sufficient. My apologies. This is the updated version:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(treatment north mean_v1 mean_v2 yu_v1 yu_v2 yl_v1 yl_v2)
    0 0 12.92 4.38 15.19 5.21 10.61  3.5
    0 1  8.05 3.07 10.59 4.15  5.47 1.99
    1 0  13.4 5.42 17.96 6.76 10.82 4.08
    1 1  8.11 2.99 12.54 3.68  5.62 2.32
    end
    Last edited by Anna Binger; 08 Aug 2024, 08:06.

    Comment

    Working...
    X