dear StackExchange users,

I'm struggling with a survival analysis problem. I have longitudinal data, so with multiple observations per individual (about 8 months per person). Each row represents one month. My dataset contains both time-varying variables and time-constant variables. Since the proportionality assumption does no hold on my data, I want to use the piecewise constant hazard model. I figured out how to do this for a binary survival problem (alive/death), but I would like to expand it to a competing risk problem (e.g. sick is the current state, person can move to death or to being healthy again). The only thing this will change in my dataset is that the event column can also have '2' instead of only 1 and 0. I added the code I used for the binary problem below. I'm really hoping someone can help me out!

Data I used now (binary events), named pw.heart enter image description here

and the code I used to fit the piecewise poisson:

fit <- glm(event~offset(log(time))+interval+year, data=pw.heart, fam="poisson")

New data for which I want to predict: enter image description here

lambda <- exp(predict(fit, new=predict.data))

surv.pois <- exp(-cumsum(lambda))


1 Answer 1


In classical time to event or survival analysis the interest is places on the survivor function, which expresses the probability of surviving until a certain time point. However, when various types of events are of interest occur that we can model the cumulative incidence (CI) function for each type of event:

$\widehat{F}_{i}(t) = \sum \widehat{h}_{ij}\widehat{S}(t_{j-1})$

where $\widehat{F}_{i}(t)$ is the CI for event $i$, $\widehat{S}(t_{j-1})$ is the probability of being event free of any type of event, and $\widehat{h}_{ij}$ is the cause specific hazard.

Then you can take the inversion of the cumulative hazard approach, which is piecewise linear.

There are many other ways to model competing risk data. I have here introduced a simple example. A part from that, it has to be distinguished between time dependent hazard models and joint models.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.