Announcement

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

  • Competing-risks regression

    Hi all!

    I am having issues setting up and estimating a competing-risk regression using the command stcrreg. Any help on this is much appreciated.

    I have an unbalanced panel of individuals. Individuals transit over time through different marital statuses (i.e., singlehood, cohabitation, and marriage). The data looks like this:
    Code:
    clear
    input str7 id float(year marital_status) int age
    "1" 2002 0 25
    "1" 2005 2 27
    "1" 2010 2 32
    "2" 2002 0 30
    "2" 2003 0 31
    "2" 2004 1 32
    "2" 2005 1 33
    "2" 2006 2 34
    "2" 2010 2 43
    "2" 2011 0 44
    "3" 2010 0 26
    "4" 2002 0 40
    "4" 2004 2 42
    "4" 2006 1 44
    "4" 2008 0 46
    end
    where the variable marital_status is coded as:
    Code:
    label define status 0 "singlehood" 1 "cohabitation" 2 "marriage"
    
    label values marital_status status
    
    tab marital_status, m
    
    marital_stat |
              us |      Freq.     Percent        Cum.
    -------------+-----------------------------------
      singlehood |          7       46.67       46.67
    cohabitation |          3       20.00       66.67
        marriage |          5       33.33      100.00
    -------------+-----------------------------------
           Total |         15      100.00
    I am interested in studying the impact of age on the likelihood that a given marital status occurs. For that, I am trying to estimate sub-hazard ratios between different competing marital statuses but apparently, I am not setting up the data correctly since I get the following error message:
    Code:
    option compete(): competing risks events must be stset as censored
    For instance, for the relative likelihood to cohabit (vs being married), I am using the following:
    Code:
    clonevar year1 = year
    
    snapspan id year1 marital_status, gen(year0) clear
    
    stset year1, id(id) origin(time year0) failure(marital_status = 2)
    
    Survival-time data settings
    
               ID variable: id
             Failure event: marital_status==2
    Observed time interval: (year1[_n-1], year1]
         Exit on or before: failure
         Time for analysis: (time-origin)
                    Origin: time year0
    
    --------------------------------------------------------------------------
             15  total observations
              1  ignored because never entered
              3  observations end on or before enter()
              5  observations begin on or after (first) failure
    --------------------------------------------------------------------------
              6  observations remaining, representing
              3  subjects
              3  failures in single-failure-per-subject data
              9  total analysis time at risk and under observation
                                                    At risk from t =         0
                                         Earliest observed entry t =         0
                                              Last observed exit t =         4
    
     
    
    stcrreg age, compete(marital_status = 1) robust
    option compete(): competing risks events must be stset as censored
    Any ideas?
    Thanks!

    [Stata version 17.0]

  • #2
    Try with double equal signs in both stset and stcrreg.
    Code:
    stset year1, id(id) origin(time year0) failure(marital_status == 2)
    Code:
       
     stcrreg age, compete(marital_status == 1) robust

    Comment


    • #3
      Thanks, Paul. Double-equal signs do not make the trick. I think the error message is related to the way I define failures and non-failures (i.e., censored observations) in the stset command.

      Comment

      Working...
      X