[R-sig-Geo] dnearneigh() from spdep: Points with the exact same location are not considered neighbours.

Roger Bivand Roger.Bivand at nhh.no
Wed Apr 12 09:27:57 CEST 2017


Do not post HTML-mail, only plain text. Your example is not reproducible 
because you used HTML-mail.

Please read the help file, the bounds are described as being between lower 
(greater than) and upper (less than or equal to) bounds. Since the 
distance between identical points is strictly zero, they are not 
neighbours because the distance must be > d1 and <= d2. If d1 is < 0, it 
is reset to 0, as it is assumed that a negative lower bound is a user 
error (and it would break the underlying compiled code).

In any case, no reasonable cross-sectional spatial process has duplicated 
point (nugget) observations in situations in which spatial weights would 
be used (spatio-temporal panels will have, but then time differs).

Hope this clarifies,

Roger

On Wed, 12 Apr 2017, Maël Le Noc via R-sig-Geo wrote:

> Dear List
>
> As I was working on a project, I realized that when I use dnearneigh
> from spdep, two (or more) points that have the exact same coordinates
> are not considered neighbours and thus are not linked (even when the
> lower bound is put to 0 or even to -1). See below for an example.
> (However this does not happen if the parameter longlat is set to false)
>
> Does the function behave the same way for you? Am I missing something?
> Is this an expected behavior? And if so, if there a way to change that ?
>
> In the example below, points 1 and 2 are not connected to each other/are
> not neighbours (as you can see since the both have only one link, to 3),
> even though they have the exact same coordinates (and are thus less than
> 25km apart), while point 3 is connected to both point 1 and 2.
> If I want to assess autocorrelation using, for instance joincount.test,
> this is then an issue...
>
>> /library(data.table) />/library(spdep) />/pointstable <- data.table(XCoord=c(13.667029,13.667029,13.667028), /YCoord=c(42.772396,42.772396,42.772396))
>> /print(pointstable) /     XCoord  YCoord
> 1: 13.667029 42.772396
> 2: 13.667029 42.772396
> 3: 13.667028 42.772396
>> /coords <-cbind(pointstable$XCoord, pointstable$YCoord) />/nbLocal<- dnearneigh(coords, d1=0, d2=25, longlat = TRUE) />/nbLocal<- dnearneigh(coords, d1=-1, d2=25, longlat = TRUE) #both lines /produce the same output
>> /summary(nbLocal) /Neighbour list object:
> Number of regions: 3
> Number of nonzero links: 4
> Percentage nonzero weights: 44.44444
> Average number of links: 1.333333
> Link number distribution:
>
> 1 2
> 2 1
> 2 least connected regions:
> 1 2 with 1 link
> 1 most connected region:
> 3 with 2 links
>> //
> Thanks
> Maël
>
>
> 	[[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

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
Editor-in-Chief of The R Journal, https://journal.r-project.org/index.html
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list