Hello,
I’ve been running an INLA model with the code and settings below, but I keep getting an error even when I change the initial values for the hyperparameters. I’d really appreciate any help or insights you could share to solve this issue. Both error and the codes are mentioned below.
Btw, is there a way to make INLA give NULL for misc, because it is so heavy and most of the times it gives me memory error and inla function fails due to memory issues.
Best,
Yasaman
The error
Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts, :
The inla-program exited with an error. Unless you interupted it yourself, please rerun with verbose=TRUE and check the output carefully.
If this does not help, please contact the developers at <
he...@r-inla.org>.
The inla program failed and the maximum number of tries has been reached.
The code and settings:
here is the code:
spatial <- mesh$idx$loc
nmesh <- length(spatial)
aalpha <- c(rep(1:Time, N), rep(NA, 5*nmesh))
repli <- c(rep(spatial, each = Time), rep(NA, 5*nmesh))
bbeta0 <- c(rep(NA, ntot), spatial, rep(NA, 4 * nmesh)) # Intercept field
bbeta1 <- c(rep(NA, ntot), rep(NA, 1 * nmesh), spatial, rep(NA, 3 * nmesh)) # 1st regressor
bbeta2 <- c(rep(NA, ntot), rep(NA, 2 * nmesh), spatial, rep(NA, 2 * nmesh)) # 2nd regressor
bbeta3 <- c(rep(NA, ntot), rep(NA, 3 * nmesh), spatial, rep(NA, 1 * nmesh)) # 3rd regressor
bbeta4 <- c(rep(NA, ntot), rep(NA, 4 * nmesh), spatial)
BOLD <- list(y=y, aalpha=aalpha, bbeta0=bbeta0, bbeta1=bbeta1, bbeta2=bbeta2,bbeta3=bbeta3,bbeta4=bbeta4)
formula = y ~ -1 + f(aalpha, model='ar1', replicate=repli, compute = FALSE) +
f(bbeta0, model=spde) + f(bbeta1, model=spde) +
f(bbeta2, model=spde) +
f(bbeta3, model=spde) +
f(bbeta4, model=spde)
inla.setOption("num.threads", 2)
setup_time <- as.numeric(difftime(Sys.time(), bayesian_setup_start, units="mins"))
cat(sprintf("Bayesian setup completed in %.2f minutes\n", setup_time))
#different computation strategy
#k <- 1 #ccd only
for(k in 1:2){
print(k)
if(k==1) strategy <- 'ccd'
cat("\n=== BAYESIAN INLA-CCD ===\n")
if(k==2) strategy <- 'eb' #46 minutes
cat("\n=== BAYESIAN INLA-EB ===\n")
# TIME THE INLA COMPUTATION
inla_start <- Sys.time()
cat(sprintf("Starting INLA with %s strategy...\n", toupper(strategy)))
proj <- inla.mesh.projector(mesh, dims=c(nx,ny), xlim=c(1,nx), ylim=c(1,ny))
#25 minutes for CCD, 11 min with iid errors (with initial error precision = 1)
#20 minutes for EB, 9 min with iid errors (with initial error precision = 1)
t0 <- Sys.time()
result <- inla(formula, data=BOLD, family='gaussian',
control.family=list(hyper=list(prec=list(initial=10,fixed=TRUE))),
control.predictor=list(A=A),
control.compute = list(config = TRUE, return.marginals.predictor = FALSE,
return.marginals.random = FALSE,
return.marginals.hyperpar = FALSE,
return.summary.linear.predictor=FALSE,
return.summary.fitted.values=FALSE,
return.model.matrix=FALSE,
mlik = FALSE,
cpo = FALSE,
dic = FALSE,waic = FALSE),
control.inla = list(strategy = "gaussian", int.strategy = strategy),
verbose=TRUE, keep=FALSE)
print("INLA function finished")
result$misc <- NULL