0

I have a dataset with time, event and 4 predictor variables of which "Q.V4" is a categorical variable which needs to be transformed using tt function. This variable has 4 levels - Q1, Q2, Q3, Q4

F1 <- data.frame(
  time=c(102,48,84,72,66,90), 
  event=c(0,1,0,0,0,0), 
  v1=c(72,76,74,76,72,61),
  v2=c(1,1,1,1,1,1), v3=c(1,1,2,2,1,2), 
  Q.V4=c("Q2","Q4","Q3","Q1","Q2","Q1"))

coxph(Surv(time,event)~v1 + v2 + v3 + tt(Q.V4), data = F1, 
 tt = function(Q.V4,time,...){matrix <- model.matrix(~Q.V4)[,-1] matrix*time)})                                                                                                                                                                                             

I am getting the following error message

unexpected symbol in "function(Q.V4,time,...){ matrix <- model.matrix(~Q.V4)[,-1]"                                                                                          

I would really appreciate if you can please show me where I am making the mistake and help me with the right code at your earliest. Thanks in advance.

Biostats
  • 51
  • 8

0 Answers0