# Extended Cox model with continuous time dependent covariate - how to structure data?

I need to run an extended Cox model with a time-varying covariate in R: let’s call it the "number of doses" (X). I am interested in the hazard ratio associated with each level of X, ie. how an additional dose affects the likelihood of recovery.

X is a discrete, positive integer. It can either remain constant or increase by 1 during each observation time. status=1 represents recovery and d1,d2,...d6 are the number of doses received (created for modeling purposes)

I am not sure how to set up the data. I’ve come up with two alternatives based on my reading and am attaching an excerpt of the data set-up and the code for each method, however I’m not sure which (if either) is correct for answering this question? They give fairly different results.

The data has been artificially parsed at each observation time (stop):

    patient     start      stop doses d1 d2 d3 d4 d5 d6 status
1  0.000000  0.034000     1  1  0  0  0  0  0      0
1  0.034000 12.949399     2  1  1  0  0  0  0      0
1 12.949399 13.813242     3  1  1  1  0  0  0      0
1 13.813242 30.835070     4  1  1  1  1  0  0      0
2  0.000000  0.240000     1  1  0  0  0  0  0      0
2  0.240000  2.984179     2  1  1  0  0  0  0      0
2  2.984179  4.014723     3  1  1  1  0  0  0      0
2  4.014723  5.186506     4  1  1  1  1  0  0      0
2 20.869955 29.832999     4  1  1  1  1  0  0      0
2 29.832999 32.063887     5  1  1  1  1  1  0      0
2 32.063887 37.924743     6  1  1  1  1  1  1      1


METHOD 1: treat the number of doses as a factor

    dt<-read.csv('data.csv',header=T)
surv<-Surv(start,stop,status,data=dt)
m<-coxph(surv ~ factor(doses),data=dt)


METHOD 2: treat each dose as a binary variable

    dt<-read.csv('data.csv',header=T)
surv<-Surv(start,stop,status,data=dt)
m<-coxph(surv ~ d1+d2+d3+d4+d5+d6, data=dt)


Does either method take into account that a patient had (n-1) doses in the previous period?

• I don't think either method "takes into account" the value in a precious interval. Furthermore, you should only use 5 dummies if you have 6 levels, that is only if you choose to do it the hard way in not using a factor variable. You could always create a cumulative dose variable.
– DWin
Commented May 4, 2013 at 5:27
• I don't think you should look at "time-dependent covariates". Instead, you should go for "repeated measures". Commented May 4, 2013 at 7:37
• @ocram a repeated measures analysis will not handle an arbitrary baseline hazard function. Commented Mar 8, 2018 at 15:35