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!