Announcement

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

  • Survival function after a stsplit

    Hi, is it possible to plot the survival function by strata (urban-rural designation) after conducting stsplit (because two factors including treatment modality and the urban-rural designation did not meet the proportional hazards assumption) and fitting a model with interaction of these two factors with time? How could I plot these survival functions? Thank you. Talar

  • #2
    Ordinarily, stsplit would have nothing to do with the issue you describe. Perhaps I'd have understood why you used it if you'd shown your stset, stsplit, and stcox statements and their results, as the FAQ request. Please do so in future posts to Statalist.

    Still I'll take a stab. Plotting the survival curves when you have baseline covariates that interact with time is simple with sts graph.

    Code:
    sysuse auto, clear
    gen hirep = rep78>4
    gen trunk14 = trunk-14 /* subtract median to get a meaningful zero */
    stset price
    stcox trunk14 ,tvc(foreign hirep)
    sts graph, by(foreign hirep) separate
    or

    Code:
    stcox trunk14, strata(foreign hirep)
    sts graph, by(foreign hirep) separate
    If the graphs from the two sts graph statements differ much, it suggests that your interaction model could be improved, perhaps by adding the texp() option.
    Last edited by Steve Samuels; 23 Apr 2014, 18:00.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Hi Steve,

      Thank you for your response, I made the plots, it works, but as you indicate, my question was not clear. I am interested to plot the estimated survivor function, as in stcurve, which is not allowed after estimation with tvc() or when the model contains an interaction involving factor variables with time (after conducting an stsplit and fitting a model with interaction of the factors with time).

      Model 1:
      stcox AGEDX i.race i.gender i.marital i.employ i.payer i.RUCA_rec i.stage i.Surg i.Chem i.Rad i.grade, tvc(RUCA_rec Rad) texp(ln(_t))

      The Confidence Intervals were large, so I did

      stset survival, failure(vitalstatus_2==0) id (ID)
      stsplit, at(failures)

      Model 2:
      stcox AGEDX i.race i.gender i.marital i.employ i.payer i.RUCA_rec i.stage i.Surg i.Chem i.Rad i.grade i.RUCA_rec##c._t i.Rad#c._t

      The statement pasted below does not run after both models 1 and 2,
      stcurve, survival at1(RUCA_rec=1) at2(RUCA_rec=2) at3(RUCA_rec=3)

      Is there an alternative for stcurve to get the estimated survivor function for models that contain an interaction involving factor variables with time?

      Please note, I did not know which results to include or if they might be needed for my question.

      Much thanks,
      Talar

      Comment


      • #4
        First I have to apologize for a silly error: sts graph plots only Kaplan-Meier curves, not Cox baseline survival curves. Therefore, ignore my previous code.

        I see that you are following the recipe in "Predictions after stcox with the tvc() option" on page 189 of the Survival manual, but that doesn't work for survival curves with factor variables. You must instead construct iindicator variables for the interacting terms. In the following, I create a three-level variable "rep" based on rep78.

        Code:
        sysuse auto, clear
        rename rep78 rep
        recode rep 1/3=1 4=2 5=3
        tab rep, gen(r)
        sum r1 r2 r3
        /* Important fact about indicator variables:
            rep = 1:  r2 = 0 & r3 = 0
            rep = 2:  r1 = 0 & r3 = 0
            rep = 3:  r1 = 0 & r2 = 0
        */
        gen fail=1
        gen id = _n
        stset price, failure(fail) id(id)
        stsplit, at(failures)
        gen r1t = r1*_t
        gen r2t=  r2*_t
        gen r3t = r3*_t
        
        /* rep = 1:  r2 = r3 = r2t = r3t= 0 */
        stcox   r2 r3 r2t r3t
        stcurve, survival title(rep=1) at(r2=0 r3=0 r2t=0 r3t=0)
        
        /*rep = 2 : r1 = r3 = r1t = r3t =0 */
        stcox   r1 r3 r1t r3t
        stcurve, survival title(rep=2) at(r1=0 r3=0 r1t=0 r3t=0)
        What to show when you post. It's better to construct a minimum example that shows your problem. In other words, you didn't need to include the covariates not involved in the interaction. With that proviso, show all the commands and output from them-skipping nothing.
        Last edited by Steve Samuels; 24 Apr 2014, 19:59.
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          I made the plots with the indicator variables, the survival curves look perfect, thank you.

          Finally, can I show all three curves on the same graph, the survival curve of rep=1, rep=2 and rep=3 presented all on the same graph?

          Thank you,
          Talar

          Comment


          • #6
            I think the following should do that:


            Code:
            stcox   r2 r3 r2t r3t
            stcurve, survival at1(r2=0 r3=0 r2t=0 r3t=0)     ///
                              at2(r3=0 r3t=0)                ///
                              at3(r2=0 r2t=0)                ///
                              lc(blue red yellow)            ///
                              legend(cols(1) ring(0) posi(1) ///
                                     label(1 "Rep 1") label(2 "Rep 2") label(3 "Rep 3"))

            Comment


            • #7
              Yes, it works, thank you for your help.

              Talar

              Comment


              • #8
                Hi,

                I am not sure if Steve's suggestion is correct. Should not we use scurve_tvc command as outlined in this link: https://constantinruhe.files.wordpre...ubmission.pdf?

                Zube
                Last edited by Zube Salis; 13 Jan 2021, 22:51.

                Comment

                Working...
                X