Error: For survival models, then the reponse has to be of class `inla.surv'; you have `list'

41 views
Skip to first unread message

Aria

unread,
Jul 12, 2024, 4:38:21 PM (9 days ago) Jul 12
to R-inla discussion group
Hello,

I'm trying to estimate two survival models together using inla(). It works well when I specify the two survival models to be Weibull distributed, i.e., family = c('weibullsurv', 'weibullsurv'). However, I had an error when I tried to use a random walk as the baseline hazard and specified family = c('coxph', 'coxph'). The error message is: "For survival models, the response has to be of class inla.surv; you have list."

Here is a simple version of my code:

>y.r = inla.surv(time = c(time.r, rep(NA, n2)), event = c(event.r, rep(NA, n2)))
>y.t = inla.surv(time = c(rep(NA, n1), time.t), event = c(rep(NA, n1),event.t))
>y.joint = list(y.r, y.t)
>linear.covariate = data.frame(x.r = c(data$x, rep(0, n2)),
                              x.d = c(rep(0, n1), data.d$x))
>data.f = c(linear.covariate)
>data.f$Y = y.joint
>formula = Y ~ -1 + x.r + x.d 
>inla.model = inla(formula, family = c("coxph", "coxph"),
                 data = data.f)


Thank you!



Finn Lindgren

unread,
Jul 12, 2024, 5:10:15 PM (9 days ago) Jul 12
to Aria, R-inla discussion group
Hi,

from what I can see, the old inla.coxph() function that is used
internally to setup the coxph model doesn't properly support being
part of multi-family models.
In fact, it always returns a single 'family="possion"' model, so
inherently cannot cope with being a part of a more complex model.
It would probably require a rewrite of that code to make that model
work in a more general context.

Finn
> --
> You received this message because you are subscribed to the Google Groups "R-inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to r-inla-discussion...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/ab2fdcce-c9ae-4546-9727-713345d14de6n%40googlegroups.com.



--
Finn Lindgren
email: finn.l...@gmail.com

Janet Van Niekerk

unread,
Jul 13, 2024, 3:02:10 AM (9 days ago) Jul 13
to Finn Lindgren, Aria, R-inla discussion group

Aria

unread,
Jul 15, 2024, 10:33:03 AM (6 days ago) Jul 15
to R-inla discussion group
Hi Finn, thank you for your reply.
Reply all
Reply to author
Forward
0 new messages