# R Survival Analysis - Cox Regression and Cumulative Time Dependent Covariate

Hoping for some help related to a survival analysis using R and the survival package. I've been relying heavily on a series of blog posts done by Dayne Batten, particularly this portion: [http://daynebatten.com/2015/12/survival-analysis-customer-churn-time-varying-covariates/]

I've collected and merged the data as instructed using the tmerge function. My model relies on a cumulative time-dependent covariate, which strays away from the example provided. So my first question is does a cumulative covariate affect the validity of the Cox Regression? Here is my code at the moment:

fit <- coxph( Surv(tstart, tstop, had_event) ~ review_event, data = newdatatestcum)


My second question pertains to the lack of an ID being assigned within this model. For each customer ID within this data I have up to a few hundred lines of events with my covariate. I don't see how this regression could possibly be accounting for that.

• Why do you think it would affect the validity of the Cox regression? – Theodor Jun 9 '16 at 12:54
• Being as new to this as I am I feared any deviation from the post and there is little documentation on cumulative covariates as it relates to the Cox Regression. Really just hoping to hear of others' experiences and possible pitfalls in trusting the results. – Chapin23 Jun 9 '16 at 13:17
• @Chapin23 Think of doing regular linear regression $y \sim X \beta$ where each row in the predictor $X$ varies from a sample to the next one. Time doesn't play a role here because the model is Markov. – wsw Jun 29 '16 at 21:52

In the logic of the (extended) Cox model, the hazard $h(t)$ is defined as $$h(t) dt = P(T = t| T \geq t, \mathcal{H}(t_-))$$
In other words, the hazard at time $t$ depends on the probability of the event to happen at time $t$, given that it has not happened so far ($T\geq t$) and given the past ($\mathcal{H}(t_-)$). This past includes information up to time $t$. In particular, if you have a covariate $x(t)$ that you want to use, you may as well use any functional form of $x(t)$, like $\int_0^t x(s)ds$ (the cumulative version), or $\log x(t)$, or whatever.