The inla program failed and the maximum number of tries has been reached.

23 views
Skip to first unread message

yasaman shahhoseni

unread,
Aug 19, 2025, 2:53:19 PMAug 19
to R-inla discussion group

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:

install.packages("INLA", repos="https://inla.r-inla-download.org/R/testing")
# Test basic INLA functionality
library(INLA)
inla.version()
R-INLA version ..........: 25.06.22-1
Date ....................: 2025-06-22
Maintainers .............: Havard Rue <hr...@r-inla.org>
                         : Finn Lindgren <finn.l...@gmail.com>
                         : Elias Teixeira Krainski <el...@r-inla.org>
Main web-page ...........: www.r-inla.org
Download-page ...........: inla.r-inla-download.org
Repository ..............: github.com/hrue/r-inla
Email support ...........: he...@r-inla.org
                         : r-inla-disc...@googlegroups.com
setwd("~/Downloads")
getwd()
INLA::inla.setOption("pardiso.license", "panua.lic")

inla.pardiso.check()
[1] "SUCCESS: PARDISO IS INSTALLED AND WORKING"

# Now try set solver pardiso
inla.setOption(smtp = "pardiso")

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
   
  
   
 

INLA help

unread,
Aug 19, 2025, 3:33:26 PMAug 19
to R-inla discussion group, yasaman shahhoseni
Could you share so we can rerun it here to check?

Haavard Rue
HelpDesk 
help@r-inla. org
--
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, visit https://groups.google.com/d/msgid/r-inla-discussion-group/6eb7aa07-2a73-4531-9a41-0805a99fa0cbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages