hclustgeo {ClustGeo} | R Documentation |
Implements a Ward-like hierarchical clustering
algorithm including soft contiguity constraints. The algorithm takes as
input two dissimilarity matrices D0
and 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, D1
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.
hclustgeo(D0, D1 = NULL, alpha = 0, scale = TRUE, wt = NULL)
D0 |
an object of class |
D1 |
an object of class "dist" with other dissimilarities between the same n observations. |
alpha |
a real value between 0 and 1. This mixing parameter gives the
relative importance of |
scale |
if TRUE the two dissimilarity matric |
wt |
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 alpha
increases,
the homogeneity calculated with D0
decreases whereas the
homogeneity calculated with D1
increases.
Returns an object of class hclust
.
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.
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)