redcap: Regionalization with dynamically constrained agglomerative...

Description Usage Arguments Value Examples

View source: R/clustering.R

Description

REDCAP (Regionalization with dynamically constrained agglomerative clustering and partitioning) is developed by D. Guo (2008). Like SKATER, REDCAP starts from building a spanning tree with 4 different ways (single-linkage, average-linkage, ward-linkage and the complete-linkage). The single-linkage way leads to build a minimum spanning tree. Then,REDCAP provides 2 different ways (first-order and full-order constraining) to prune the tree to find clusters. The first-order approach with a minimum spanning tree is exactly the same with SKATER. In GeoDa and pygeoda, the following methods are provided: \* First-order and Single-linkage \* Full-order and Complete-linkage \* Full-order and Average-linkage \* Full-order and Single-linkage \* Full-order and Ward-linkage

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
redcap(
  k,
  w,
  data,
  method = "fullorder-averagelinkage",
  bound_vals = vector("numeric"),
  min_bound = 0,
  distance_method = "euclidean",
  random_seed = 123456789,
  cpu_threads = 6
)

Arguments

k

The number of clusters

w

An instance of Weight class

data

A list of numeric vectors of selected variable

method

"firstorder-singlelinkage", "fullorder-completelinkage", "fullorder-averagelinkage","fullorder-singlelinkage", "fullorder-wardlinkage"

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"

random_seed

(int,optional) The seed for random number generator. Defaults to 123456789.

cpu_threads

(optional) The number of cpu threads used for parallel computation

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 <- redcap(4, queen_w, data, "fullorder-completelinkage")
guerry_clusters

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