# Structure of data and function call for recurrent event data with time-dependent variables

I'm attempting to estimate the effect of 2 drugs (drug1, drug2) on the likelihood of a patient falling (event). The patients can fall more than once and can be put on or taken off of the the drugs at any point.

My question is how the data should be structured with regard to the time period (days), specifically whether there needs to be overlap between the days. There are two reasons why I think my structure is wrong, the first being a seemingly incorrect N. I am also getting some errors where the time period is a single day (i.e. time1=4, time2=4) and am unsure how these should be coded. Should the start time of subsequent entries be the stop time of the previous entry? I've tried it both ways (with and without overlap), and while having overlap gets rid of the warning, the N is still incorrect.

Warning message:
In Surv(time = c(0, 2, 7, 15, 20, 0, 18, 27, 32, 35, 39, 46, 53,  :
Stop time must be > start time, NA created


Right now I have the data set up where the beginning of the next entry is the next day. Unique patients are identified by their chart numbers.

Time1    Time2    Drug1    Drug2   Event    ChartNo
0        2        1        0       0        123
3       10        1        1       1        123
11       14        1        1       1        123
0       11        0        1       0        345
0       19        1        0       1        678
0        4        0        1       0        900
5       18        1        1       0        900


Patient 123 was on drug1 at the start to day 2, after which point they had drug2 added. They went from day 3 to day 10 on both drugs before falling the first time, then fell a second time on day 14 while still on both drugs. Patient 345 went 11 days on drug2 without falling (then was censored), etc.

The actual estimation looks like this:

S <- Srv(time=time1, time2=time2, event=event)
cox.rms <- cph(S ~ Drug1 + Drug2 + cluster(ChartNo), surv=T)


My main concern is that the n for my analysis is reported to be 2017 (the number of rows in the data), when in actuality I only have 314 unique patients. I am unsure if this is normal or the result of some error I've made along the way.

> cox.rms\$n
Status
No Event    Event
1884      133


The same is true when using coxph() from the survival package.

 n= 2017, number of events= 133


The number of events is correct however.

This Post seems to have it set up with the 'overlap' I described, but I am unsure about the N, and they don't seem to be clustering by ID.

• The +cluster(ChartNo) term should take care of the repeated observations concern. An alternate approach would be to add + (1|subject) to a coxme::coxme analysis. – DWin Nov 30 '13 at 23:27

You have multiple records per-patient due to recurrent events and the added complexity of the drug being a time varying covariate. The output you printed using head is helpful for understanding these data.