2

I am checking a few of my Cox multivariate regression analyses' proportional hazard assumptions using time-dependent co-variates, using the survival package. The question is looking at survival in groups with different ADAMTS13 levels (a type of enzyme).

Could I check if something is wrong with my code itself? It keeps saying Error in tt(TMAdata$ADAMTS13level.f) : could not find function "tt" . Why?

Notably, ADAMTS13level.f is a factor variable.

cox_multivariate_survival_ADAMTS13 <- coxph(Surv(TMAdata$Daysalive, TMAdata$'Dead=1')
                                                        ~TMAdata$ADAMTS13level.f
                                                        +TMAdata$`Age at diagnosis`
                                                        +TMAdata$CCIwithoutage
                                                        +TMAdata$Gender.f
                                                        +TMAdata$`Peak Creatinine`
                                                        +TMAdata$DICorcrit.f,
                                                        tt(TMAdata$ADAMTS13level.f), 
                                                        tt = function(x, t, ...)
                                                        {mtrx <- model.matrix(~x)[,-1] 
                                                         mtrx * log(t)})

Thanks- starting with the fundamentals of my actual code or typos- I have tried different permutations to no avail yet.

Jobolo
  • 79
  • 6
  • 1
    From the document of `?coxph`, `tt` is an "optional list of time-transform functions". You are directly providing a function, so would recommend creating a named function and passing that through a list. Or it seems you just want to create weights from `tt`, so just define `tt` before the call to `coxph`. – caldwellst Jan 27 '22 at 09:18
  • Also, your time transformations don't seem to contribute to your model, and because you are using unnamed parameters, I think your `tt` function *call* will be taken as the value of `data` and its *definition* as the value of `weights`. I doubt that's what you meant. Also, TMAdata$`Dead=1` looks strange, but without a reproducible example, it's impossible to be sure if it's a problem. If you specify `data=TMAdata`, you won't need to specify `TMAData$` in front of every term in your model. It's usually a good idea to start simple and add complexity in stages to be sure all is well. – Limey Jan 27 '22 at 09:24

1 Answers1

1

@Limey was on the right track!

The time-transformed version of ADAMTS13level.f needs to be added to the model, instead of being separated into a separate argument of coxph(...).

The form of coxph call when testing the time-dependent categorical variables is described in How to use the timeSplitter by Max Gordon.

Other helpful documentation:

coxph - fit proportional hazards regression model

cox_multivariate_survival_ADAMTS13 <- 
  coxph(
    Surv(
      Daysalive,
      'Dead=1'
    ) ~
      ADAMTS13level.f
    + `Age at diagnosis`
    + CCIwithoutage
    + Gender.f
    + `Peak Creatinine`
    + DICorcrit.f
    + tt(ADAMTS13level.f), 
    tt = function(x, t, ...) {
      mtrx <- model.matrix(~x)[,-1]
      mtrx * log(t)
    },
    data = TMAdata
  )

p.s. with the original data, there was also a problem because Daysalive included a zero (0) value, which eventually resulted in an 'infinite predictor' error from coxph, probably because tt transformed the data using a log(t). (https://rdrr.io/github/therneau/survival/src/R/coxph.R)

David Fong
  • 506
  • 4
  • 3