Implements a Ward-like hierarchical clustering
algorithm including soft contiguity constraints. The algorithm takes as
input two dissimilarity matrices
D1 and a mixing
parameter alpha between 0 an 1. The dissimilarities can be non euclidean
and the weights of the observations can be non uniform. The first matrix
gives the dissimilarities in the "feature space". The second matrix gives
the dissimilarities in the "constraint" space. For instance,
can be a matrix of geographical distances or a matrix build from
a contiguity matrix. The mixing parameter
alpha sets the importance
of the constraint in the clustering process.
an object of class
an object of class "dist" with other dissimilarities between the same n observations.
a real value between 0 and 1. This mixing parameter gives the
relative importance of
if TRUE the two dissimilarity matric
vector with the weights of the observations. By default, wt=NULL corresponds to the case where all observations are weighted by 1/n.
The criterion minimized at each stage is a convex combination of
the homogeneity criterion calculated with
D0 and the homogeneity
criterion calculated with
D1. The parameter
alpha (the weight
of this convex combination) controls the importance of the constraint
in the quality of the solutions. When
the homogeneity calculated with
D0 decreases whereas the
homogeneity calculated with
Returns an object of class
M. Chavent, V. Kuentz-Simonet, A. Labenne, J. Saracco. ClustGeo: an R package for hierarchical clustering with spatial constraints. Comput Stat (2018) 33: 1799-1822.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
data(estuary) # with one dissimilarity matrix w <- estuary$map@data$POPULATION # non uniform weights D <- dist(estuary$dat) tree <- hclustgeo(D,wt=w) sum(tree$height) inertdiss(D,wt=w) inert(estuary$dat,w=w) plot(tree,labels=FALSE) part <- cutree(tree,k=5) sp::plot(estuary$map, border = "grey", col = part) # with two dissimilarity matrix D0 <- dist(estuary$dat) # the socio-demographic distances D1 <- as.dist(estuary$D.geo) # the geographical distances alpha <- 0.2 # the mixing parameter tree <- hclustgeo(D0,D1,alpha=alpha,wt=w) plot(tree,labels=FALSE) part <- cutree(tree,k=5) sp::plot(estuary$map, border = "grey", col = part)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.