Interaction with time in a Cox model What is the purpose of adding an interaction with time for a variable that does not meet the proportional hazards assumption? I don't see how it solves the problem. Does it allow the hazard ratio to be estimated, or does it just allow you to keep the variable in the model? I guess if it's the latter, it is a better substitute for stratifying if you have a continuous variable?

If the proportional hazards (PH) assumption isn't met for a predictor, a smoothed plot of its scaled Schoenfeld residuals against time will show how its estimated regression coefficient (log-hazard) changes over time. You might then adapt the model to include an interaction between the predictor and a function of time, a function chosen to match that change of coefficient over time. The R time dependence vignette illustrates that in Section 4, along with the cautions one needs to take to set up that function and the data properly.
That can accomplish two things.
First, it can describe the hazard associated with that predictor more reliably. Otherwise, the fixed-in-time coefficient for that predictor in a PH model will be an average over the events, an average that might hide an important time dependency.
Second, it might improve the estimates of the coefficients for the other predictors in the model. The iterative model-fitting process fits all coefficients together, as it compares each covariate value for the case with an event against the risk-weighted mean of the corresponding values for all cases at risk. With a more realistic model for the hazard over time associated with a predictor that doesn't meet PH, those risk-weighted mean covariate values can become more precise for all covariates.
