Announcement

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

  • Alter axis in Kaplan Meier

    Can anyone help limiting the x-axis?

    I have made a Kaplan Meier survival graph, but when I try to limit the x-axis the graph still shows values out to ~175

    I have sum timevar and minimum is 0 and maximum 35; I monitor out to 56 days so want the x-axis to run 0-56

    I have tried this: sts graph, ci risktable xscale(range(0 56)) - but the x-axis continue out to 200

    M


  • #2
    Also, the ticks seem to be automatically set at '10'. I can change the label, but not the actual value which I want to be in increments of 7 days

    Comment


    • #3
      Assuming that your time variable is named "day", you could try the following.
      Code:
      sts graph if day <= 56, xlabel(0(7)56)

      Comment


      • #4
        I have never known Stata to create an inappropriately extended scale for these plots. Perhaps there is something in your data you aren't fully aware of. Try this:

        Code:
        summ _t if _st
        This will tell you the range of survival times that Stata has found in your data. My guess is that the max you find will be in the vicinity of 175 or 200. If there aren't supposed to be survival times that long in your data, then either your data have gotten mangled along the way somehow, or you have perhaps made an error in the way you -stset- your data. (E.g., did you need to specify an -origin()- or -scale()- option that you omitted?)

        Remember also that the appropriate range of the horizontal axis in these graphs is out to the last observed time value, be it a failure or a censored observation.

        Added: crossed with Joseph Coveney's response. If you do as Joseph says, you will get a graph with the axis you are looking for. But I think it is a mistake to do that: you are just sweeping some problem with your data under the rug. If you believe that the maximum time should be 56 days and Stata is telling you it finds times going out to around 200, then you have a problem. Either your beliefs are ill-founded, or your data is wrong, or wrongly -stset-. You should solve that problem, and then the graph's appearance will take care of itself. Just forcing the graph to your desired appearance will give you a false picture of your data, and the results in that graph cannot be trusted.
        Last edited by Clyde Schechter; 15 Aug 2016, 20:31.

        Comment


        • #5
          Thanks

          There was indeed a rogue 'total' of 173 carried over when I cut and pasted the data from Excel.

          M

          Comment


          • #6
            The x-labelling also worked perfectly.
            M

            Comment


            • #7
              In response to #5: cut and paste is not a reliable way to transfer data from Excel to Stata, as your very example shows. You should usually use the -import excel- command. There are some irregular Excel data configurations it cannot handle, but if you are copying rectangular blocks of data, the command has a -cellrange()- option that gives you complete and accurate control over just what gets brought in.

              Comment

              Working...
              X