Which function of time to use in a Cox Regression for time-varying coefficients? I have a Cox regression model where the outcome is a non-recurring event. Within the model, two categorical variables violate proportional hazards, and I have currently extended it to account for time-varying coefficients.
Using the survival package, I have split up the analysis time into multiple intervals per individual, and then created interactions between the variables violating PH and time using the tt() function.
However, I am getting very different results depending on which function of time I specify within the interaction. I am unclear as to why a certain function of time (e.g. log(t) vs t^2) might be preferred within this interaction. Is there a reason to choose one function over another?
 A: The time-dependent vignette for the survival package recommends examining the shape of the plot of scaled Schoenfeld residuals over time and using a function that captures the shape of that relationship; see Section 4.2 of the vignette. That's why different situations might be handled best by different functional forms for the change over time. For this continuous-time modeling approach, that Section shows how to overlay the tt() function result onto the plot of residuals, to see how well you have managed to model the time dependence. Sometimes a simple step function will work well enough, which is modeled instead by breaking the data into strata containing different epochs and allowing covariate:stratum interaction terms; see Section 4.1 of the vignette. You will have to examine your own results to decide which functional form to try.
With two predictors at issue for lack of proportional hazards, you will need to specify a list of functions for tt(), to handle the two invocations of the function in the model formula. Also, be very careful in your syntax. For example, although for the continuous-time modeling approach you are evaluating an interaction of your covariate with a function of time, you don't write it as a usual interaction in the main formula but rather include the tt() as a separate additive term in the formula, with the interaction specified as a product in the definition of tt(). In the example of Section 4.2 of the vignette:
vfit3 <-  coxph(Surv(time, status) ~ trt + prior + karno + tt(karno), data=veteran, tt = function(x, t, ...) x * log(t+20))

Finally, unless you have time-dependent covariates or are using the time-epoch stratification approach to handle step-changes in coefficient values, with no more than one event per individual you don't need to split up the data into "multiple time intervals per individual" to model time-dependent coefficients.
