Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Re: Nearstat version

From   Nick Cox <>
To   "" <>
Subject   Re: st: Re: Nearstat version
Date   Mon, 6 Feb 2012 17:41:30 +0000

In general I support programmers' rights (my program, my decision) but I have to say that this sounds distinctly eccentric. So in a database of Stata users if several people at StataCorp have the same coordinates the distance between them is the distance to the nearest Stata user, say several miles (km) away? To me it's zero. (Whether some purposes compel me to change zero to some positive tolerance is a different issue.)

I'd recommend to Wilner

1. Documenting this quirk in the help if that's not done already. I guess most users of geographical data would regard it as a misfeature, to be frank.

2. Even if this default is what you want consider adding an option to override it.

3. In fact two options: zero means that; zero means a user-specfied tolerance.


On 6 Feb 2012, at 16:33, "P. Wilner Jeanty" <> wrote:

2012/2/5 Rüdiger Vollmeier <>:
Thanks a lot for the good advice how to run the program.

I ve got one question regarding the programming: It seems that in case
of non-identical observations with identical longitude and latitude,
the programs does not return the distance 0 but calculates the
shortest distance to non-identical latitude and longitudes. Am I
right? This is surprising and, I guess, for many users not desired. Is
it possible to change that (such that the distance 0 will be returned
in these cases)?

This is a legitimate behavior by the program. Because it does not
stand to reason that two different locations have identical latitudes
and longitudes, -nearstat- thinks that it is computing the distance
between an observation and itself. In order to identify the nearest
neighbors (1st, 2nd, 3rd, and so forth), distance computed from an
observation to itself is intentionally set to missing as part of the
programming process. Ruediger's case where non-identical observations
have identical latitudes and longitudes is an unusual one. As a
result, I don't intend to modify -nearstat- to allow for it, at least
not now, unless many users want this change to be made. Without more
information, I find it odd that non-identical observations or areal
units have identical latitudes and longitudes.

FYI, a new version of -nearstat- with Mata code compiled in Stata 10.1
has been submitted to SSC.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index