poly2nb neighbour itself should be considered a neighbour
Hello,
I found this matter easier when working with matrix representations. Set
?A^0 = I (identity matrix),
?A^1 = A, where A_{ij} = 1 if j is neighbor to j and zero otherwise
(this consider A_{ii} = 0)
?A^2 = A'A
?A^3 = A'A^2 and so on
The A^k_{ij} entry gives _how many steps of length k there is between i
and j_. To me, this definition makes this matter clear. See an example
considering a 10x10 regular grid:
nb <- grid2nb(d=c(10,10), queen = FALSE)
nn <- card(nb)
A1 <- sparseMatrix(
?i = rep(1:length(nn), nn),
?j = unlist(nb[nn>0]), x=1)
A2 <- crossprod(A1)
image(A1)
image(A2)
best regards,
Elias
On 03/11/2019 17:46, Dexter Locke wrote:
Dear Robert, It sounds like what you are looking for is typically called a second order neighbor. Higher order neighbors can also included in a weights matrix such as your neighbors?, neighbors?, neighbor which is a third-order neighbor. I think you are seeking second-order neighbors. See the spdep vignettes, and the section 5 Higher-Order Neighbors subsection here: https://cran.r-project.org/web/packages/spdep/vignettes/nb.pdf in particular. The spdep::nblag might be what you need, but without additional information it is hard to know. Good luck, Dexter dexterlocke.com
On Nov 3, 2019, at 2:12 PM, Robert R <usercatch at outlook.com> wrote:
?Dear All,
I would like to know if the function "poly2nb" ("spdep" package.) let me create a neighborhood of itself, i.e., not only its queen neighbors (queen=TRUE), but a neighbour itself should also be considered a neighbour.
I am looking to create a queen weight neighborhood matrix afterwards using "nb2listw".
Any help would help me a lot.
Many thanks
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo