Error when adding splines to different models

13 views
Skip to first unread message

Aria

unread,
Jul 10, 2024, 3:53:20 PM (11 days ago) Jul 10
to R-inla discussion group
Hello,

I'm trying to add splines to two different models. Here is a simple example for my question:

d1 <- rnorm(30)
d2 <- rpois(30, 10)
d <- matrix(NA, ncol = 2, nrow = 30 + 30)
d[1:30, 1] <- d1
d[31:60, 2] <- d2
time1 <- c(1:30, rep(NA, 30))
time2 <- c(rep(NA, 30), 1:30)
mult.lik <- inla(Y ~ -1 + bs(t1) + bs(t2),
                 data = list(Y = d, t1 = time1, t2 = time2),
                 family = c("gaussian", "poisson"))

time1 and time2 are identical, but they are supposed to add to the Gaussian and Poisson models, respectively. But I got an error:

 *** Key [1] is used twice and that is not allowed.
 *** A typical example where this happens is: y ~ x + f(x)
 *** Change this formula into: y ~ x + f(x2)
 *** where you define x2=x

Any help would be greatly appreciated!


Helpdesk (Haavard Rue)

unread,
Jul 11, 2024, 5:57:41 AM (11 days ago) Jul 11
to Aria, R-inla discussion group
the normal way of using splines is by using model="rw2"
> --
> 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/5bb9b5db-1be0-40ef-9514-8388d55bb72cn%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org

Aria

unread,
Jul 11, 2024, 9:17:38 AM (10 days ago) Jul 11
to R-inla discussion group
Thank you very much for your help!
Reply all
Reply to author
Forward
0 new messages