Announcement

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

  • Сode for display censored data

    The following code creates comparative cumulative incidence functions (without showing censored data):

    use http://www.stata-press.com/data/r13/hypoxia
    stset dftime fail(failtype==1)
    stcrreg ifp tumsize pelnode, compete(failtype==2)
    stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0)

    Whether it is possible to add (at the end) the code which will show (on curves) the censored data (ie zeros in censore variable " failtype ") to run in the command window?
    P.S. Of course, this is a model example (to use it for other data).
    Thank you in advance!

  • #2
    For twoway type graphs, you have the addplot option. You may need to adjust where the y axis begins as the defaults do not take into account whatever is included in the additional plot.


    Code:
    gen Censored= 0.failtype
    
    stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0) ///
    addplot(scatter Censored _t, mcolor(blue) msize(tiny) ) ///
    yscale(range(0 0.5))

    Comment


    • #3
      Thank you, Andrew! I consistently entered commands in the Command window:

      use http://www.stata-press.com/data/r13/hypoxia
      stset dftime, fail(failtype==1)
      stcrreg ifp tumsize pelnode, compete(failtype==2)
      gen Censored= 0.failtype
      stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0)
      addplot(scatter Censored _t, mcolor(blue) msize(tiny) )
      command addplot is unrecognized
      Last edited by Ted Turov; 02 Dec 2017, 15:26.

      Comment


      • #4
        -addplot- is not a command and thus cannot be the first word on a line (unless, like Andrew in #2, you are using a do-file and you comment out the line break); so, move the addplot line to the same line as the -stcurve- command

        Comment


        • #5
          use http://www.stata-press.com/data/r13/hypoxia
          stset dftime, fail(failtype==1)
          stcrreg ifp tumsize pelnode, compete(failtype==2)
          gen Censored= 0.failtype
          stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0) addplot(scatter Censored _t, mcolor(blue) msize(tiny) ) yscale(range(0 0.5))

          Points appear, but not there where they are need (I consistently entered commands in the Command window).
          Sincerely thanks Andrew and Rich, this is enough, not need anything else!

          Comment


          • #6
            Do you need to project these points to the curves? I do not have much experience with survivor functions so I cannot vouch for the validity of what you are doing. However, here are two ways

            1. Use dropline with reduced opacity for the lines (Stata 15), or

            2) Represent points as broken segments on the curves


            Just a slight correction from the above. The variable dfcens=0 if censored.

            Code:
            use http://www.stata-press.com/data/r13/hypoxia
            stset dftime, fail(failtype==1)
            stcrreg ifp tumsize pelnode, compete(failtype==2)
            desc dfcens
            *Set censored variable= maximum of the curves' yscale and missing if not censored
            gen censored= cond( dfcens==0, 0.5,.)
            stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0) ///
            addplot(dropline censored _t, mcolor(none) lcolor(blue%25)) ///
            yscale(range(0.1 0.5))
            
            stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0) ///
            addplot(dropline censored _t, mcolor(none) lcolor(white)) ///
            yscale(range(0.1 0.5)) legend(off) ///
            note(Note: Broken segments in the curves represent censored points)
            If you had something else in mind, please explain.

            Click image for larger version

Name:	graph1.png
Views:	1
Size:	44.9 KB
ID:	1420700

            Click image for larger version

Name:	graph2.png
Views:	1
Size:	31.4 KB
ID:	1420701

            Comment


            • #7
              Thank you Andrew, you are very responsive man! very responsive ...

              Comment


              • #8
                "A voice in the wilderness"
                I'm close to solution, but I need a hint a person who knows Graph Editor.
                When I activate plot1, censor points appear (with a small lines!) on plot1,
                and when I activate plot2 censor points appear on plot2 too, but disappear on plot1.
                To activate both areas (plot1 and plot2) at the same time does not obtained!
                (The mouse click using SHIFT button on background does not help.)

                use http://www.stata-press.com/data/r13/hypoxia
                stset dftime, fail(failtype==1)
                stcrreg ifp tumsize pelnode, compete(failtype==2)
                stcurve, cif at1(ifp=5 pelnode=0) at2(ifp=20 pelnode=0)
                Last edited by Ted Turov; 06 Dec 2017, 11:30.

                Comment

                Working...
                X