Announcement

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

  • How to add "tailor made" error bars to a line graph.

    Dear beloved all,

    Recently I am working on how to draw a line graph like this:
    Click image for larger version

Name:	example.png
Views:	1
Size:	319.6 KB
ID:	1483504



    However, my dependent variable is a series of incidence rates calculated from many waves and I am trying to depict the trajectory of those incidence rates. Hence, I don't want Stata to calculate/predict confident intervals for me, I already had them when I produced my incidence rate before. I just want to add my upper and lower confident intervals by hand. Is it possible?

    Here is my data:
    Click image for larger version

Name:	data.png
Views:	1
Size:	55.5 KB
ID:	1483505



    I want three lines in terms of gender (1 for male, 0 for female, 2 for total), the x should be waves (there are 6) and y should be incidence rates. Here is what I have done so far:

    twoway ///
    (line incidence wave if gender==1) ///
    (line incidence wave if gender==2) ///
    (line incidence wave if gender==0) ///

    but I can't go any further as I have no clue if Stata has the function to achieve my goal.

    Anyway, any suggestions would be extremely important for me and thank you in advance for any help

    Ted.

  • #2
    ok, I find the way. Use: rcap

    twoway ///
    (line incidence wave if gender==0) ///
    (line incidence wave if gender==1) ///
    (line incidence wave if gender==2) ///
    (rcap upper lower wave, vertical)

    For those who may have the same problem

    Comment


    • #3
      Dear Ted,
      thank you for detailing this easy method to add error bars to line graphs.
      It has been shown for bar charts but also works nicely for line graphs.
      Very helpful.
      Martin

      Comment

      Working...
      X