Announcement

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

  • Adding 95% Confidence Interval to the line graph

    Greetings,

    I have plotted a graph of pressure (y variable) over (duration) as shown below. I have plotted a line graph using the code below. I would like to add the 95% confidence interval to the graph but I have no idea how to do it. I am not sure if using the rcap command is appropriate. Thank you.

    twoway (line pressure1 duration if med==1) (line pressure2 duration if med==2)

    William
    Attached Files

  • #2
    This is the fourth thread you've started with apparently the same question.

    https://www.statalist.org/forums/for...aph-production

    https://www.statalist.org/forums/for...xed-time-point

    https://www.statalist.org/forums/for...mean-and-95-ci


    I can't see that anyone is going to give you a better or a different answer if you don't give more information.

    Comment


    • #3
      Nick,

      I apologize for the insufficient information provided. My data set below (only showed part of it since the data set was large) includes the eye pressure of 3 people administrated to med1 or med2. They were followed up on various durations (duration is expressed in the unit of years). I have plotted the above graph (pressure against duration) but I would like to add the 95% CI to the graph. May I kindly seek your advice. Thank you.
      Attached Files

      Comment


      • #4
        That helps, thank you, although presenting an image rather than using dataex inhibits experiment.

        I tend to use statsby in conjunction with ci for this kind of plot. See https://www.stata-journal.com/articl...article=gr0045 but note that the syntax of ci has changed since that paper.

        A guess would be

        Code:
        statsby , by(duration) clear : ci means pressure 
        
        line mean duration || rcap ub lb duration

        Comment


        • #5
          Thanks a lot Nick for the kind guidance and time!

          Comment

          Working...
          X