# Cox Proportional Hazard model (Time dependent covariates) in R

I'm doing a survival analysis using the cox proportional hazard model. I have time dependent covariates so In order to encode time-dependent covariates I used the (start, stop] form of the model described in the following document https://cran.r-project.org/web/packages/survival/vignettes/timedep.pdf. The subjects have different starting (time1) times and stopping times (time2) between 2000 and 2019. My data then looks something like this (but then for around 37000 observations):

I then used the following code to estimate the model and plot the survival curves.

fit <- coxph(Surv(time1, time2, findis) ~ Gearing + PE + crisis + cluster(IDNR), data=mydata)
plot <- ggadjustedcurves(fit, variable = mydata\$PE)


While the estimation output makes sense with my expectations, my problem is that when I run ggadjustedcurves it just keeps on going forever. If I try to plot the curves using: plot(fit) I get the graph below which doesn't seem right to me either, it seems like the graph might look better if it didn't start at zero but at 2000? Can someone tell me what I might be doing wrong? I hope I made everything clear this is my first time using this site.

Usually survival curves are plotted with time 0 for each subject (calling each of your distinct IDNR values a "subject") being the time that the particular subject entered the study. With the way you've set this up, there would be no events until time = 2000 or so (hence your plot), and a subject entering in 2015 could appear to survive longer than one who entered in 2007 just because the subject starting in 2015 entered the study later than the other one. If your data for some reason aren't compatible with time 0 as representing study entry date for each subject, then you have to deal with more difficult issues of data truncation or censoring of entry times, a more advanced topic.
• Thank you for the clarification. As you suggested I defined time 0 for each subject as the corresponding study entry date and then represent the subsequent (start, stop] times for that subject relative to the corresponding time 0 reference. When plotting the survival functions however, I now get Error in Surv(start, stop, findisZM) : Time variable is not numeric – Oscar Jun 7 '20 at 13:09
• Thank you for your help, I figured it out! Using as.numeric() indeed fixed it. – Oscar Jun 7 '20 at 14:59