nhclu_kmeans | R Documentation |
This function performs non-hierarchical clustering based on dissimilarity using a k-means analysis.
nhclu_kmeans(
dissimilarity,
index = names(dissimilarity)[3],
seed = NULL,
n_clust = c(1, 2, 3),
iter_max = 10,
nstart = 10,
algorithm = "Hartigan-Wong",
algorithm_in_output = TRUE
)
dissimilarity |
The output object from |
index |
The name or number of the dissimilarity column to use. By
default, the third column name of |
seed |
A value for the random number generator ( |
n_clust |
An |
iter_max |
An |
nstart |
An |
algorithm |
A |
algorithm_in_output |
A |
This method partitions data into k groups such that the sum of squares of Euclidean distances from points to the assigned cluster centers is minimized. K-means cannot be applied directly to dissimilarity or beta-diversity metrics because these distances are not Euclidean. Therefore, it first requires transforming the dissimilarity matrix using Principal Coordinate Analysis (PCoA) with pcoa, and then applying k-means to the coordinates of points in the PCoA.
Because this additional transformation alters the initial dissimilarity matrix, the partitioning around medoids method (nhclu_pam) is preferred.
A list
of class bioregion.clusters
with five components:
name: A character
string containing the name of the algorithm.
args: A list
of input arguments as provided by the user.
inputs: A list
of characteristics of the clustering process.
algorithm: A list
of all objects associated with the clustering
procedure, such as original cluster objects (only if
algorithm_in_output = TRUE
).
clusters: A data.frame
containing the clustering results.
If algorithm_in_output = TRUE
, the algorithm
slot includes the output of
kmeans.
Boris Leroy (leroy.boris@gmail.com)
Pierre Denelle (pierre.denelle@gmail.com)
Maxime Lenormand (maxime.lenormand@inrae.fr)
For more details illustrated with a practical example, see the vignette: https://biorgeo.github.io/bioregion/articles/a4_2_non_hierarchical_clustering.html.
Associated functions: nhclu_clara nhclu_clarans nhclu_dbscan nhclu_pam nhclu_affprop
comat <- matrix(sample(0:1000, size = 500, replace = TRUE, prob = 1/1:1001),
20, 25)
rownames(comat) <- paste0("Site",1:20)
colnames(comat) <- paste0("Species",1:25)
comnet <- mat_to_net(comat)
dissim <- dissimilarity(comat, metric = "all")
clust <- nhclu_kmeans(dissim, n_clust = 2:10, index = "Simpson")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.