Error in aeqSurv(Y) : aeqSurv exception, an interval has effective length 0
Asked Answered
C

3

7

I'm using R's coxph function to fit a survival regression model, and I'm trying to model time dependent covariates (see this vignette). When fitting the model, I get the following error:

Error in aeqSurv(Y) : aeqSurv exception, an interval has effective length 0

Other than the source code, I couldn't find any references to this error online. Would appreciate any ideas about how to handle this exception.

Cresol answered 28/10, 2017 at 9:56 Comment(3)
If you could provide the Surv object via dput I trust you could get some help. The error sound to me like for some events time == time2:Surv(time, time2, event...)Anselme
Did you find a solution to this? I had code which was working fine for years and I even had workspaces saved that, when I ran the models, worked fine. But recently I've been getting this error as well. Has something changed in the coxph or Surv functions?Bethune
Looks like this error arises with R v. 3.4.3. When I downgraded to version 3.3.3 everything worked again. Hope this works for you.Bethune
S
4

I found the same error. Probably the cause is the aeqSurv routine that treats time values such that tiny differences are treated as a tie. This is actually useful and the error is potentially pointing an issue with the data.

However, if we need to force a solution you can use the coxph.options. Just setting timefix = FALSE in the call to coxph should make the trick!

Source: https://rdrr.io/cran/survival/src/R/aeqSurv.R

Spencerianism answered 8/3, 2019 at 11:44 Comment(0)
C
1

I had this error after I used the survSplit function to make time intervals, prior to fitting with coxph. I noticed that survSplit introduced trailing digits (i.e., 20 days turned into 20.0 days). So I removed those digits with the round function and it worked.

Cartography answered 2/10, 2018 at 20:17 Comment(0)
D
0

Like the above answer, adding the control variable in the coxph function should solve the problem. Please see the reference: https://github.com/therneau/survival/issues/76

model <- coxph(formula = Surv(time1, time2, event) ~ cluster(cluster), 
               data = dataframe, 
               control = coxph.control(timefix = FALSE)) # add the control variable 
Daggerboard answered 8/2, 2021 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.