Skip to contents

Prunes the minimum spanning tree of the contiguity graph (edge weight = attribute distance, Prim's algorithm from start) k - 1 times; each cut takes, over all current subtrees, the edge whose removal most reduces the within-group dissimilarity, in decreasing order until both parts respect min_size and min_weight. The dissimilarity is the sum of Euclidean distances to the group mean as in the skater function of spdep, or the sum of squared deviations when squared = TRUE.

Usage

Skater(
  X,
  adjacency,
  k,
  min_size = 1,
  weights = NULL,
  min_weight = NULL,
  squared = FALSE,
  start = 1
)

Arguments

X

Attribute matrix (units in rows).

adjacency

0/1 contiguity matrix or list of 1-based neighbour vectors.

k

Number of regions.

min_size

Minimum units per region.

weights

Per-unit weights for min_weight.

min_weight

Minimum summed weight per region.

squared

Use squared deviations.

start

1-based root of Prim's algorithm.

Value

list(labels (1-based), mst, ssw, n_regions).

References

Assuncao, R. M., Neves, M. C., Camara, G. and da Costa Freitas, C. (2006). Efficient regionalization techniques for socio-economic geographical units using minimum spanning trees. International Journal of Geographical Information Science 20, 797-811.

Examples

X <- matrix(c(0, 0.1, 0.2, 5, 5.1, 5.2))
path <- list(2, c(1, 3), c(2, 4), c(3, 5), c(4, 6), 5)
Skater(X, path, 2)$labels
#> [1] 1 1 1 2 2 2