Skip to content

About dnearneight and nb2listw function

2 messages · Letícia Dal' Canton, Roger Bivand

#
I am forwarding the routine used and the part of the database I am interested in, which uses georeferenced agricultural data.

require(spdep)
require(geoR)

dados = read.geodata("test.txt", header = T)
dados

coord=dados$coord

max(dist(coord))/2

grid = dnearneigh(dados$coord, 0, 880)

lw=nb2listw(grid,zero.policy=TRUE)
1) The "dnearneight" function provides the neighbor list object. Is there any way to numerically visualize who the neighbors are?

2) The "nb2listw" function provides the "Characteristics of weights list object". When requesting the weights (lw$w in the routine), the n points are listed and values are assigned (who are these values?) And why are not the n values associated to the remaining n-1. Because in "attr (," comp ") $ d" it is noticeable that each point is associated to a different amount of points. For example, with the database used, the first point is associated to another 57, the second to another 65. Why does this occur?

Thankfully,


Let?cia Dal' Canton.

Matem?tica.
Mestre em Engenharia Agr?cola.
Doutoranda em Engenharia Agr?cola com linha de pesquisa em Estat?stica Espacial.
Universidade Estadual do Oeste do Paran? - UNIOESTE.

Curr?culo Lattes: http://lattes.cnpq.br/1085422685501012.
Contato: (45) 9 9962-7492.
#
On Mon, 4 Nov 2019, Let?cia Dal' Canton wrote:

            
"numerically visualize" is not clear. Do you mean "show me who is 
neighbour of whom"?

library(spdep)
example(columbus, package="spData")
col.gal.nb # print method for nb objects
print.default(col.gal.nb) # treating nb as a list
col.gal.nb[[1]] # neighbours of observation 1

See also the package vignette vignette("nb_igraph") or: 
https://r-spatial.github.io/spdep/articles/nb_igraph.html
https://cran.r-project.org/web/packages/spdep/vignettes/nb_igraph.html
No idea, your data are not available. If you posted HTML, they were 
certainly discarded as risky. Post plain text only, and provide data on a 
link, not verbatim. If you set the distance threshold to 800, probably 
some observations were further than 800 units apart.

all.equal(attr(nb2listw(col.gal.nb)$weights, "comp")$d, card(col.gal.nb))

shows that in this case (row standardisation), the d vector is the same as 
the neighbour count per observation - it does not have to be so.

Roger