% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/manuscript-viz.R
\name{cluster_selection_plot}
\alias{cluster_selection_plot}
\title{Justify the number of clusters (silhouette + elbow / scree)}
\usage{
cluster_selection_plot(
  x,
  k_range = 2:8,
  linkage = "ward.D2",
  select = c("elbow", "silhouette"),
  plot = TRUE
)
}
\arguments{
\item{x}{A fitted result (with \code{$DistM}), a dissimilarity matrix, or a
\code{List} of data sources (objects in rows).}

\item{k_range}{Integer vector of candidate cluster counts.}

\item{linkage}{Agglomeration method used to cut the dissimilarity.}

\item{select}{How to pick \code{best_k}: \code{"elbow"} (default) uses the
knee of the within-cluster dispersion (scree) curve -- the \eqn{k} at which
the curve starts to flatten; \code{"silhouette"} uses the maximum average
silhouette width.}

\item{plot}{Logical; draw the two-panel figure.}
}
\value{
Invisibly a data frame with \code{k}, \code{silhouette} and
\code{within_dispersion}, plus attributes \code{"best_k"}, \code{"elbow_k"}
and \code{"silhouette_k"}.
}
\description{
For a fused dissimilarity (or a fitted result, or a \code{List} of sources)
compute, over a range of \eqn{k}, the average silhouette width and the total
within-cluster dispersion (an elbow / scree curve), and plot them so the
chosen \eqn{k} can be justified in the manuscript.
}
\examples{
data(mosaic_toy)
fit <- M_ABCpp(mosaic_toy$List, numsim = 40, NC = 3)
cluster_selection_plot(fit, k_range = 2:6)
}
\seealso{
\code{\link{embedding_plot}}, \code{\link{SelectnrClusters}}
}
