determineNeighbors {BayesNSGP} | R Documentation |
Determine the k-nearest neighbors for each spatial coordinate.
Description
determineNeighbors
returns an N x k matrix of the nearest neighbors
for spatial locations coords, with the ith row giving indices of the k nearest
neighbors to the ith location, which are selected from among the 1,...(i-1)
other spatial locations. The first row is -1's, since the first location has
no neighbors. The i=2 through i=(k+1) rows each necessarily contain 1:i.
Usage
determineNeighbors(coords, k)
Arguments
coords |
N x 2 array of N 2-dimensional (x,y) spatial coordinates. |
k |
Scalar; number of neighbors |
Value
An N x k matrix of nearest neighbor indices
Examples
coords <- cbind(runif(100), runif(100))
determineNeighbors(coords, 20)
[Package BayesNSGP version 0.1.2 Index]