schc: Spatially Constrained Hierarchical Clucstering (SCHC)

Description Usage Arguments Value Examples

View source: R/clustering.R

Description

Spatially constrained hierarchical clustering is a special form of constrained clustering, where the constraint is based on contiguity (common borders). The method builds up the clusters using agglomerative hierarchical clustering methods: single linkage, complete linkage, average linkage and Ward's method (a special form of centroid linkage). Meanwhile, it also maintains the spatial contiguity when merging two clusters.

Usage

1
2
3
4
5
6
7
8
9
schc(
  k,
  w,
  data,
  method = "average",
  bound_vals = vector("numeric"),
  min_bound = 0,
  distance_method = "euclidean"
)

Arguments

k

The number of clusters

w

An instance of Weight class

data

A list of numeric vectors of selected variable

method

"single", "complete", "average","ward"

bound_vals

(optional) A 1-d vector of selected bounding variable

min_bound

(optional) A minimum value that the sum value of bounding variable int each cluster should be greater than

distance_method

(optional) The distance method used to compute the distance betwen observation i and j. Defaults to "euclidean". Options are "euclidean" and "manhattan"

Value

A list of numeric vectors represents a group of clusters

Examples

1
2
3
4
5
6
7
guerry_path <- system.file("extdata", "Guerry.shp", package = "rgeoda")
guerry <- geoda_open(guerry_path)
queen_w <- queen_weights(guerry)
guerry_df <- as.data.frame(guerry) # use as data.frame
data <- guerry_df[c('Crm_prs','Crm_prp','Litercy','Donatns','Infants','Suicids')]
guerry_clusters <- schc(4, queen_w, data, "complete")
guerry_clusters

lixun910/rgeoda documentation built on March 19, 2021, 3:49 p.m.