I know that in the survival package, you are able to define a function which allows you to transform time in the event that you have a covariate that violates proportional hazards.
However, in the documentation I've seen, you should be able to run a proportional hazards test using cox.zph, but each time I try to run it, it says that the "function is not defined for models with tt() terms."
Is this a change that occurred recently, or am I implementing this incorrectly? The code is below.
cox0 <- coxph(Surv(time=st.time, time2=end.time, event) ~ black + tt(black) + christian +
cluster(id), data =df,
tt = function(x, t, ...) {
mtrx <- model.matrix(~x)[,-1]
mtrx * log(t)
})
test <- cox.zph(cox0,
transform=function(t)log(t))