inla error with bym2 model with nbinomial family

15 views
Skip to first unread message

Aminath Shausan

unread,
Oct 7, 2025, 11:11:06 PM (6 days ago) Oct 7
to R-inla discussion group
Dear all, 
I am trying to fit a spatiotemporal model with bym2 prior and a negative binomial and poisson family for observed data. I am getting the following warning/error when using family = 'nbinomial', while the family = 'poisson' model works fine. Could you please help. 

Thank you
===================================
warning  msg: 
sh: line 1: 66988 Segmentation fault: 11  '/Users/.../.../.../r-libraries/INLA/bin/mac.arm64/inla.run' -s -v -t12:1 -P compact '/var/folders/z0/9tsk9q0x0pl8g491mdfsck5h0000gp/T//Rtmp1Tt3hr/file3fa9f144b/Model.ini' > '/var/folders/z0/9tsk9q0x0pl8g491mdfsck5h0000gp/T//Rtmp1Tt3hr/file3fa9f144b/Logfile.txt'

 *** inla.core.safe:  The inla program failed, but will rerun in case better initial values may help. try=1/1 

 *** inla.core.safe:  rerun with improved initial values


***[10] warning *** iterative process seems to diverge, 'vb.correction' is aborted
*** Please (re-)consider your model, priors, confounding, etc.
There are many such warnings
.
===================================
Note: 

Here is my code
precision.prior <- list(prec = list(prior = "pc.prec", param = c(0.5, 0.01)))

baseformula <- obs ~ 1 + holiday + f(week, replicate = ID_region, model = "rw1", cyclic = TRUE, constr = TRUE, scale.model = TRUE,  hyper = precision.prior) +
   f(ID_region2, model = "bym2", replicate = ID_year, graph = map.graph,,
    hyper = precision.prior, scale.model = TRUE)  

# test baseline model with Poisson and Negative Binomial distributions
model <- inla(formula = baseformula, data = df_train, family = 'nbinomial', E = 1,
              control.inla = list(strategy = 'adaptive'), 
              control.compute = list(dic = TRUE, waic=TRUE, config = FALSE,
                                     cpo = TRUE, return.marginals = FALSE),
              control.fixed = list(correlation.matrix = TRUE,
                                   prec.intercept = 1, prec = 1),
              control.predictor = list(link = 1, compute = TRUE),
              verbose = FALSE)

Note
1. I have tried adding the following to inla() function with initial = -1 OR -2,, but I am still getting the same error. 
# control.family = list(hyper = list(size = list(initial = -1))), ## ADD for nbinomial
2. When I run the model again, sometimes I don't get the warnings and posterior summary is OK.

Helpdesk (Haavard Rue)

unread,
Oct 8, 2025, 1:22:24 AM (6 days ago) Oct 8
to Aminath Shausan, R-inla discussion group
Hi

you do not provide information about R-version and INLA version, so I guess
you're on R-4.5 and the most recent testing version for INLA

Note that family='nbinomial' is essentially family='poisson' + iid effect pr
observation. so

y ~ f(bym2) with family='poisson'

is essentially

y ~ f(besag) with family='nbinomial'

since the bym2 contains the iid effect.

so doing 'nbinomial' for the bym2 is creating a confounding issue that is no
good...

however, it should not crash. If possible, could you share data/code to help@...
and I can rerun and check it here?

thx
best
Havard
> --
> 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/d7b962d1-a856-4dde-9984-7107bab4ec24n%40googlegroups.com
> .

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

Aminath Shausan

unread,
Oct 12, 2025, 7:51:11 PM (23 hours ago) Oct 12
to R-inla discussion group
Dear Professor, 

Thank you for your prompt reply. 
I have shared my code and data with he...@r-inla.org.  Please let me know if there is any problem accessing them. 

I am using : 
R version = 4.5.1 (2025-06-13)
INLA version = INLA_25.06.07 built 2025-06-11

Thank you

Reply all
Reply to author
Forward
0 new messages