Skip to content

K-means cluster analysis

In the app: Help → Help contents, K-means cluster analysis.

K-means (Estimate → Clusters → K-means clusters…) splits observations into k groups so that each is as close as it can be to its group's centre: it minimises the within-cluster sum of squared distances. Clustering the dates of a set of indicators finds regimes (expansion, slowdown, stress) without a model; clustering the series by their standardised paths finds the indicators that move together. Standardising first (the default) lets each series count equally whatever its units.

The algorithm (Lloyd's) alternates two steps: each observation goes to its nearest centre, and each centre moves to the mean of its observations, until nothing moves. It finds a local minimum, so it starts several times from k-means++ centres (spread out at random, in proportion to the squared distance from those already chosen) and keeps the best; the seed fixes the starts, so the clusters are the same each time. Clusters are numbered in the order they first appear.

The silhouette of an observation compares its mean distance to its own cluster (a) with that to the nearest other cluster (b): (b - a) / max(a, b), near 1 when it sits well inside its cluster, near 0 between two, negative when it is closer to another. Number of clusters (k-means)… fits each k in a range: the within-cluster sum of squares always falls as k rises, so look for the elbow where it stops falling steeply, and for a high mean silhouette. Next ▸ draws the clusters as a band above a surveillance heatmap.

See also

References

  • MacQueen, J. (1967). Some methods for classification and analysis of multivariate observations. Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability 1, 281-297. (search)
  • Arthur, D. and Vassilvitskii, S. (2007). k-means++: the advantages of careful seeding. Proceedings of the 18th ACM-SIAM Symposium on Discrete Algorithms, 1027-1035. (search)
  • Rousseeuw, P. J. (1987). Silhouettes: a graphical aid to the interpretation and validation of cluster analysis. Journal of Computational and Applied Mathematics 20, 53-65. doi:10.1016/0377-0427(87)90125-7