In a factor model, the centre \(\lambda f\) slides along a line. In a cluster model, the latent variable is discrete: each observation belongs to one of a few groups, and its centre jumps among a few points.
The group of observation \(t\), one of \(k\) groups:
\[ g_t=\begin{cases} 1 & \text{if observation } t \text{ belongs to group } 1,\\ \vdots & \\ k & \text{if observation } t \text{ belongs to group } k. \end{cases} \]
With \(\mu_{li}\) the mean of variable \(i\) in group \(l\), and two variables:
\[ x_{t1}=\mu_{g_t1}+u_{t1},\qquad x_{t2}=\mu_{g_t2}+u_{t2} \qquad\text{or}\qquad \mathbf x_t=\mu_{g_t}+\mathbf u_t \]
Setting \(\mu_{g_t}=\Lambda\mathbf f_t\) gives the factor model \(\mathbf x_t=\Lambda\mathbf f_t+\mathbf u_t\), whose centre stays on a line or a plane. In the cluster model, \(\mu_{g_t}\) is one of only \(k\) points, which can lie anywhere. Cluster analysis estimates the groups from the observations alone.
The density of the penguins’ bill length and depth has three hills, one for each species.
Each method sees only the measurements. The species then check the result.
Merge the two closest clusters, again and again. Distance between clusters: the average of the Euclidean distances \(d_{st}=\lVert\mathbf x_s-\mathbf x_t\rVert\) between their members \(s\) and \(t\).
\(W\), the within-cluster sum of squares: the squared distances of the observations from the means of their clusters, added up.
All 333 penguins, four measurements, each standardised. Height: the distance between the two clusters when they merge, as each linkage measures it. For single linkage one close pair is enough to merge two clusters, so a chain of neighbours links the Adelie and the Chinstrap.
\(\hat g_t\) is the cluster of observation \(t\), and \(\bar{\mathbf x}_l\) the mean of cluster \(l\), its centre. k-means minimises
\[ W=\sum_{t=1}^n\sum_{i=1}^p\big(x_{ti}-\bar x_{\hat g_ti}\big)^2=\sum_{t=1}^n\big\lVert\mathbf x_t-\bar{\mathbf x}_{\hat g_t}\big\rVert^2 \]
Lloyd’s algorithm repeats two steps until no observation moves:
\(W\) never rises, but the algorithm can stop at a local minimum, so it is run from many starts.
\(W\) counts a millimetre of length like a millimetre of depth, so k-means favours round clusters of one size, like the dashed circles.
Within each species, bill length varies two to three times as much as depth: a long, flat ellipse.
Both axes have the same scale, so round looks round.
More clusters always lower \(W\).
Look for an elbow: here at two, the Adelie against the rest, with a smaller step to three.
The plot suggests a number but does not decide it.
The flipper length of the Adelie and Gentoo. Group \(l\) is normal, with density \(f_l\), mean \(\mu_l\) and variance \(\sigma_l^2\):
\[f(x)=\pi_1f_1(x)+\pi_2f_2(x)\]
The membership probability
\[P(g_t=l\mid x_t)=\frac{\pi_lf_l(x_t)}{f(x_t)}\]
is the share of group \(l\) among penguins with flipper length \(x_t\).
The shares, means and variances maximise the log-likelihood \(\ln L=\sum_t\ln f(x_t)\). EM repeats two steps:
\[ \pi_l=\frac1n\sum_tP(g_t=l\mid x_t),\qquad \mu_l=\frac{\sum_tP(g_t=l\mid x_t)\,x_t}{\sum_tP(g_t=l\mid x_t)}, \] \[ \sigma_l^2=\frac{\sum_tP(g_t=l\mid x_t)\,(x_t-\mu_l)^2}{\sum_tP(g_t=l\mid x_t)} \]
EM is k-means with soft assignments, and \(\ln L\) never falls.
With \(p\) variables, \(f_l\) is normal with mean vector \(\mu_l\) and covariance matrix \(\Sigma_l\): each group is an ellipse. The groups match the species for 97% of the penguins, k-means for 75%.
Three letters, in this order:
Each letter is one of:
For example, EVE: the same size, each group its own shape, the same tilt.
\[\text{BIC}=2\ln\hat L-(\text{number of parameters})\times\ln n\]
\(\ln\hat L\) is the largest log-likelihood of a model and \(n\) the number of observations. The largest BIC wins.
More parameters always fit at least as well: without the charge, VVV with many groups would win and overfit.
With round groups of equal size and share, the shape EII: \(\Sigma_l=\sigma^2I\) (the same variance \(\sigma^2\) in every direction) and \(\pi_l=1/k\):
\[\pi_lf_l(\mathbf x_t)=\frac1k\,(2\pi\sigma^2)^{-p/2}\exp\!\Big(-\frac{\lVert\mathbf x_t-\mu_l\rVert^2}{2\sigma^2}\Big)\]
The most likely group is the one with the nearest mean, as in k-means.
k-means is the mixture EII: round groups, measured by the Euclidean distance, where body mass in grams dominates. The mixture VEE gives all groups the same ellipse up to its size, which adapts to any units: its Mahalanobis distances do not depend on them, so it finds the same groups.
BIC picks four groups.
The fourth splits the Gentoo by sex: males are larger.
The model was never told the sex.
Six indicators, standardised, k-means with \(k=3\). The data find the groups, and we name them from the means.
Every method finds the South. How the other states are grouped depends on the method.
Ward’s method gives the k-means clusters too, but it minimises the same \(W\), so it is no independent check.
| Factor analysis | Model-based clustering | |
|---|---|---|
| Latent variable | continuous factors \(\mathbf f_t\) | a discrete group \(g_t\) |
| Model | \(\mathbf x_t=\Lambda\mathbf f_t+\mathbf u_t\) | \(\mathbf x_t=\mu_{g_t}+\mathbf u_t\) |
| What it groups | variables | observations |
| Not identified | the turn of the factors | the numbers of the groups |
| For each observation | factor scores | membership probabilities |
| How many? | likelihood ratio test | BIC |
Cluster analysis finds groups of observations that lie together. A model adds probabilities, shapes and a way to choose their number.