na's introduced by coercion: problem with graph file

204 views
Skip to first unread message

Christy Meredith

unread,
Oct 27, 2011, 3:04:25 PM10/27/11
to r-inla-disc...@googlegroups.com

Hello, I have made some changes to a graph file, but now the graph file will not run properly in my code. I tried to debug, and no problems were found. This is the error when I try to read the graph file: Would could be wrong?


* 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 numeric(n) : vector size cannot be NA
In addition: Warning messages:
1: running command '"C:/Program Files/R/R-2.13.1/library/INLA/bin/windows/inla.exe" -s -m graph "habitattry2.graph"' had status 3
2: In inla.read.graph(graph.file) : NAs introduced by coercion

Havard Rue

unread,
Oct 27, 2011, 3:14:10 PM10/27/11
to r-inla-disc...@googlegroups.com

can u send me the graph in trouble?

--
Havard Rue

Christy Meredith

unread,
Oct 28, 2011, 1:24:02 PM10/28/11
to r-inla-disc...@googlegroups.com

Havard
Thanks for taking a look at this. I have 73 reaches along a stream. I previously had them all connected in the graph file, however, I changed the graph file so that there are some disconnected sections because several of the reaches are extremely far apart. But the new graph file gives me an error.


I think it might be better to use a geostatistical model, but my data is areal data with a zero inflated negative binomial distribution. Also, I am not sure how to do a geostatistical model in INLA. I am just pasting because I seem to be having problems attaching a file. The graph file is below.

73


1 1 2
2 2 1 3
3 2 2 4
4 2 3 5
5 2 4 6
6 2 5 7
7 2 6 8
8 2 7 9
9 2 8 10
10 2 9 11
11 2 10 12
12 2 11 13
13 2 12 14
14 2 13 15
15 2 14 16
16 1 15
17 1 18
18 2 17 19
19 2 18 20
20 2 19 21
21 2 20 22
22 1 21
23 1 22
24 2 23 25
25 1 26
26 1 27
27 2 26 28
28 2 27 29
29 2 28 30
30 2 29 31
31 1 30
32 1 33
33 2 32 34
34 2 33 35
35 2 34 36
36 1 35
37 1 38
38 2 37 39
39 2 38 40
40 2 39 41
41 2 40 42
42 1 41
43 1 44
44 2 43 45
45 2 44 46
46 2 45 47
47 2 46 48
48 2 47 49
49 2 48 50
50 2 49 51
51 2 50 52
52 2 51 53
53 2 52 54
54 2 53 55
55 2 54 56
56 2 55 57
57 1 56
58 1 59
59 2 58 60
60 2 59 61
61 2 60 62
62 2 61 63
63 2 62 64
64 2 63 65
65 1 64
66 1 67
67 2 66 68
68 2 67 69
69 2 68 70
70 2 69 71
71 2 70 72
72 2 71 73
73 1 72


LC Chien

unread,
Oct 28, 2011, 5:05:40 PM10/28/11
to r-inla-disc...@googlegroups.com
It is suggested to use the BayesX package in R to modify your .gra file. According to my experience, the .gra file is generally converted from the boundary (.bnd) file. You have to investigate some disconnected areas and know their codings. Then, use the add.neighbor() function to connect those areas to the closest areas with each other. Each area should at least one adjacent area. Sometimes it is not enough, but you can convert the modified boundary file to a graph file first, then run your model to see whether it works. If it is still failed, add more neighbors to those areas until your model works. I encountered similar problems in these months, and now they are all solved by this way. Hope it is helpful.
Reply all
Reply to author
Forward
0 new messages