Announcement

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

  • Survival analysis - single record multiple failure modes

    Dear all,

    I am planning a survival analysis on a single-record multiple failure dataset. Each subject has one entry with multiple independent variables as well as three different potential failure events. Only one of the events is terminal (fail3 - death) but the other two can occur independently and in any order (see below). Many subject may have had none or more of the three events up to a censoring time (checktime).
    I would like to consider all the events in a multiple-failure analysis rather than only the first event. I am not entirely clear on how to stset the dataset - recommendations would be greatly appreciated.
    Many thanks,
    Nikos

    Example table:
    ID - subject ID
    IV1/2 independent variables
    Fail1/2/3 - three different failure modes and corresponding times (where appropriate).
    checktime - last time info is available on subject outcome
    All times are already in days from time of entry with no left-censoring
    ID IV1 IV2 Fail1 Fail1time Fail2 Fail2time Fail3 Fail3time Checktime
    1 33 32 0 . 1 15 0 . 1125
    2 22 43 0 . 0 . 0 . 800
    3 14 23 1 34 0 . 1 155 155
    4 55 34 0 . 1 140 0 . 998
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte(id iv1 iv2 fail1 fail1time fail2) int fail2time byte fail3 int(fail3time checktime)
    1 33 32 0  . 1  15 0   . 1125
    2 22 43 0  . 0   . 0   .  800
    3 14 23 1 34 0   . 1 155  155
    4 55 34 0  . 1 140 0   .  998
    end

  • #2
    Does either of events 1 and 2 occur more than once for the same individual?
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Ah.. you said "single record" and your dataex input statement reflects that. I apologize. Here are the setups for five possible analyses of this data:

      1. Analysis of Type 1 failure , with occurrence of Type 2 as a time-dependent covariate
      2. Analysis of Type 1 failure, treating deaths (Type 3) as competing risks. This is helpful if you want to plot the cumulative incidence curve for Type 1 in the presence of Type 2 (and vice versa).
      3. Analysis of Type 2 failure, with occurrence of Type 1 as a time-dependent covariate
      4. Analysis of Type 2 with death as competing risk
      5. Analysis of death (Type 3)
      There are also formal bivariate survival analyses which model Type 1 and Type 3 simultaneously. I've never done one, but analyses 1 and 2 address the association of the two kinds of events The primary reference for multiple failure types is Mario Cleve's article, which may give you still other ideas. Work through the code and study the listings to see the transformations needed.
      Code:
      * 0. Set up initial data
      clear
      input byte(id iv1 iv2 fail1 fail1time fail2) int fail2time byte fail3 int(fail3time checktime)
      1 33 32 0 . 1 15 0 . 1125
      2 22 43 0 . 0 . 0 . 800
      3 14 23 1 34 0 . 1 155 155
      4 55 34 0 . 1 140 0 . 998
      end
      
      forvalues i = 1/3{ //rename for reshape
       rename fail`i'time time`i'
       }
      
      reshape long time fail, i(id) j(type)
      replace type = 4 if time==.
      replace time=checktime if time==.
      drop checktime
      sort id time
      list // there are duplicates
      duplicates drop
      list id time type, sepby(id)
      save d01, replace
      
      * 1. Analysis of type 1 events (non-competing risk)*/
      stset time, fail(type==1) id(id)
      
      /* create experience variables needed to
       clean the data set and as time-varying predictors*/
      stgen tm1 = when(type==1)
      stgen tm2 = when(type==2)
      stgen ever1 = ever(type==1)
      stgen ever2 = ever(type==2) // covariates
      ** fill in values -note stfill won't do it
      bys id: replace tm1 = tm1[_n-1] if tm1==.
      bys id: replace tm2= tm2[_n-1] if tm2==.
      save d02, replace // Use this for other analyses
      drop if time > tm1
      list id time type tm1 ever1 tm2 ever2 _d _t _t0, sepby(id)
      
      // sample analysis: stcox iv1 iv2 ever2
      
      ** Result of last list
      /*
           +----------------------------------------------------------------+
           | id   time   type   tm1   ever1   tm2   ever2   _d     _t   _t0 |
           |----------------------------------------------------------------|
        1. |  1     15      2     .       0    15       1    0     15     0 |
        2. |  1   1125      4     .       0    15       1    0   1125    15 |
           |----------------------------------------------------------------|
        3. |  2    800      4     .       0     .       0    0    800     0 |
           |----------------------------------------------------------------|
        4. |  3     34      1    34       1     .       0    1     34     0 |
           |----------------------------------------------------------------|
        5. |  4    140      2     .       0   140       1    0    140     0 |
        6. |  4    998      4     .       0   140       1    0    998   140 |
           +----------------------------------------------------------------+
      
      */
      * 2. Type 1 analysis: competing risk is death */
      use d02, clear
      drop if time > tm1 & type==2
      // stcrreg iv1 iv2 , compete(type==3)
      * or stpm2cif
      
      * 3. Type 2 Analysis: not competing risk */
      use d02, clear
      streset, fail(type==2) // change failure type
      drop if time> tm2
      // stcox iv1 iv2 ever1
      
      * 4 Type 2 Analysis-competing risk
      use d02, clear
      drop if time > tm2 & type==1
      // stcrreg iv1 iv2 , compete(type==3)
      
      * 5. Type 3 Analysis */
      use d02, clear
      streset, fail(type==3)
      // stcox iv1 iv2 ever1 ever2
      l
      Last edited by Steve Samuels; 20 Apr 2016, 20:07.
      Steve Samuels
      Statistical Consulting
      [email protected]

      Stata 14.2

      Comment


      • #4
        Sorry, the fourth analysis section should have been:
        Code:
        * 4 Type 2 Analysis-competing risk
          use d02, clear
          streset ,fail(type==2) // <-added,
          drop if time > tm2 & type==1
        // stcrreg iv1 iv2 , compete(type==3) *
        Last edited by Steve Samuels; 21 Apr 2016, 11:43.
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          Thank you, Steve. Converting to multiple entry list looks neat. I will study your code, implement and let you know.
          Nikos

          Comment


          • #6
            Hi Steve,

            Many thanks again for taking the time to write all this. I have been studying it and it has proved very helpful indeed in understanding the transformations. I also read Mario Cleves' article. I think I will need to use his proposal for "unordered failure events of different types" as I am looking for a composite endpoint of type 1/2/3. Type 1 & Type 2 are not competing with Type 3, but Type 3 is always a terminal event of interest (as it represents death).

            One thing I noticed is that the original stset in the code above seems to fail to include the Type 3 events. I think this is because their timestamps are identical to the Type 4 event generated for that subject.
            I thought I would add the following code:
            Code:
             sort id type
             list id time type, sepby(id)
             bys id: drop if time==time[_n-1] & type==4 &type[_n-1]==3
            to remove the extra Type 4 entry, and then make sure to specify in stset that subjects exit at a Type 3 event. Does that sound ok?

            I will keep you posted of progress.

            Nikos

            Comment


            • #7
              That sounds right. There should have been no Type 4 event for ID 3.
              Last edited by Steve Samuels; 15 May 2016, 18:26.
              Steve Samuels
              Statistical Consulting
              [email protected]

              Stata 14.2

              Comment

              Working...
              X