Error in if (n.from.graph <= 0) { : missing value where TRUE/FALSE needed : In inla.read.graph.ascii.internal(..., size.only = size.only) : NAs introduced by coercion

468 views
Skip to first unread message

guna...@umn.edu

unread,
Apr 23, 2021, 10:44:00 AM4/23/21
to R-inla discussion group
Hi,
I am trying to incorporate an adjacency matrix I created based on phylogenetic distance in to an INLA spatial model, I used the below code  for  BYM model,

 H<inla.read.graph(filename="adjlist_mya98_3.txt",size.only = FALSE)
summary(H)

datas<-read.csv("SIRpig_spatial.csv")
all.outs <- sum(datas$outbreaknumber)
all.pop <- sum(datas$totpigpop)
datas$exp.new <-datas$totpigpop*(all.outs/all.pop)


formula<-outbreaknumber~1+f(ID,model="bym",graph="H",
      scale.model = TRUE,
      hyper=list(prec.unstruct=
                   list(prior="loggamma",param=c(1,0.001)),
                 prec.spatial=list(
                   prior="loggamma",param=c(1,0.001))))

mod.Mya98<-inla(formula,family="poisson",
                data=datas,
                E=exp.new,
                control.predictor = list(compute = TRUE),
                control.compute = list(dic=TRUE),verbose=T)

 when I do that, I get the error message, 
Error in if (n.from.graph <= 0) { : missing value where TRUE/FALSE needed
In addition: Warning message:
In inla.read.graph.ascii.internal(..., size.only = size.only) :
  NAs introduced by coercion

I used the same IDs in creating the adjacency matrix and the csv file(attached). I can't find what is missing, Can anyone please let me know what is wrong?

Thanks
Umanga



adjlist_mya98_3.txt
SIRpig_spatial.csv

Helpdesk

unread,
Apr 23, 2021, 10:49:08 AM4/23/21
to guna...@umn.edu, R-inla discussion group

try with

graph=H

instead of

graph="H"



On Fri, 2021-04-23 at 07:44 -0700, 'guna...@umn.edu' via R-inla
> --
> 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/cf9a1264-73f1-4ecb-96b7-c2c595dbbc30n%40googlegroups.com
> .

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

guna...@umn.edu

unread,
Apr 23, 2021, 10:54:41 AM4/23/21
to R-inla discussion group
Hi,

I tried both ways, but it did not work,

Helpdesk

unread,
Apr 24, 2021, 6:46:51 AM4/24/21
to guna...@umn.edu, R-inla discussion group
you have

H<inla.read.graph(filename="adjlist_mya98_3.txt",size.only = FALSE)

but it should be

H <- inla.read.graph(filename="adjlist_mya98_3.txt",size.only = FALSE)


and then you need

formula<-outbreaknumber~1+f(ID,model="bym",graph=H,

without the ""'s


On Fri, 2021-04-23 at 07:54 -0700, 'guna...@umn.edu' via R-inla

guna...@umn.edu

unread,
Apr 24, 2021, 8:33:49 AM4/24/21
to R-inla discussion group
Hi,
I apologize for not writing it correctly it is <- in my original R file, when I was copying and pasting here, I lost a part of the arrow,  and yes I have tried without " ", but it will still produce same errors,
Since errors are related to "NA" s I tried again using comma delimited txt to crate adjacency matrix file to make sure there is no extra space, but it still did not work, 
I think it is something to do with my adjacency matrix , because I have used the same csv file with a different adjacency matrix and it worked!
I also thought whether it would make any difference if I make my adjacency matrix as a matrix instead of graph file,
Please let me know what you think 

Thanks
Umanga

Helpdesk

unread,
Apr 24, 2021, 8:44:12 AM4/24/21
to guna...@umn.edu, R-inla discussion group

you can also try with

g=inla.debug.graph(H)

which reads the graph from 'H', if its a file, or matrix, but output
some debug info. maybe this will help


On Sat, 2021-04-24 at 05:33 -0700, 'guna...@umn.edu' via R-inla

guna...@umn.edu

unread,
Apr 24, 2021, 9:18:46 AM4/24/21
to R-inla discussion group
Hi,
When I try to run that, it says, 
Error in inla.debug.graph("H") : file.exists(graph.file) is not TRUE

guna...@umn.edu

unread,
Apr 24, 2021, 9:41:20 AM4/24/21
to R-inla discussion group
I was able to run inla.debug.graph  and it gave me following message, but no errors were found, 
I am not sure what it means, 
Warning message:
In system(paste(shQuote(inla.call.builtin()), "-s -m graph", shQuote(graph.file)),  :
  running command '"C:/Users/DefaultUser/Documents/R/win-library/3.6/INLA/bin/windows/64bit/inla.exe" -s -m graph "Mya98_adj.txt"' had status 3

Helpdesk

unread,
Apr 24, 2021, 9:43:19 AM4/24/21
to guna...@umn.edu, R-inla discussion group

can you upgrade to R-4.0, reinstall INLA (which will be a newer
version), and retry ??

On Sat, 2021-04-24 at 06:41 -0700, 'guna...@umn.edu' via R-inla

guna...@umn.edu

unread,
Apr 24, 2021, 10:11:55 AM4/24/21
to R-inla discussion group
I upgraded R and reinstalled INLA, but I get the same error message

Helpdesk

unread,
Apr 24, 2021, 12:43:01 PM4/24/21
to guna...@umn.edu, R-inla discussion group

doing

> g <- inla.debug.graph("adjlist_mya98_3.txt")


I get a lot of errors. I had to cut the output.

* File [adjlist_mya98_3.txt] consists of 65 lines.
* Number of lines left after removing empty lines: 64
* Size of the graph is N= 63
* Read line 2 ...node = 1 number.of.neigbours= 6 ok
* Read line 3 ...node = 2 number.of.neigbours= 6 ok
* Read line 4 ...node = 3 number.of.neigbours= 25 ok
* Read line 5 ...node = 4 number.of.neigbours= 25 ok
* Read line 6 ...node = 5 number.of.neigbours= 44 ok
* Read line 7 ...node = 6 number.of.neigbours= 6 ok
* Read line 8 ...node = 7 number.of.neigbours= 10 ok
* Read line 9 ...node = 8 number.of.neigbours= 18 ok
* Read line 10 ...node = 9 number.of.neigbours= 10 ok
* Read line 11 ...node = 10 number.of.neigbours= 10 ok
* Read line 12 ...node = 11 number.of.neigbours= 18 ok
* Read line 13 ...node = 12 number.of.neigbours= 6 ok
* Read line 14 ...node = 13 number.of.neigbours= 6 ok
* Read line 15 ...node = 14 number.of.neigbours= 25 ok
* Read line 16 ...node = 15 number.of.neigbours= 8 ok
* Read line 17 ...node = 16 number.of.neigbours= 8 ok
* Read line 18 ...node = 17 number.of.neigbours= 10 ok
* Read line 19 ...node = 18 number.of.neigbours= 6 ok
* Read line 20 ...node = 19 number.of.neigbours= 18 ok
* Read line 21 ...node = 20 number.of.neigbours= 57 ok
* Read line 22 ...node = 21 number.of.neigbours= 8 ok
* Read line 23 ...node = 22 number.of.neigbours= 44 ok
* Read line 24 ...node = 23 number.of.neigbours= 44 ok
* Read line 25 ...node = 24 number.of.neigbours= 6 ok
* Read line 26 ...node = 25 number.of.neigbours= 10 ok
* Read line 27 ...node = 26 number.of.neigbours= 25 ok
* Read line 28 ...node = 27 number.of.neigbours= 44 ok
* Read line 29 ...node = 28 number.of.neigbours= 44 ok
* Read line 30 ...node = 29 number.of.neigbours= 13 ok
* Read line 31 ...node = 30 number.of.neigbours= 57 ok
* Read line 32 ...node = 31 number.of.neigbours= 44 ok
* Read line 33 ...node = 32 number.of.neigbours= 18 ok
* Read line 34 ...node = 33 number.of.neigbours= 6 ok
* Read line 35 ...node = 34 number.of.neigbours= 8 ok
* Read line 36 ...node = 35 number.of.neigbours= 25 ok
* Read line 37 ...node = 36 number.of.neigbours= 57 ok
* Read line 38 ...node = 37 number.of.neigbours= 8 ok
* Read line 39 ...node = 38 number.of.neigbours= 57 ok
* Read line 40 ...node = 39 number.of.neigbours= 6 ok
* Read line 41 ...node = 40 number.of.neigbours= 44 ok
* Read line 42 ...node = 41 number.of.neigbours= 13 ok
* Read line 43 ...node = 42 number.of.neigbours= 44 ok
* Read line 44 ...node = 43 number.of.neigbours= 18 ok
* Read line 45 ...node = 44 number.of.neigbours= 25 ok
* Read line 46 ...node = 45 number.of.neigbours= 18 ok
* Read line 47 ...node = 46 number.of.neigbours= 13 ok
* Read line 48 ...node = 47 number.of.neigbours= 18 ok
* Read line 49 ...node = 48 number.of.neigbours= 18 ok
* Read line 50 ...node = 49 number.of.neigbours= 25 ok
* Read line 51 ...node = 50 number.of.neigbours= 13 ok
* Read line 52 ...node = 51 number.of.neigbours= 6 ok
* Read line 53 ...node = 52 number.of.neigbours= 57 ok
* Read line 54 ...node = 53 number.of.neigbours= 10 ok
* Read line 55 ...node = 54 number.of.neigbours= 13 ok
* Read line 56 ...node = 55 number.of.neigbours= 44 ok
* Read line 57 ...node = 56 number.of.neigbours= 25 ok
* Read line 58 ...node = 57 number.of.neigbours= 13 ok
* Read line 59 ...node = 58 number.of.neigbours= 6 ok
* Read line 60 ...node = 59 number.of.neigbours= 6 ok
* Read line 61 ...node = 60 number.of.neigbours= 25 ok
* Read line 62 ...node = 61 number.of.neigbours= 6 ok
* Read line 63 ...node = 62 number.of.neigbours= 44 ok
* Read line 64 ...node = 63 number.of.neigbours= 57 ok


* I will now try to read the graph properly using inla.read.graph().
* If there are any errors in the following, then recall
* that the numbering for lines and nodes, are 0-based (and NOT 1-based)!


GMRFLib_graph_validate: error: node[2] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[49], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[53], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[56], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[45], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[40], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[28], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[16], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[52], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[8], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[24], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[9], but not
oposite


GMRFLib_graph_validate: error: node[2] has neighbor node[6], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[56], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[53], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[40], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[28], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[45], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[49], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[6], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[8], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[9], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[16], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[52], but not
oposite


GMRFLib_graph_validate: error: node[3] has neighbor node[24], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[14], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[15], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[20], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[33], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[36], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[40], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[28], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[49], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[45], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[53], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[56], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[47], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[18], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[31], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[7], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[10], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[46], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[42], but not
oposite


GMRFLib_graph_validate: error: node[4] has neighbor node[44], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[7] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[10] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[56], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[49], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[53], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[45], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[40], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[28], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[24], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[9], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[16], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[52], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[8], but not
oposite


GMRFLib_graph_validate: error: node[13] has neighbor node[6], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[18] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[14], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[15], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[20], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[33], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[36], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[12], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[11], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[5], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[17], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[23], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[56], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[28], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[53], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[40], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[45], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[49], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[2], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[13], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[43], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[48], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[55], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[59], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[3], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[25], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[34], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[42], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[44], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[46], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[7], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[10], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[18], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[31], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[47], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[52], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[24], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[16], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[6], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[8], but not
oposite


GMRFLib_graph_validate: error: node[19] has neighbor node[9], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[14], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[15], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[36], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[20], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[33], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[0], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[1], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[32], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[38], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[50], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[57], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[58], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[60], but not
oposite


GMRFLib_graph_validate: error: node[21] has neighbor node[5], but not
oposite



On Sat, 2021-04-24 at 07:11 -0700, 'guna...@umn.edu' via R-inla

guna...@umn.edu

unread,
Apr 24, 2021, 12:54:57 PM4/24/21
to R-inla discussion group
Oh ok, does that error means that some of the adjacent areas are connected but others are not?
ex: node[21] has neighbor node[60], but not oposite
meaning that INLA is expecting another connection that I did not input as a  neighbor of 21? 
Like I said, this adjacency matrix is based on phylogenetic distance and not spatial distance , so adjacent  areas are not  connected, if that is the problem, then I can make a different matrix that connect far and adjacent areas as well and try,  
Thanks 

Helpdesk

unread,
Apr 24, 2021, 1:01:02 PM4/24/21
to guna...@umn.edu, R-inla discussion group

with a graph with 3 nodes, then

3
1 2 2 3
2 2 1 3
3 2 1 2

is a fully connected valid graph. what you give is like

3
1 2 2 3
2 2 1 3
3 1 2


which says 1 has 3 as a neigb, but 3 says only 2 is a neig.

so the spesification needs to be symmetric.



On Sat, 2021-04-24 at 09:54 -0700, 'guna...@umn.edu' via R-inla
> > > > > > > On Sat, 2021-04-24 at 05:33 -0700, 'guna...@umn.edu' via R-

guna...@umn.edu

unread,
Apr 24, 2021, 1:08:27 PM4/24/21
to R-inla discussion group
Ok , Thanks a lot,   I think I understand what you are saying,  I should make a new adjacency matrix fulfilling the above criteria,

Thanks
Umanga

guna...@umn.edu

unread,
May 4, 2021, 3:31:54 PM5/4/21
to R-inla discussion group
Hi,

I have an additional question related to this, in the adjacency matrix, is it ok to have the same id more than once in the same raw?
ex 

3
1 2 2 3
2 2 1 3 3
3 2 1 2 1

Helpdesk

unread,
May 4, 2021, 4:54:31 PM5/4/21
to guna...@umn.edu, R-inla discussion group

no, that does not work. If the graph is correct, you can put 'newline'
where you want, but the graph below is not correct.

this one is

> inla.read.graph("3
1 2 2 3
2 2 1 3 3
2 1 2 ")
$n
[1] 3

$nnbs
[1] 2 2 2

$nbs
$nbs[[1]]
[1] 2 3

$nbs[[2]]
[1] 1 3

$nbs[[3]]
[1] 1 2


$cc
$cc$id
[1] 1 1 1

$cc$n
[1] 1

$cc$nodes
$cc$nodes[[1]]
[1] 1 2 3



attr(,"class")
[1] "inla.graph"
>




On Tue, 2021-05-04 at 12:31 -0700, 'guna...@umn.edu' via R-inla
> > > > > > > On Sat, 2021-04-24 at 06:41 -0700, 'guna...@umn.edu' via R-
Screenshot from 2021-05-04 23-51-59.png

guna...@umn.edu

unread,
May 4, 2021, 10:00:59 PM5/4/21
to R-inla discussion group
Thank you for reply, can you please explain what do you mean by a "new line"?
I am sorry but my previous example should be corrected as below;
(I forgot to change the total sum number in the second column) 

inla.read.graph("3
 1 2 2 3
 2 3 1 3 3
 3 3 1 2 1")
$n
[1] 3

$nnbs
[1] 2 3 3

$nbs
$nbs[[1]]
[1] 2 3

$nbs[[2]]
[1] 1 3 3

$nbs[[3]]
[1] 1 2 1


$cc
$cc$id
[1] 1 1 1

$cc$n
[1] 1

$cc$nodes
$cc$nodes[[1]]
[1] 1 2 3


is it still wrong? every node is now connected to each other but some nodes may connected to each other more than once, is that not accepted in inla graph?


Message has been deleted

guna...@umn.edu

unread,
May 5, 2021, 5:06:35 PM5/5/21
to R-inla discussion group

Hi,

I also tried creating the graph with only IDs connected and putting 0s for what is not connected,  
I ran inla.debug.graph and my error report do not run after 
"I will now try to read the graph properly using inla.read.graph().
* If there are any errors in the following, then recall
* that the numbering for lines and nodes, are 0-based (and NOT 1-based)!
Error in if (s[k] + offset == 0L) { : 
  missing value where TRUE/FALSE needed"
Can you please check what is wrong with this format? is it because I have 0s? here I have everything connected and each ID is only one time,
txt file is attached

Just to summarize; in the previous attempt I tried to duplicate the connections , this was done irrespective of considering the direction of connection, so that all IDs are connected to each other , sometimes resulting in duplicate connections  (which I am not sure is accepted in a graph file and waiting for your reply)
The other method is putting 0 for what is not connected as in this attempt that I just described,  considering one direction of connection,


Thanks
Umanga
test_R_INLA.txt

Umanga Gunasekera

unread,
May 31, 2021, 10:40:05 AM5/31/21
to R-inla discussion group
Hi,

Can you please let me know what is the difference between saturated DIC and the normal DIC? Is it that saturated DIC is calculated based on log likelihood? When I want to compare models and select the best model that differs due to change of one random variable, is it better to use DIC or saturated DIC?
Is there a place I can get more information?

Thanks
Umanga

Helpdesk

unread,
Jun 1, 2021, 12:51:16 AM6/1/21
to Umanga Gunasekera, R-inla discussion group

that is about using the log likelihood or the saturated log likelihood,
and only matters if you compare models with different likelihood.
comparing models with the same likelihood, then, its does not matter
what you use.

On Mon, 2021-05-31 at 20:09 +0530, 'Umanga Gunasekera' via R-inla
discussion group wrote:
> Hi,
>

Umanga Gunasekera

unread,
Jun 1, 2021, 1:01:01 AM6/1/21
to Helpdesk, R-inla discussion group
Ok, thanks. 
Reply all
Reply to author
Forward
0 new messages