INLA crash when fitting the MCAR model .

172 views
Skip to first unread message

Barry Thierno Souleymane

unread,
Dec 4, 2021, 5:20:06 AM12/4/21
to R-inla discussion group
Hello,

I am fitting a MCAR model for two binary outcomes from my data. The model run  but INLA crashes when fitting the MCAR model on the data.  There is window that appears and the message is " Fatal error: unable to initialize the JIT"

Error in inla.inlaprogram.has.crashed() :
  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>.

Please,  anyone experienced in such kind of issue? How can I solve it?  

There are below  the codes I have used:

library(sf)
library(sp)
library(maptools)
# loads sp library
library(maps)

# read in shape files (single folder with all associated files, no

x<-st_read("C:\\Users\\Alexis H\\Downloads\\gin_admbnda_ocha_fis\\gin_admbnda_adm1_ocha.shp")
str(x)
# display the shapefile
plot(x)
str(x)
library("spdep")

#Compute sparse adjacency matrix

Guineaadj <- poly2nb(x, queen = FALSE)

Guinea.adj <-nb2mat(Guineaadj, style = "B")

Guinea.adj <- as(Guinea.adj, "dgTMatrix")

# joint model
#devtools::install_github("becarioprecario/INLAMSM")
install.packages('INLAMSM')
library(INLA)
library(INLAMSM)
require(spdep)
require(spData)
require(rgdal)

# Proper MCAR model
#Data


dta <- data.frame(Y12 =c(Final_data$Outcome, Final_data$Outcome2), E=c(Final_data$Age, Final_data$Age),
                   E=c(Final_data$Gender, Final_data$Gender))

dta$Var1 <- c(rep(1,length(Final_data$Outcome)),rep(2,length(Final_data$Outcome)))

k=2 #number of diseases

# Range of autocorrelation parameter

alpha.min <- 0 #Minimum value of the spatial autocorrelation parameter.
alpha.max <- 1 #Maximum value of the spatial autocorrelation parameter.

#Define MCAR model

model.mcar <- inla.MCAR.model(k = k, W = Guinea.adj, alpha.min = alpha.min,alpha.max = alpha.max)

MCAR <- inla(Y12 ~ 0+f(Var1, model = model.mcar), data = dta,
              control.compute = list(waic=T,cpo = T, dic = T), # compute DIC, CPO
              family ="binomial",
              Ntrials = 1, #marginal distribution for the outcome, expected count,
              control.predictor = list(compute = TRUE),verbose=TRUE)

#total model summary
summary(MCAR)


Helpdesk

unread,
Dec 4, 2021, 6:30:22 AM12/4/21
to Barry Thierno Souleymane, R-inla discussion group
I think this is a case where you're using R-4.0 and the package is
compiled for R-4.1. If that is the case, please upgrade to R-4.1
> --
> 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/fcba306d-1b2c-4647-bdcd-10a4cd723c88n%40googlegroups.com
> .

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

Barry Thierno Souleymane

unread,
Dec 4, 2021, 6:59:26 AM12/4/21
to Helpdesk, R-inla discussion group
Thanks, but I am using R 4.1.1

INLA help

unread,
Dec 4, 2021, 7:02:18 AM12/4/21
to Barry Thierno Souleymane, R-inla discussion group
Upgrade the packages?

Haavard Rue
HelpDesk 
help@r-inla. org

Barry Thierno Souleymane

unread,
Dec 4, 2021, 7:49:12 AM12/4/21
to INLA help, R-inla discussion group
Yes

Barry Thierno Souleymane

unread,
Dec 6, 2021, 8:52:38 AM12/6/21
to INLA help, R-inla discussion group
Hello,
Thank you for your quick response.
I updated my R to the version (R 4.1.2) you advised me to. I tried executing my codes but it could not work. 
I am humbly requesting you if I can share with you my codes to please run it in your computer to see if the problem is about my INLA.

Thank you

INLA help

unread,
Dec 6, 2021, 9:06:27 AM12/6/21
to Barry Thierno Souleymane, R-inla discussion group
Please do share 

Haavard Rue
HelpDesk 
help@r-inla. org

Barry Thierno Souleymane

unread,
Dec 6, 2021, 9:21:15 AM12/6/21
to INLA help, R-inla discussion group

Thank you, 
Below are R codes and attached the zipped folder in which we have the shapefile named "gin_admbnda_adm1_ocha.shp"

# dependent variable 1
rm(list=ls())
memory.limit()
memory.limit(size= 1000000)

prop <- c(0.3,0.5,0.6,0.7,0.8,0.3,0.3,0.2)
for(i in 1:8)
{
  data  <- replicate(200,{
    sample<- rbinom(8,1,prop[i]) })
   
}

# dependent variable 2
prop <- c(0.4,0.5,0.6,0.5,0.7,0.5,0.3,0.6)
for(i in 1:8)
{
  data2  <- replicate(200,{
    sample<- rbinom(8,1,prop[i]) })
 
}



library(INLA)

# independent variables

