Announcement

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

  • Narrow scale of axis in sts graph (survival data)

    Hello everyone,

    I have another question for which I could not find an answer by myself: I'm trying to create a graph for a survival date analysis (-sts graph-). The command works fine but since there are some outliers with a very high value for the duration variable the graph extents very far to the right. I tried the option -xscale()-, but despite the option is accepted by Stata it does not change the look of the graph. In line graphs, I solve this problem by using the -if- option. In this case, however, the -if- option would also affect the calculation of the Kaplan-Meier survival function, which I would like to avoid. Is there any way to accomplish my goal?

    Here is my full command für the graph:

    [CODE
    ]#delimit ;
    sts graph, ci
    title("")
    xtitle("Elapsed time (days)", size(small)) ytitle("Probability of reaching the respective duration", size(small))
    xlabel(0(200)1000, labsize(small))
    xscale(range(0 1000))
    ylabel(, labsize(small) angle(horizontal))
    legend(off)
    ;
    #delimit cr
    [/CODE]

    Thanks in advance!

    Best regards,
    Sebastian

  • #2
    It would help if 1) you'd show the graph (graph export as png file); Upload attachment (button to left of "A" on right); and 2) tell us the values of the outlying points, which we cannot see.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      I'm using test data to write my do file. Thus, the actual values will definitely differ to some extend, but here is the output of the -sum- command for the dependent variable.

      Code:
      . sum unempl_epi if nrU==1  & jahr>=2010, det
      
           Duration of unemployment episode, with combining (value in
                      all spells, use unempl_first)
      -------------------------------------------------------------
            Percentiles      Smallest
       1%            2              1
       5%            8              1
      10%           17              1       Obs               1,932
      25%         52.5              1       Sum of Wgt.       1,932
      
      50%        145.5                      Mean           494.0316
                              Largest       Std. Dev.      1252.806
      75%        359.5          11317
      90%          992          11757       Variance        1569522
      95%         2023          12673       Skewness       5.532403
      99%         7460          12824       Kurtosis       39.13846
      I hope the percentiles give you a better indication about what I mean with outliers.

      Here is one of the graphs I'm trying to create:
      Click image for larger version

Name:	image_4997.png
Views:	1
Size:	100.3 KB
ID:	1341353

      It would be perfectly fine if the x axis ranges just up to, let's say, 1000.
      Last edited by Sebastian Geiger; 17 May 2016, 20:20.

      Comment


      • #4
        You can restrict the graph with a new stset:
        Code:
        ​stset studytime, fail(fail) exit(time 6000)
        sts graph, ci
        Last edited by Steve Samuels; 18 May 2016, 07:14.
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          Thank you Steve for your answer. Doesn't this also affect how the graph looks like, because the unemployment spells are treated as if they end after 6,000 days even if they are longer?!

          Comment


          • #6
            It's just like cutting off the original graph you show above at 6,000 days. The graph looks different, but the values shown are the same as those on the original curve. Your statement that "unemployment spells are treated as if they end after 6,000 days even if they are longer" is contradictory. The longer spells do end after 6,000 days, but when is not shown. An alternative which will show the entire range is
            Code:
            xscale(log)
            A disadvantage is that will squish the left hand size of the curve.
            Steve Samuels
            Statistical Consulting
            [email protected]

            Stata 14.2

            Comment


            • #7
              Thank you Steve for your help. I checked the graphs again and you are right.

              Comment

              Working...
              X