Learn R Programming

smerc (version 1.0.1)

nnpop: Determine nearest neighbors for minimum spanning trees

Description

mst.nn determines the nearest neighbors for a set of observations based on the distance matrix according to a distance-based upperbound. These neighbors are directly related to the zones considered in dmst.test, dc.test, and mlink.test

Usage

nnpop(d, pop, ubpop)

scan.nn(d, pop, ubpop)

Arguments

d

An \(n\times n\) square distance matrix containing the intercentroid distance between the \(n\) region centroids.

pop

The population size associated with each region.

ubpop

The upperbound of the proportion of the total population to consider for a cluster.

Value

Returns the indices of the nearest neighbors as a list. For each element of the list, the indices are ordered from nearest to farthest from each centroid.

Details

This function determines the nearest neighbors of each centroid based on the intercentroid distance. The number of nearest neighbors is limited by the sum of the population values among the nearest neighbors. The set of nearest neighbors can contain no more than ubpop * sum(pop) members of the population. The nearest neighbors are ordered from nearest to farthest.

Examples

Run this code
# NOT RUN {
data(nydf)
coords = as.matrix(nydf[,c("longitude", "latitude")])
d = as.matrix(dist(coords))
nn = scan.nn(d, pop = nydf$pop, ubpop = 0.1)
# }

Run the code above in your browser using DataLab