StatLabStudent EditionUser guideGalleryFeaturesAbout

K-means cluster analysis

Splits cases into a chosen number of groups so that cases in a group are close to the group centre on the chosen variables.

Menu: Analyze → Classify → K-Means Cluster…

When should I use it?

What are the assumptions?

How do I run it in StatLab?

  1. Move the variables in (standardized versions if their scales differ).
  2. Enter the number of clusters.
  3. Raise the maximum iterations if the iteration history shows centres still moving.
  4. Save cluster membership to profile the clusters with other variables.
  5. Tick Use running means to update each cluster centre after every case is assigned, instead of after a complete pass.

How do I read the output?

OutputMeaning
Initial Cluster CentersStarting points chosen from the data.
Iteration HistoryHow far centres moved each iteration.
Final Cluster CentersMean of each variable in each cluster — use to name clusters.
ANOVAWhich variables separate the clusters most (descriptive only).
Number of Cases in each ClusterCluster sizes.

Worked example

On the practice survey dataset (File → Sample dataset), this command — which the dialog's Paste button also produces — runs the procedure:

PROC glmKMeans /vars=(score age) /k=2 /maxIter=10 /running=NO /anova=YES /member=NO /save=NO.

Output tables: Initial Cluster Centers · Iteration History · Final Cluster Centers · Distances between Final Cluster Centers · ANOVA · Number of Cases in each Cluster.

How would I report it in APA style?

A k-means cluster analysis on Wellbeing score, Age (years) (N = 150) formed 2 clusters of 71, 79 cases and converged in 2 iterations.

Computed by StatLab's validated procedure code when this page was built. The example only illustrates the steps; choose variables that fit your own research question.

What are common mistakes?

Open StatLab   All guide topics