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:
where the variable marital_status is coded as:
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:
For instance, for the relative likelihood to cohabit (vs being married), I am using the following:
Any ideas?
Thanks!
[Stata version 17.0]
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
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
Code:
option compete(): competing risks events must be stset as censored
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
Thanks!
[Stata version 17.0]

Comment