Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: competing risk discrete time survival analysis with nlogit

From   Klaus Pforr <>
To   statalist <>
Subject   st: competing risk discrete time survival analysis with nlogit
Date   Tue, 18 Jun 2013 21:23:57 +0200


Dear Listers,

I want to estimate competing risk discrete time event history model as proposed in this paper: Hill, D. H., Axinn, W. G., & Thornton, A. (1993). Competing hazards with shared unmeasured risk factors. Sociological methodology, 23, 245.

I would be happy to get some feedback on my solution, especially on the way I specify the covariates at the different nest-levels in nlogit. Please excuse some redundancies in the code.

I tried to implement this on the example data used in the Stata Manual for stcrreg (hypoxia.dta).

This is my code to solve this.

* start
clear *
set more off
webuse hypoxia

* for comparison if run the standard analysis given in the manual
stset dftime, failure(failtype == 1)
noisily stcrreg ifp tumsize pelnode, compete(failtype == 2)

* now i go for the nlogit-solution
* first i split the episode to have discrete time event history data
* the choice of scale is arbitrary
stset dftime, failure(failtype==1) id(stnum) scale(1)
stsplit spell, every(1)

* Outcome is defined
gen outcome=1 if inlist(failtype,.,0) /* Censored, i.e. after treatment of cervix tumor everything is fine */
replace outcome=2 if failtype==1 /* Event of relapse of pelvic tumor */
replace outcome=3 if failtype==2 /* Event of relapse of tumor in other body region */
label def out 1 "zens" 2 "local relapse" 3 "distant relapse"
label val out out

* Create index to mark "individual" choice sets for nlogit
gen index=_n

* Expand by number of outcomes
expand 3

* Generate alternative-indicator
bysort stnum spell: gen alternative=_n
* Generate choice-indicator
gen choice=outcome==alternative
* Generate indicator for first nest (either 1=censored or 0=event or competing risk)
gen zens=alternative==1

* Check if nest-structure is defined as supposed
noisily  nlogittree alternative  zens , choice(choice)

* Indicator for processtime
quietly tab spell, gen(spnr)

* Estimate the model
* Version 1: Covariates come in at level of censoring vs. event/comp.risk
* Note that I added 8 processtime-indicators

quietly nlogit choice || zens: ifp tumsize pelnode spnr2-spnr9, base(1) ||alternative: , base(1) case(index) vce(robust) difficult
noisily esttab, keep(zens1:ifp zens1:tumsize zens1:pelnode )  unstack eform

* Version2: Covariates come in at last level
* Note that I added no processtime-indicators

quietly nlogit choice || zens: , base(1) ||alternative: ifp tumsize pelnode, base(1) case(index) vce(robust) difficult noisily esttab, keep(alternative2:ifp alternative2:tumsize alternative2:pelnode alternative3:ifp alternative3:tumsize alternative3:pelnode ) unstack eform

* end of code
Some additional notes on the models:
I use robust standard errors to correct for the choice sets as person-splits being nested within persons. I added the difficult-option because of convergence problems that arise when I add periodtime-indicators.

The questions that I have about this solution are:
a) Is this a correct implementation of what is proposed by Hill etal. (1993)? b) What is the difference of putting the covariates in the first instead of putting them in the second level? c) Why does the model have severe convergence problems, when I put the covariates in the second level and add processtime-indicators?

Any comments are highly appreciated.

best wishes


Klaus Pforr
GESIS -- Leibniz Institut für Sozialwissenschaft
Postfach 122155
D - 68072 Mannheim
Tel: +49 621 1246 298
Fax: +49 621 1246 100
E-Mail: <>
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index