Announcement

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

  • Line graphs with fixed time point

    Hi everyone, I am a new user in STATA. I have encountered some problems in making line graphs. My graph is studying the pressure (y variables) over a time period (x variable). However, i would like to only show plots at specific time points such as 1 month, 3 month, 5 month and 7 month (similar to the attached figure, together with the 95% CI. My x variable is non-integers (6 month expressed as 0.5). I am not sure how to produce it.

    I used the command:

    sort time
    twoway (line pressure time)

    Thank you very much if any experts in STATA can give me a kind help. Thank you in advance.

    Source: Lancet 2015; 385: 1295–304
    Attached Files

  • #2
    Just repeating the same post is obviously not helpful. If there was insufficient information in your previous post to give a meaningful answer, than repeating it is not going to solve it. In general you improve your chances of getting a reply if you add some example data. How to do that is discussed in the Statalist FAQ (link is in the black bar near the top of this page).
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Dear Mr. Buis,

      Thank you for the reply and I am very sorry for repeating the post. Attached is the dataset I have obtained, where I have included subjects identification, eyes (0=left eye; 1= right eye), medication (0=drug A; 1= drug B), duration is expressed in terms of years. However, i would like to only show plots at specific time points such as 1 month, 3 month, 5 month and 7 month.


      I used the command and showed the graph as attached.

      sort time
      twoway (line pressure duration if medication==0) (line pressure duration if medication==1)

      May I kindly seek your expertise? Thank you very much and sorry for the inconvenience.
      Attached Files
      Last edited by Wong Ho Lam; 18 Feb 2022, 04:56.

      Comment


      • #4
        Thanks very much.
        Last edited by Wong Ho Lam; 18 Feb 2022, 04:57.

        Comment


        • #5
          Dear all,

          I hope the additional information has made my question clearer. I am frustrated over the graph production. It would definitely be my pleasure if any STATA experts can kindly offer some advice on the graph plotting code. Thank you very much!

          Best,
          William
          Last edited by Wong Ho Lam; 18 Feb 2022, 23:50.

          Comment


          • #6
            Dear all experts,

            Please kindly let me know if I have missed out any important data or I am not explaning data clear enough. Thank you very much and I would be very grateful if any experts can offer any idea on this graph. Thanks!

            Comment


            • #7
              Dear all experts,

              Please kindly let me know if I have missed out any important data or I am not explaning data clear enough. Thank you very much and I would be very grateful if any experts can offer any idea on this graph. Thanks!

              Comment


              • #8
                I am sorry for the disturbance but may I kindly ask if any experts in STATA can give me some hints on this. Thanks very much!

                Comment


                • #9
                  Maarten Buis already in #2 flagged the FAQ Advice as giving guidance on how to ask a good question.

                  https://www.statalist.org/forums/help

                  See also https://www.statalist.org/forums/help#adviceextras #1 on bumping.

                  Unfortunately, it is still very difficult to work out how to relate your information to the graph you showed.

                  You want to plot pressure versus duration, which is fine, but to get confidence intervals for pressure at distinct points, it seems likely that you need to do something quite different. It seems that no one can work that out.

                  Comment


                  • #10
                    Dear Nick,

                    Thank you very much for your kind reply and sorry for bumping that I sincerely apologize for it. May I kindly ask your advice on how to plot pressure versus duration (1 month ,2 month ,3 month etc) at distinct points given that the duration in my dataset is non-integers. Thanks a lot!

                    William

                    Comment


                    • #11
                      As I commented on your cross-post at https://stackoverflow.com/questions/...aph-production it is really up to you to decide how to bin duration. It's not even clear that your data lend themselves to the graph you asked about in #1.

                      There is, on the face of it, an almost impossible trade-off. Restrict attention to data points within a smidgen of 2 months (say) and your confidence intervals will be at best enormous because you have so few data points, and at worse you will have no relevant data. Widening the intervals would improve on that, but then what you are doing is then utterly different from what you seek.

                      I think this is the main reason why people weren't answering your question -- although repeated bumping can be counter-productive too.

                      Comment


                      • #12
                        Dear Nick,

                        Thank you so much for the suggestion. The dataset was just part of the entire set so I guess it would be fine in terms of data quantity. However, If I would like to bin duration to nearest 0.1 month, is the following code appropriate?

                        : duration \ round(duration, 0.1)

                        Thank you very much!!!

                        William

                        Comment

                        Working...
                        X