# Time varying Cox regression, adding in a mixed effect for patient

I've been reading a lot of vignettes and literature on how to approach repeated-measures longitudinal data with time varying components for the purpose of time-to-event or survival analysis.

The consensus seems to be that modelling methods that allow for right and left censoring should be used (such as the $$\tt{survival}$$ package in R), and each 'patient' should be split up into long form, with a different row for each interval, with disjointed intervals for each row (see Fox & Weisburg or Thomas & Reyes, for example). This seems to structure the data in way that allows for row independence, since the time intervals are disjoint.

This is where my problem lies: I have a hard time understanding how (or why) these rows from the same patient are considered 'independent'. Why wouldn't we be including a random effect (or a 'frailty') for each patient, as surely the variances of these rows are possibly related somehow?

## 1 Answer

Therneau et al explain this in a vignette about time-dependent covariates and time-varying coefficients in survival analysis:

One common question with this data setup is whether we need to worry about correlated data, since a given subject has multiple observations. The answer is no, we do not. The reason is that this representation is simply a programming trick. The likelihood equations at any time point use only one copy of any subject, the program picks out the correct row of data at each time. There two exceptions to this rule:

When subjects have multiple events, then the rows for the events are correlated within subject and a cluster variance is needed.

When a subject appears in overlapping intervals. This however is almost always a data error, since it corresponds to two copies of the subject being present in the same strata at the same time, e.g., she could meet herself at a party.

Thinking about how Cox regressions work might help make this logic clearer. The analysis is done at each event time. The covariate values for the case having that event are compared against the current covariate values of all cases still at risk at that time.

If there is at most one event per individual, nothing can be done to take into account inter-individual differences in risk except insofar as they are represented in the event times and covariate values themselves. Any inter-individual differences beyond what's in the covariate values and times are necessarily confounded with those values and times.

So if there is at most one event per individual possible, breaking out separate rows for each time period for each individual is just a way of keeping track of which covariate values apply at which times during the analysis. The event times and covariate values over time are still independent among the individuals in the study.

The need for incorporating random effects or "frailties" in some designs is explained for example in this review on multilevel survival analysis:

Conventional regression models assume that subjects are independent of one another.[*] However, subjects who are nested within the same higher level unit are likely to have outcomes that are correlated with one another, thus violating the assumption of independent observations.

The article goes on to explain how groupings of subjects by hospital, geographic locations, and so forth can lead to a need to incorporate frailties into the model, to account for the lack of independence. But those aren't frailties per individual.

Individual frailties do need to be considered when the same person can have more than one event. Then the distributions of event times aren't all independent, as is required by standard Cox regression. Some way of accounting for the intra-individual correlations are required, with frailty terms a way to do that.

So if multiple events per individual are possible, or if there is some higher-level structure that should be taken into account in any analysis, your concerns are warranted. Otherwise, there is no need to worry about that particular problem as there is still independence among event times and individuals. As the vignette demonstrates, there are more than enough other things to worry about in survival analyses with time dependencies.

*If more than one event per individual is possible, then there needs to be a stronger assumption that the event times are independent, even within a subject.

• Yes, I saw this vignette also, thank you. I understand that it's probably the case that this is true, as it's been reiterated in many explanations. I haven't really found anything concrete as to why, though. It just doesn't make intuitive sense to me. Jun 8 '20 at 2:46
• @bandwagoner I've expanded the answer in an attempt to provide more intuition. With at most 1 event per individual, there is no way to account for inter-individual difference in risk except insofar as that information is contained in the event times and covariate values. That is true whether the covariate values happen to be constant over time or are time-varying. Multiple events per individual or higher-order structure to the data (e.g., patients within hospitals) lead to potential non-independence that needs to be addressed with approaches like frailty.
– EdM
Jun 8 '20 at 12:28