mu <- c(43,40,46,50,53,54,46,49)
std <- c(2.3,2.4,2.1,2.5,2.7,2.9,2.0,2.1)

for(i in 1:8)
{
  age <- replicate(200,
                   {
                     samplew <- round(rnorm(8,mu[i],std[i]),0)
                   })
}

# gender

gender  <- replicate(200,{
  sample<- rbinom(8,1,0.5) })

library(reshape2)

# cleaned format

Age_child <- melt(age, value.name = "Age")

Y <- melt(data,value.name = "Outcome" )

Gender_child <- melt(gender, value.name = "Gender")

Y2 <- melt(data2,value.name = "Outcome2" )

# joining

library(dplyr)

Merged_data <- inner_join(Y,Age_child, by = c("Var1","Var2"))

Merged_data1 <- inner_join(Merged_data, Gender_child,by = c("Var1","Var2"))
Merged_data2 <- inner_join(Merged_data1, Y2, by = c("Var1","Var2"))

# variables of interest

Final_data <- select(Merged_data2, Outcome,Outcome2, Age, Var1, Gender)
head(Final_data)

library(sf)
library(sp)
library(maptools)
# loads sp library
library(maps)

# read in shape files 

x<-st_read("...................................\\gin_admbnda_ocha_fis\\gin_admbnda_adm1_ocha.shp")

library("spdep")

#Compute sparse adjacency matrix

Guineaadj <- poly2nb(x, queen = FALSE)

Guinea.adj <-nb2mat(Guineaadj, style = "B")

Guinea.adj <- as(Guinea.adj, "dgTMatrix")

# joint model
#devtools::install_github("becarioprecario/INLAMSM")
##install.packages('INLAMSM')
library(INLA)
library(INLAMSM)


# Proper MCAR model

#Data


dta <- data.frame(Y12 =c(Final_data$Outcome, Final_data$Outcome2), E=c(Final_data$Age, Final_data$ Gender ))

dta$Var1 <- c(rep(1,length(Final_data$Outcome)),rep(2,length(Final_data$Outcome)))

k=2 #number of diseases

# Range of autocorrelation parameter

alpha.min <- 0 #Minimum value of the spatial autocorrelation parameter.
alpha.max <- 1 #Maximum value of the spatial autocorrelation parameter.

#Define MCAR model

model.mcar <- inla.MCAR.model(k = k, W = Guinea.adj, alpha.min = alpha.min,alpha.max = alpha.max)

MCAR <- inla(Y12 ~ E+f(Var1, model = model.mcar), data = dta,
gin_admbnda_ocha_fis.zip

Helpdesk

unread,
Dec 6, 2021, 1:44:37 PM12/6/21
to Barry Thierno Souleymane, R-inla discussion group
it run fine here.

you can try setting

library(INLA)
inla.setOption(inla.mode="experimental")


but it also runs fine without


Wall-clock time used on [/tmp/RtmpGIX2Mb/file686eb1b81edc5/Model.ini]
Preparations : 1.157 seconds
Approx inference (stage1): 2.588 seconds
Approx inference (stage2): 0.000 seconds
Approx inference (total) : 2.588 seconds
Output : 0.041 seconds
------------------------------------------
Total : 3.786 seconds
--
Håvard Rue
he...@r-inla.org

Virgilio Gómez-Rubio

unread,
Dec 6, 2021, 2:07:00 PM12/6/21
to Barry Thierno Souleymane, INLA help, R-inla discussion group
Hi,

I am the developer of the INLAMSM package. I have been able to run your code without any problem. My guess is that there is an “issue” with your installation of R. Please, try to run the example of the MCAR model:

example("inla.MCAR.model”)

It should run fine. If you encounter the same problem, then most likely you should try to update all packages or get you a fresh R installation. Also, please try to install the latest version form GitHub:

devtools::install_github("becarioprecario/INLAMSM”)

The CRAN version has been archived and we need to update it now that rgeneric works smoothly with the latest R version. The checks on CRAN failed exactly with the error that you have reported.

I have posted below my sessionIfo() in case it helps.

Best,

Virgilio



> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] dplyr_1.0.7 reshape2_1.4.4 rgdal_1.5-27 INLA_21.02.23 foreach_1.5.1
[6] maps_3.4.0 maptools_1.1-2 INLAMSM_0.2-3 spdep_1.1-12 sf_1.0-3
[11] spData_2.0.1 sp_1.4-6 MCMCpack_1.6-0 MASS_7.3-54 coda_0.19-4
[16] Matrix_1.3-4


Barry Thierno Souleymane

unread,
Dec 6, 2021, 2:47:48 PM12/6/21
to Helpdesk, R-inla discussion group
Thank you,
Please share with me those results in private. I need them please.

Barry Thierno Souleymane

unread,
Dec 6, 2021, 2:51:02 PM12/6/21
to Virgilio Gómez-Rubio, INLA help, R-inla discussion group
Hello Dear Virgilio,
Thank you for your response 
Reply all
Reply to author
Forward
0 new messages