IINLA-SPDE error

115 views
Skip to first unread message

Prince Michael Amegbor

unread,
Dec 13, 2022, 7:13:23 PM12/13/22
to R-inla discussion group
Hello,

I was catching up on an old work and I just realised my script which worked on previous INLA version now gives me an error. Please find the error below

f1 <- y ~ 1 + Age + Sex + Edu + Emp + Inc + Veh + Occ +  HH_INF +
  HH_CH + HH_ADL + out + f(s, model = spde) 

stk.dat1 <- inla.stack(
  data = list(y = SPDF$MNH, numtrials = 1),
  A = list(A,1),
  effects = list(list(s = 1:spde$n.spde),
                 data.frame(Intercept = 1, ID = SPDF$ID,
                            Age = factor(SPDF$Age),Sex = factor(SPDF$Sex),
                            Edu = factor(SPDF$EDU),Emp = factor(SPDF$EMP),
                            Inc = factor(SPDF$INC),Veh = factor(SPDF$CAR),
                            Occ = factor(SPDF$OCC),HH_INF = factor(SPDF$HH_INF),
                            HH_CH = factor(SPDF$HH_CH),HH_ADL = factor(SPDF$HH_ADL),
                            out = SPDF$out)), tag = 'dat.mnh')

mod1 <- inla(f1, family = "binomial", Ntrials = 1,
control.family = list(link = "logit"), control.compute = list(dic=TRUE, waic=TRUE),
data = inla.stack.data(stk.dat1),verbose=TRUE,
control.inla=list(strategy="adaptive", int.strategy="eb"),
control.predictor = list(
compute = TRUE, link = 1,
A = inla.stack.A(stk.dat1)))


Error in if (...length() && any(...names() == "Dimnames")) .Object@Dimnames <- fixupDN(.Object@Dimnames) :
  missing value where TRUE/FALSE needed

 *** inla.core.safe:  inla.program has crashed: rerun to get better initial values. try=1/2
Error in if (...length() && any(...names() == "Dimnames")) .Object@Dimnames <- fixupDN(.Object@Dimnames) :
  missing value where TRUE/FALSE needed

 *** inla.core.safe:  inla.program has crashed: rerun to get better initial values. try=2/2
Error in if (...length() && any(...names() == "Dimnames")) .Object@Dimnames <- fixupDN(.Object@Dimnames) :
  missing value where TRUE/FALSE needed
Error in inla.core.safe(formula = formula, family = family, contrasts = contrasts,  :
  *** Fail to get good enough initial values. Maybe it is due to something else.

Finn Lindgren

unread,
Dec 13, 2022, 7:26:17 PM12/13/22
to Prince Michael Amegbor, R-inla discussion group
Necessary info:
R version
INLA version
Matrix version
traceback() output after the first line of your code that generates an error.
(get the versions from sessionInfo(), for example)

The error message seems to come from some internal function in the
Matrix package (since "fixupDN" is a non-exported function in the
Matrix package).
There were recent changes in Matrix that necessitated some changes in
INLA as well, so make sure you have the latest Matrix version (1.5-3)

Finn
> --
> 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 on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/ea012950-c853-45ba-8067-175f6102bfc0n%40googlegroups.com.



--
Finn Lindgren
email: finn.l...@gmail.com

Prince Michael Amegbor

unread,
Dec 13, 2022, 7:32:04 PM12/13/22
to R-inla discussion group
Thanks Finn.

From the sessionInfo, it seems I have the latest version of Matrix. Please find the versions info and traceback below:

R version 4.1.2 (2021-11-01)
INLA_22.12.03
Matrix_1.5-3


traceback
top("*** Fail to get good enough initial values. Maybe it is due to something else.")
2: inla.core.safe(formula = formula, family = family, contrasts = contrasts,
       data = data, quantiles = quantiles, E = E, offset = offset,
       scale = scale, weights = weights, Ntrials = Ntrials, strata = strata,
       lp.scale = lp.scale, link.covariates = link.covariates, verbose = verbose,
       lincomb = lincomb, selection = selection, control.compute = control.compute,
       control.predictor = control.predictor, control.family = control.family,
       control.inla = control.inla, control.fixed = control.fixed,
       control.mode = control.mode, control.expert = control.expert,
       control.hazard = control.hazard, control.lincomb = control.lincomb,
       control.update = control.update, control.lp.scale = control.lp.scale,
       control.pardiso = control.pardiso, only.hyperparam = only.hyperparam,
       inla.call = inla.call, inla.arg = inla.arg, num.threads = num.threads,
       blas.num.threads = blas.num.threads, keep = keep, working.directory = working.directory,
       silent = silent, inla.mode = inla.mode, safe = FALSE, debug = debug,
       .parent.frame = .parent.frame)
1: inla(f1, family = "binomial", Ntrials = 1, control.family = list(link = "logit"),
       control.compute = list(dic = TRUE, waic = TRUE), data = inla.stack.data(stk.dat1),
       verbose = TRUE, control.inla = list(strategy = "adaptive",
           int.strategy = "eb"), control.predictor = list(compute = TRUE,
           link = 1, A = inla.stack.A(stk.dat1)))

Thank you

Finn Lindgren

unread,
Dec 13, 2022, 7:39:07 PM12/13/22
to Prince Michael Amegbor, R-inla discussion group
Hmmm, the inla.safe system makes it harder to debug.
Can you verify if the calls
thedata <- inla.stack.data(stk.dat1)
and
thedata <- inla.stack.A(stk.dat1)
run without error?
Those are the only outside calls, so are easier to check.

Finn

On Wed, 14 Dec 2022 at 00:32, Prince Michael Amegbor
> To view this discussion on the web, visit https://groups.google.com/d/msgid/r-inla-discussion-group/f1b31ecb-7156-4fc6-8e70-076a540cfe5fn%40googlegroups.com.

Prince Michael Amegbor

unread,
Dec 13, 2022, 7:42:11 PM12/13/22
to R-inla discussion group
Yes, there are no errors for the two: 

thedata <- inla.stack.data(stk.dat1)
and
thedata <- inla.stack.A(stk.dat1)



Prince Michael Amegbor

unread,
Dec 13, 2022, 8:20:00 PM12/13/22
to R-inla discussion group
I just tried the same data and script on my old work computer and it works. The sessionInfo details are: 

R version 4.2.2 Patched (2022-11-10 r83330)
INLA_22.05.18-2
Matrix_1.5-1 


On Tuesday, December 13, 2022 at 7:39:07 PM UTC-5 finn.l...@gmail.com wrote:

Prince Michael Amegbor

unread,
Dec 16, 2022, 12:10:29 PM12/16/22
to R-inla discussion group
Hello, Finn.

It works now after upgrading my R to the latest version 4.2.2

Previously, I was using R version  4.1.2 with the latest INLA testing version - INLA_22.12.03 . Thank you.

On Tuesday, December 13, 2022 at 7:39:07 PM UTC-5 finn.l...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages