Description Usage Arguments Details Value Author(s) See Also Examples
Writes a graph file from an adjacency matrix suitable for use with INLA.
1 | nbToInlaGraph(adjMat, graphFile="graph.dat")
|
adjMat |
An object of class |
graphFile |
name of file to save adjacency matrix to. |
This function correctly handles regions which have zero neighbours.
A vector of names and indices
Patrick Brown
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | data('kentucky')
# remove all the neighbours Ballard county
kSub = kentucky[-c(2,20,79),]
if( require("spdep", quietly=TRUE)) {
adjMat = poly2nb(
kSub,
row.names=kSub$County,
queen=FALSE
)
nFile = tempfile()
nbRes = nbToInlaGraph(adjMat, nFile)
# Ballard is region 3
nbRes['Ballard']
# note that Ballard has no neighbours
adjMat[[3]]
cat(readLines(nFile, n=5), sep='\n')
## Not run:
# there will be a warning about zero neighbours
junk = bym(poverty ~ 1, data=kSub, family='gaussian')
## End(Not run)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.