Dear INLA users,
I am trying to fit an additive regression model (using the reproducible example below)
y_i ~ Poisson(mu_i), where mu_i = exp(alpha), alpha = {f1(x1) + f2(x2) + f3(x3)}/6
but gets the following error
Error in inla.check.location(location[[r]], term = gp$random.spec[[r]]$term, :
Locations are too close for f(x1, model="rw2", ...): min(diff(sort(x)))/diff(range(x)) = 7.453e-09 < 1e-03
You can fix this by some kind of binning, see ?inla.group
If you want/need to bypass this check at your own risk, do
> m = get("inla.models", INLA:::inla.get.inlaEnv())
> m$latent$rw2$min.diff = NULL
> assign("inla.models", m, INLA:::inla.get.inlaEnv())
The same error occurs also for exponential and binary distributions, and also if I try any of the predictors x1, x2 or x3. I've tried the code anyway by bypassing the check, it kept running all night long and I had to stop it after 10 hours (such simple models and sizes of data shouldn't take so long). Any idea whether it is a bug or numerical instabilities came into play?
PS: other libraries were able to fit the same models and data.
Many thanks!
Reproducible example
library(INLA)
## smooth functions
f1 <- function(x){ return(0.2 * x^11 * (10 * (1 - x))^6 + 10 * (10 * x)^3 * (1 - x)^10) }
f2 <- function(x){ return(2 * sin(pi * x)) }
f3 <- function(x){ return(exp(2*x)) }
n <- 1e+04
x1 <- runif(n)
x2 <- runif(n)
x3 <- runif(n)
dat <- data.frame(x1, x2, x3)
mu <- exp( (f1(dat$x1) + f2(dat$x2) + f3(dat$x3))/6)
dat$y <- rpois(n, mu)
#dat$y <- rexp(n, mu)
#mu <- binomial()$linkinv( (f1(dat$x1) + f2(dat$x2) + f3(dat$x3) -5)/6)
#dat$y <- rbinom(n, 1, mu)
fINLA <- inla( y ~ f(x1, model="rw2") + f(x2, model="rw2") + f(x3, model="rw2"),
data=dat,
verbose=FALSE,
family="poisson",
#family="exponential",
#family="binomial", Ntrials=n,
num.threads=4,
control.predictor=list(compute=TRUE),
control.compute = list(config=TRUE)
)