Bookmark and Share

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


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

st: sppack [was: SSPACK]


From   [email protected]
To   [email protected]
Subject   st: sppack [was: SSPACK]
Date   Thu, 31 Mar 2011 13:21:55 -0500

Ashley Arnio <[email protected]> asked about creating k-nearest-neighbor (KNN)
spatial-weighting matrices:

> Are there any plans to include a k-nn matrix in the near future? 

Ashley can use -spmat idistance- with the undocumented option -knn()- to create
a KNN spatial-weighting matrix.  I will illustrate with the ancillary
pollute.dta dataset that comes with the sppack suite.

  . use pollute, clear
  . spmat idistance dobj longitude latitude, id(id) dfunction(dhaversine) knn(5)

-spmat idistance ..., knn(5)- creates a spatial-weighting matrix in which the
five nearest neighbors of each spatial unit are weighted by their inverse
distances and all others recieive zero weights.  We can use -spmat summarize-
with the option -links- to verify that each spatial unit has indeed five
neighbors.

  . spmat summarize dobj

We did not document the -knn()- option because the command is slow for large
problems.  We plan to address this issue in the future.

--Rafal
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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