Elbow_finder: Automatically selects the optimal number of clusters based on elbow criterion.
Description
Automatically selects the optimal number of clusters (X-axis) based on elbow criterion computed on a metric (Y-axis).
Potential metrics are the AIC and the BIC. The function can be applied to any other context in which the objective is to find the optimal X producing an elbow in Y.
Usage
Elbow_finder(x, y, Plot = TRUE)
Value
Returns the following outputs:
x_max_dist: optimal value of x (i.e., the x satisfying the elbow rule)
y_max_dist: optimal value of y (i.e., the y satisfying the elbow rule)
Scatterplot (non-compulsory) of x and y with connecting lines and vertical line in correspondence of the optimal value of x.
Arguments
x
Numeric (m x 1) vector of integer values (usually, the number of clusters from 1 to G)
y
Numeric (m x 1) vector of values (usually, the criterion values) associated with the number of groups.
Plot
Logical value (TRUE or FALSE). If Plot = TRUE a plot of the relationship between x and y is produced.
The plot is a scatterplot with connecting lines. A vertical line is depicted in correspondence of the optimal value of x.