# Cox PH controlling for multiple events

I'm working on a cox proportional hazard analysis in R using the survival package. I´m analysing covariate effects on fish movement within a study area. The study area is divided into two zones ("A" & "B"), each zone is analysed separately. I will focus on zone "B" to make it easier to explain. In zone B 3 different events can occur (0= day/night change, 1=moving from zone "B" to zone "A", 2=leaving study area (final event)). In zone "B" the number of events per individual range between 1-11 (mean 2.24).

T1 indicates start time and T2 indicates stop time. If the fish move from zone B -> zone A and then returns to zone B T1 is reset to 0 as none of the events in Zone B could occur when not being present in zone B. If event 0 occurs time is accumulated and T1 is equal to T2 in the previous event (example data below).

I´m trying to control for the multiple events by adding individual id as a random effect using frailty(id) in the model. Se example code below:

frailty_model <- coxph(formula=Surv(T1 , T2, event==2) ~ length + discharge + day + frailty(id), data = cox_data, na.action = na.fail)

I´m getting this error for some of the frailty models:

Warning message:
In coxpenal.fit(X, Y, istrat, offset, init = init, control, weights = weights,  :
Inner loop failed to converge for iterations 3


According to Therneau, this warning could be ignored (https://stat.ethz.ch/pipermail/r-help/2016-September/441556.html). But before I found this out I tried to stratify the model using number of exposures in the zone, assuming this would give similar results.

Example code:

stratified_model <- coxph(formula=Surv(T1 , T2, event==2) ~ length + discharge + day + strata(exp), data = cox_data, na.action = na.fail)

But the results differ greatly from each other. Covariates that have a lot of effect on the model fit in the stratified model have almost no effect in the frailty model.

Here´s a piece of dummy data formatted the same way as the original data

  id      exp    T1     T2 event length day          discharge

1 53885     1  0     57.7  1       12.5 Day               24.5
2 53885     2  0      7.7  1       12.5 Day               24.5
3 53885     3  0     16.3  1       12.5 Day               24.4
4 53885     4  0      8.87 2       12.5 Day               24.3
5 53989     1  0      3.35 0       13.5 Day               30.5
6 53989     1  3.35 211.   1       13.5 Night_Lights      30.6
7 53989     2  0     21.6  2       13.5 Night_Lights      30.6


QUESTIONS
Have I done something fundamentally wrong to get such so different results? Or should that be assumed when using the two different approaches?
Would you suggest any other way to control for multiple events?

UPDATE 20/5:

Clarification on the description of event 0

So, let’s say that an individual enters the zone at 19:00 and leave the study area at 23:00 (event 2). At 21:00 it becomes night, so this individual spends 2 hours in the zone during the day without leaving and another 2 hours in the zone during the night after which it leaves the study area. Event 0 is maybe better described as a censoring event, in this example it would occur at 21:00 splitting the "original" event into a day section and a night section so that the correct day/night covariate can be assigned to the individual. That´s also why the end time of event 0 is the start time of event 2 as the individual have had the opportunity to leave the area during the entire period.

• Using an automatic spell checker can be a good idea. Commented May 19, 2022 at 13:17
• Yeah, sorry about that. I was a bit stressed so forgot to check the spelling. Commented May 19, 2022 at 14:06

It would be simpler to think of this as a multi-state survival model, as explained in the vignette, and study both Zones together. The id values keep track directly of which fish is involved. You don't necessarily need a frailty term in that situation.
With a multi-state model, your states would include in Zone A, in Zone B, and out of study; perhaps there are more you haven't described. You would then model all possible transitions between those states.
The day/night change doesn't seem to make sense as an event, as that is an external variable that should be treated as a time-varying covariate.