2

I am using coxph to estimate the effect of a time-varying variable (tvc) on a survival event (event). Following the several instructions on the Internet (considering tmerge), I prepared the data (df) as:

id  country   start stop    event   endpoint tvc    time
1   a         0     3       0       0        0.1    9
1   a         3     6       0       0        0.2    9
1   a         6     9       0       0        0.3    9
2   a         0     3       1       0        0.1    8
2   a         3     6       1       0        0.2    8
2   a         6     8       1       1        0.3    8
3   b         0     3       1       0        0.1    5
3   b         3     5       1       1        0.2    5

Nevertheless, when I run fit = coxph(Surv(start, stop, event) ~ country + tvc, data=df) it returns a proper coefficient only for each country and the coefficient for tvc results NA. Therefore I do not understand whether there is something wrong with my formula or it is in some way wrong considering tvc as time-varying covariate (since it variates on precise time steps (0-3 = 0.1, 3-6 = 0.2, 6-9 = 0.3) and in these time steps it has the same value no matter the id).

Any help would be much appreciated.

Thanks, Alberto

  • 2
    Did you ever figure this out by any chance? – Bill O'Brien Apr 16 '21 at 21:15
  • I am still not sure about it. The issue is that the time varying covariate is static across IDs, therefore (I assume) the code returns NaNs for that. When I tried a tvc that presented different values not only across times, but also across IDs, the formula worked. – Alberto Grassi Apr 26 '21 at 08:41

0 Answers0