Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: nearest neighbor distance


From   "Benoit Dulong" <[email protected]>
To   "StataList" <[email protected]>
Subject   st: nearest neighbor distance
Date   Thu, 09 Jan 2003 01:54:22 -0500

x=(x1,x2), a point in R^2.

My dataset (simulation), has at least 200 points.
For each point in the dataset, I want:
1- identify the nearest neighbor (nnid)
2- calculate the distance to that nearest neighbor (nnd)
How can I create nnid and nnd ?

 list in 1/10, noobs

       id         x1         x2       nnid        nnd
        1     0.6231     0.6594          .          .
        2     0.0770     0.8497          .          .
        3     0.8031     0.5251          .          .
        4     0.4283     0.2249          .          .
        5     0.2084     0.1750          .          .
        6     0.8936     0.9179          .          .
        7     0.6168     0.7379          .          .
        8     0.5663     0.2539          .          .
        9     0.6465     0.5444          .          .
       10     0.7783     0.0047          .          .

In particular, I used
net search distance nearest neighbor, or

Thank you.
BD.



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index