Announcement

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

  • Changing x-axis from days into years on kaplan meier

    Dear Stata community,

    Thank you for all your help so far.

    I am doing some KM analysis for my study and the time in is days. The last exit on the survival data is about 13,000 days. In order for the reader to understand clear, I would like to convert the x-axis into years (ideally 5 yearly intervals e.g. 5, 10, 15, 20, 25, 30, 35). I am reluctant to convert the actual variable into years as this results in multiple records at same instant and therefore I lose some of the data. Is there a way just to change the the x-axis on the KM graph into years?

    Many thanks for your help once again,

    Roshani



    Click image for larger version

Name:	time_to_advanced100.png
Views:	1
Size:	117.6 KB
ID:	1527276

  • #2
    For twoway type graphs, you have the option of specifying your own x/y labels. So do the math and add the labels

    Code:
    sysuse census
    tw scatter marriage pop, xlab(5000000 "13" 10000000 "Whatever") scheme(s1color)
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	64.8 KB
ID:	1527281

    Comment


    • #3
      Andrew Musau has it right. Here is a helper command to do such conversion of scales. You want say 0(5)40 in years but your scale is days.

      Code:
      ssc install mylabels
      mylabels 0(5)40, myscale(365.25*@) local(xlabel)
      displays this (which is also held in the local macro.

      Code:
      0 "0" 1826.25 "5" 3652.5 "10" 5478.75 "15" 7305 "20" 9131.25 "25" 10957.5 "30" 12783.75 "35" 14610 "40"
      so that you can use the local macro in your graph call or even copy and paste into that.

      Comment


      • #4
        Just speculating, maybe the stset option - scale(365.25) - would do the trick.
        Best regards,

        Marcos

        Comment


        • #5
          Marcos Almeida is I guess right.

          I've never used Kaplan-Meier myself.
          Last edited by Nick Cox; 03 Dec 2019, 05:02.

          Comment


          • #6
            Dear All,

            Thank you for your fast responses!

            Marcos - I used your scale option and this has worked perfectly!!

            Thanks so much!!!
            Roshani

            Comment


            • #7
              Thanks for informing the suggestion worked well.
              Best regards,

              Marcos

              Comment

              Working...
              X