[R-sig-Geo] Converting nb list containing areas with no neighbours with nb2WB()
Xingli Giam
xgiam at princeton.edu
Wed Nov 25 09:09:11 CET 2009
Hi everyone,
Thank you in advance for your advice. First I must apologize for sending the
two scrubbed messages in this thread. I thought MS Outlook Web Light sends
messages in plain text format but I was wrong. I have transferred my account
to my new email address and have set the email format to plain text. I hope
everything is fine now. I sincerely apologize for causing inconvenience by
sending multiple unreadable messages to the list.
I am trying to convert a nb object containing a single area with no
neighbours into a spatial weights list for input into WinBUGS using nb2WB().
When I tried to run the CAR models in WinBUGS using the spatial weights list
via R2WinBUGS, I encountered a WinBUGS trap. The error message was "Index
out of range".
I checked the adjacency matrix of the spatial weights list output object,
and a zero integer was placed at the position corresponding to the area with
no neighbours.
When I re-ran the analysis after I changed my neighbourhood structure such
that all areas had neighbours, the WinBUGS simulation ran fine.
Is there a way to format the spatial weights list object via nb2WB() in a
way that allows WinBUGS to read cases with no neighbours?
In WinBUGS, if we were to enter the adjacency matrix manually it will be:
#Here is where we tell BUGS how to set up the adjacency structure. For
example, site 1 neighbors sites 19,9, and 5.
adj = c(
19, 9, 5,
10, 7,
12,
28, 20, 18,
19, 12, 1,
#Site 6 has no neighbors
17, 16, 13, 10, 2,
and so on.
)
Here are my OS details:
R version 2.10.0 (2009-10-26)
i386-pc-mingw32
locale:
[1] LC_COLLATE=English_Singapore.1252 LC_CTYPE=English_Singapore.1252
LC_MONETARY=English_Singapore.1252
[4] LC_NUMERIC=C LC_TIME=English_Singapore.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] R2WinBUGS_2.1-16 spdep_0.4-52 nlme_3.1-96 coda_0.13-4
MASS_7.3-3
[6] Matrix_0.999375-32 lattice_0.17-26 spam_0.15-5 boot_1.2-41
maptools_0.7-26
[11] foreign_0.8-38 sp_0.9-47 deldir_0.0-10
loaded via a namespace (and not attached):
[1] grid_2.10.0 tools_2.10.0
Best,
Xingli Giam
Ph.D. candidate
Department of Ecology and Evolutionary Biology
Princeton University
Princeton, USA
More information about the R-sig-Geo
mailing list