Data geometry · Methodological studies · Part I
Metric Embeddings, PCA, and Cluster Analysis
Geometric intuition, mathematical foundations, and interpretation of results in R and Minitab
Originally published:
Revised:
Abstract
Representing data in a few dimensions requires deciding which relationships to preserve. This article develops principal component analysis through its geometry and algebraic structure, explains how it supports a mediated assessment of the relevance of the original variables, and connects dimensionality reduction with cluster analysis. It includes a worked example, verified applications using decathlon2 and USArrests, comparisons of metrics and validation criteria, and an extension on random projections and the Johnson–Lindenstrauss lemma.
On small screens, tables, equations, and code that exceed the available width can be scrolled horizontally.
1. Dimensionality, variables, and relationships
A table with many columns provides numerous descriptions of its observations, but this does not guarantee that every column contributes a distinct relationship. Several measurements may vary together; others may introduce specific information or mainly reflect noise. Dimensionality reduction constructs a representation with fewer coordinates while seeking to preserve properties relevant to a specified question.
A data matrix contains n observations in its rows and p quantitative variables in its columns. The original representation space has dimension p; the rank of the centered data cannot exceed min(n−1, p). Intrinsic dimension expresses, more broadly, how many degrees of freedom are needed to describe the structure of the data at the required level of precision.
Two related operations are involved: selecting original variables and extracting combinations of them. PCA directly performs the second and provides a mediated route to assessing the relevance of the first. This operational distinction does not remove their conceptual connection: the derived coordinates are constituted by the original variables and their relationships of covariation.
The curse of dimensionality encompasses difficulties that arise under certain conditions as the number of dimensions increases: greater data requirements, concentration of distances, or instability of estimates. It is not a law rendering every wide table useless. Sample size, effective structure, distribution, metric, and task all matter.
The problem of fitting lines and planes to systems of points appears in Pearson (1901). Contemporary machine learning motivations extend its applications, but should be distinguished from the history of the procedure. PCA and the later theory of random projections address related problems through different guarantees.
2. What a transformation preserves
Centering subtracts the mean of each variable. Translation changes the origin and preserves distances between observations. Standardization additionally divides each column by its standard deviation, changing the weight of its differences. This second operation generally changes the geometry expressed in the original units.
Neither centering nor standardization, by itself, transforms an arbitrary distribution into a Gaussian distribution. Standardizing a column is also different from dividing a direction vector by its length: the latter produces a unit vector.
| Operation | Effect on Euclidean distances | Role in the analysis |
|---|---|---|
| Centering | Preserved. | Place the point cloud around its mean. |
| Full orthogonal change of coordinates | Preserved. | Express the point cloud in a new orthonormal basis. |
| Truncation to k components | May decrease; equality holds if the difference has no discarded component. | Reduce dimension with loss controlled through reconstruction. |
| Standardization | Change relative to the original units. | Prevent a numerical scale from dominating automatically. |
| Normalized random projection | Approximately preserved under probabilistic conditions. | Control distance distortion for a finite set. |
Let V be a full orthogonal matrix. For any difference d between two observations, holds. Splitting the basis into retained and discarded directions, the Pythagorean identity gives:
A reduced PCA representation is therefore not necessarily an isometric embedding. It may even map two distinct observations to the same point. Exact preservation in a lower-dimensional subspace is possible when all differences between the data points belong to the retained subspace; otherwise, distortion must be evaluated.
3. The mathematical construction of PCA
We use a consistent convention: Xc is the centered matrix, S is its covariance matrix with divisor n−1, and vj is a unit direction vector. When the variables are standardized, their covariance matrix is the correlation matrix of the original data.
The first direction maximizes projected variance among all unit directions. Subsequent directions maximize the remaining variance subject to orthogonality to the previous ones. Without the norm constraint, multiplying the coefficients by an arbitrarily large constant would make the maximum undefined.
Singular value decomposition provides a direct and numerically convenient calculation. If , the columns of V are the principal directions, the scores are T=XcV=UΣ, and the eigenvalues of S are . A singular value of the data matrix is not simply the square root of an eigenvalue of its covariance matrix: the divisor matters. The function prcomp() uses SVD and this sample convention (R Core Team, n.d.-c).
Maximizing retained variance and minimizing this squared error are equivalent formulations of the same problem. The equivalence follows because total variation decomposes into orthogonal projected and residual parts. It does not depend on separating a supposedly “analytical” methodology from a “numerical” one.
Descriptive PCA does not require normally distributed data (Jolliffe & Cadima, 2016). Additional assumptions arise when making inferences, specifying probabilistic models, or setting detection thresholds. With repeated eigenvalues, the individual directions within their subspace are not unique; even without repetition, each direction may reverse sign without changing the solution.
4. Eigenvalues, averages, and variance
In linear algebra, an eigenvalue is the factor by which a transformation multiplies an eigenvector: . In PCA, the transformation is the covariance or correlation matrix, and that factor acquires a precise statistical interpretation: the variance of the projection onto the corresponding unit direction.
An average therefore underlies the eigenvalue: the expectation of the squared, centered projections of the observations. Dispersion is measured along a direction defined by the eigenvector. This relationship allows the eigenvalue to be understood as a quantitative summary of variation in that direction.
This average of squared projections is not the average of the eigenvector’s coordinates. The coordinates are variable weights; the scores are values for observations; variance summarizes the dispersion of those scores. Confusing these three objects changes the meaning of the result.
| Matrix S = diag(9, 1) | Unit eigenvector | Mean of its coordinates | Eigenvalue |
|---|---|---|---|
| First direction | (1, 0)ᵀ | 0.5 | 9 |
| Second direction | (0, 1)ᵀ | 0.5 | 1 |
Furthermore, v and −v share an eigenvalue, while their coordinate averages change sign. Multiplying the entire matrix S by ten preserves its eigenvectors and multiplies its eigenvalues by ten. An eigenvalue depends jointly on the transformation and the direction; the direction alone does not determine its magnitude.
The eigenvector determines how to project; the eigenvalue expresses how much variation the data contain in that projection.
5. A mediated assessment of variable relevance
An account of PCA limited to saying that it “creates new coordinates” leaves its interpretive role incomplete. The new coordinates are constructed from the original variables; by ranking the components and studying their composition, we can identify, through these mediations, which variables participate in the retained structure and to what extent.
Three questions should be distinguished: which variables define a direction; what fraction of each variable’s variation is represented; and how much that direction contributes to total variation. Answering them jointly requires examining coefficients, variable–component correlations, contributions, and eigenvalues. A variable may have little relevance to PC1 and considerable relevance to PC2 or PC3.
For standardized variables, the coordinates in the correlation circle are . Their squares describe how well the variable is represented on each axis. In this standardized PCA, the conventional contribution of a variable to an axis is and sums to 100% across variables.
These expressions formalize the mediation: both the ranking of components, given by their eigenvalues, and the participation of the variable in them are involved. Since , we have . For standardized variables, Saa=1 and Ra(k)=Qa(k).
The term loading follows different conventions across programs: it may designate eigenvector coefficients or coordinates scaled by the square root of the eigenvalue. This article always specifies the object being used. An observation’s squared cosine, in turn, concerns the representation of that observation rather than a variable’s contribution.
6. A fully worked PCA example
Consider four observations on two variables, with mean (3, 3). The example is constructed so that every step can be checked without relying on software output. We work with covariances, without standardizing.
The characteristic polynomial is . It gives and . We choose the directions and . They have unit norm, are orthogonal, and satisfy the eigenvector equation.
| Observation | Centered data | PC1 | PC2 | Reconstruction using PC1, in original units |
|---|---|---|---|---|
| A | (−2, −1) | −3/√2 ≈ −2.1213 | 1/√2 ≈ 0.7071 | (1.5, 1.5) |
| B | (−1, −2) | −3/√2 ≈ −2.1213 | −1/√2 ≈ −0.7071 | (1.5, 1.5) |
| C | (1, 2) | 3/√2 ≈ 2.1213 | 1/√2 ≈ 0.7071 | (4.5, 4.5) |
| D | (2, 1) | 3/√2 ≈ 2.1213 | −1/√2 ≈ −0.7071 | (4.5, 4.5) |
The PC1 scores sum to zero. Their squares sum to 18, so their sample variance is 18/3=6. The squared PC2 scores sum to 2, and their variance is 2/3. This shows directly where the average of squared scores defining each eigenvalue enters the calculation.
For both variables, the reconstructed variance is . Since their original variance is 10/3, each is represented at 90%. Each contributes 50% to PC1. These percentages differ because they answer different questions: the composition of an axis and the representation of a variable.
R · numerical example and algebraic checks
X <- rbind(A=c(1,2), B=c(2,1), C=c(4,5), D=c(5,4))
colnames(X) <- c("X1", "X2")
Xc <- scale(X, center=TRUE, scale=FALSE)
S <- cov(X)
V <- cbind(PC1=c(1,1), PC2=c(-1,1))/sqrt(2)
T <- Xc %*% V
lambda <- diag(t(V) %*% S %*% V)
Xc_hat <- T[,1,drop=FALSE] %*% t(V[,1,drop=FALSE])
X_hat <- sweep(Xc_hat, 2, colMeans(X), "+")
lambda
T
X_hat
sum((Xc-Xc_hat)^2)
stopifnot(max(abs(lambda-c(6,2/3))) < 1e-10,
abs(sum((Xc-Xc_hat)^2)-2) < 1e-10,
max(abs(t(V)%*%V-diag(2))) < 1e-10)7. How many components should be retained?
The proportion of variance explained by component j is obtained by dividing its eigenvalue by the sum of all eigenvalues. The cumulative proportion measures how much a representation with k dimensions retains:
| Criterion | Decision | Scope and limitations |
|---|---|---|
| Cumulative variance | Retain components until a chosen percentage is reached. | The threshold depends on the objective. Neither 80% nor 90% provides a universal guarantee. |
| Kaiser | Retain eigenvalues greater than 1 in correlation-based PCA. | Compares with the variance of one standardized variable; it should not be transferred unadjusted to arbitrary units. |
| Scree plot | Look for a change in the slope of the eigenvalues. | A graphical aid whose interpretation can be ambiguous. |
| Parallel analysis | Compare eigenvalues with a reference lacking association between variables. | The result depends on the reference, percentile, sample size, and simulation design. |
| Out-of-sample reconstruction | Evaluate error on data not used for fitting. | Avoid leakage from centering and scaling; repeated splits are useful. |
| Substantive objective | Retain dimensions representing relationships of interest. | Must be assessed alongside stability and interpretation; it does not replace statistical evidence. |
A rank-deficient matrix has zero eigenvalues. For centered data, the number of positive-variance components cannot exceed min(n−1, p). When p is large relative to n, a good description of the sample can coexist with unstable estimates of population directions. Consistency requires conditions on signal, noise, and the dimensional regime; comparing two integers alone does not settle it.
Parallel analysis has an antecedent in Horn (1965). Sparse PCA imposes or encourages zero coefficients to obtain combinations with few active variables. “Sparse” here refers to the coefficient structure, not simply to having little data. It can support interpretation or regularization under specified assumptions; it does not by itself guarantee recovery of the true structure.
8. Application: the ten decathlon events
The decathlon2 dataset contains 27 athletes, ten events, and three additional columns: rank, overall points, and competition. Following the conventional example in the documentation, we use the first 23 athletes and first ten columns as active data; the remaining four rows can subsequently be projected as supplementary observations. The columns Rank, Points, and Competition do not enter the fit (Kassambara & Mundt, n.d.-a).
The events use seconds, meters, and other performance measurements. Standardization prevents numerical scale from determining each column’s initial weight. In races, a lower time generally indicates better performance; in jumps and throws, a greater distance generally indicates better performance. The signs must be interpreted with this difference in mind.
R · active data, PCA, contributions, and supplementary rows
# First run only, if these packages are missing:
# install.packages(c("factoextra", "cluster"))
data("decathlon2", package="factoextra")
deca_active <- decathlon2[1:23, 1:10]
stopifnot(all(vapply(deca_active, is.numeric, logical(1))),
!anyNA(deca_active), all(vapply(deca_active, sd, 0) > 0))
pca_deca <- prcomp(deca_active, center=TRUE, scale.=TRUE)
# Fix an orientation to simplify comparisons of signs.
orient_pca <- function(p, anchor=1, sign=-1) {
for (j in seq_len(ncol(p$rotation))) {
a <- if (j==1) anchor else which.max(abs(p$rotation[,j]))
target_sign <- if (j==1) sign else 1
if (p$rotation[a,j]*target_sign < 0) {
p$rotation[,j] <- -p$rotation[,j]
p$x[,j] <- -p$x[,j]
}
}
p
}
pca_deca <- orient_pca(pca_deca)
lambda_deca <- pca_deca$sdev^2
deca_eigenvalues <- data.frame(
lambda=lambda_deca,
percentage=100*lambda_deca/sum(lambda_deca),
cumulative=100*cumsum(lambda_deca)/sum(lambda_deca))
variable_pc_cor <- sweep(pca_deca$rotation, 2, pca_deca$sdev, "*")
contribution <- 100*pca_deca$rotation^2
representation_3 <- rowSums(variable_pc_cor[,1:3,drop=FALSE]^2)
round(deca_eigenvalues, 4)
round(cbind(variable_pc_cor[,1:3], Q3=representation_3), 4)
# Supplementary projection using the fitted centering and scaling:
supplementary_scores <- predict(pca_deca,
newdata=decathlon2[24:27,1:10])
supplementary_scores| Component | Eigenvalue | Variance (%) | Cumulative (%) |
|---|---|---|---|
| PC1 | 4.1242 | 41.24 | 41.24 |
| PC2 | 1.8385 | 18.39 | 59.63 |
| PC3 | 1.2391 | 12.39 | 72.02 |
| PC4 | 0.8194 | 8.19 | 80.21 |
| PC5 | 0.7016 | 7.02 | 87.23 |
| PC6 | 0.4229 | 4.23 | 91.46 |
| PC7 | 0.3026 | 3.03 | 94.48 |
| PC8 | 0.2745 | 2.74 | 97.23 |
| PC9 | 0.1552 | 1.55 | 98.78 |
| PC10 | 0.1220 | 1.22 | 100.00 |
The eigenvalues 4.1242, 1.8385, and 1.2391 correspond to PC1, PC2, and PC3. Each component combines the ten events; its name is not replaced by that of one of the first three columns. In the chosen orientation, PC1 contrasts short-race times with several jumps and throws. PC2 combines, among other characteristics, pole vault and 1500 meters; because a longer time and a greater height have different sporting meanings, it should not automatically be converted into a single scale of “better performance.”
| Variable | Correlation with PC1 | Contribution to PC1 (%) | Represented in PC1–PC3 (%) |
|---|---|---|---|
| X100m | -0.851 | 17.54 | 84.67 |
| Long.jump | 0.794 | 15.29 | 74.59 |
| Shot.put | 0.734 | 13.06 | 81.38 |
| High.jump | 0.610 | 9.02 | 69.76 |
| X400m | -0.702 | 11.94 | 65.68 |
| X110m.hurdle | -0.764 | 14.16 | 78.60 |
| Discus | 0.743 | 13.39 | 58.60 |
| Pole.vault | -0.217 | 1.14 | 70.80 |
| Javeline | 0.428 | 4.45 | 69.74 |
| X1500m | 0.004 | 0.00 | 66.36 |
The 100-meter event contributes 17.54% to PC1 and is represented at 84.67% when three components are retained. The 1500-meter event contributes almost nothing to PC1, but its correlation with PC2 is approximately 0.784 and its contribution to that axis reaches 33.47%. Pole vault contributes approximately 35.46% to PC2. These results show why a mediated assessment of variable relevance must consider more than one axis.
pca_deca$x.Reproduce the comparison with parallel analysis
R code
set.seed(20261113)
null_eigenvalues <- replicate(500, {
permuted <- apply(deca_active, 2, sample)
eigen(cor(permuted), symmetric=TRUE, only.values=TRUE)$values
})
threshold95 <- apply(null_eigenvalues, 1, quantile, probs=.95)
data.frame(observed=lambda_deca, threshold95=threshold95,
exceeds=lambda_deca > threshold95)
sum(lambda_deca > 1) # Kaiser: 3
sum(lambda_deca > threshold95) # Permutation parallel analysis: 1This procedure destroys association between columns while preserving their observed marginal distributions. Each ordered eigenvalue is compared with the 95th percentile of its reference distribution. This is an explicit methodological choice; another reference or rule may yield a different number of components.
9. Reading the plots and Minitab output
Software output represents different mathematical objects. Before interpreting it, identify what each point, arrow, percentage, and unit represents. This applies equally to R, Minitab, and other programs.
| Output | Object represented | Interpretation |
|---|---|---|
| Scree plot | Eigenvalues or percentages, depending on the chosen scale. | Assess how variation is distributed among components. |
| Scores | Coordinates of observations on components. | Examine patterns, separations, and distant observations; report how much variance the plane retains. |
| Coefficients or loadings | Variable weights or variable–component correlations. | Check the software convention first. These are not observation scores. |
| Correlation circle | Correlations of variables with axes. | Interpret angles as approximations to relationships when the variables are well represented in the plane. |
| Biplot | Observations and variables in a joint representation. | State the scaling. Do not give the same meaning to every distance between different kinds of objects. |
| Contributions | Participation of observations or variables in an axis. | Check which is displayed and which denominator is used. |
| Squared cosine | Quality of representation on retained axes. | A low value indicates that the plane loses a substantial part of the object represented. |
In Minitab (Minitab, n.d.), select the active quantitative columns and choose between covariance and correlation analysis. To replicate the geometry of the decathlon example, use the correlation matrix and the same 23 rows. Request eigenvalues, coefficients, scores, and plots, and compare percentages and subspaces. Signs can reverse across programs without changing the solution; divisors and score scales should also be checked.
In the financial example in the Minitab documentation, the first three eigenvalues are 3.5476, 2.1320, and 1.0447, accounting for approximately 84.1% cumulatively. Associations of PC1 with age, residence, employment, and savings support a proposed interpretation in terms of long-term financial stability; this label is a substantive reading of the coefficients and requires examining the variable definitions. Eigenvalues alone do not assign that meaning.
Some Spanish Minitab output headings use “influencias” for loadings. Here this concerns component composition rather than a regression influence measure. Nor is a loading generally a causal derivative of a variable with respect to a response phenomenon. Ordinary PCA does not define a dependent variable.
Mahalanobis distance weights coordinates by their dispersion and accounts for covariation. Retaining only some components changes this distance and can hide anomalies in discarded directions. If the covariance matrix is singular, the ordinary inverse does not exist; using a pseudoinverse or regularization changes the criterion and should be reported.
PCA and least-squares regression also differ in their objectives. A simple regression of Y on X minimizes residuals in the response direction; the PCA line fit minimizes distances orthogonal to the line in the chosen geometry. Principal component regression adds a supervised stage after PCA and must be validated as a predictive model.
10. Clusters and the k-means objective
Clustering organizes observations using a similarity criterion and a research purpose. A statistical group depends on the variables, their scale, the dissimilarity, and the algorithm. The resulting organization should be justified through these decisions and knowledge of the object being studied.
K-means seeks a partition of the observations into k groups and a centroid for each group. Its ordinary objective minimizes the sum of squared Euclidean distances to the centroids. The mean minimizes this criterion; absolute distances or other dissimilarities change the problem and do not automatically yield the same algorithm.
Common algorithms alternate assignments and updates or use other local improvements. Multiple starts reduce the risk of accepting a poor local solution, but do not certify a global minimum. In R, nstart controls how many initializations are tried when a number of centers is supplied (R Core Team, n.d.-b).
K-means is unsupervised learning: labels are constructed from the data rather than supplied as known training classes. Groups are disjoint and exhaustive when every observation receives a label. Hierarchical methods organize partitions at different levels; their groups are also disjoint when the tree is cut at a particular level.
The connection with PCA arises because both can be formulated through quadratic approximations: PCA reconstructs through a linear subspace, and k-means through centroids and discrete assignments. Ding and He (2004) study this relationship through a continuous relaxation of membership indicators. The connection does not guarantee that PC1 separates the groups or that the methods produce the same solution.
11. Application: USArrests and validation
USArrests contains 50 US states and four variables. Murder, Assault, and Rape record arrests per 100,000 residents in 1973; UrbanPop gives the urban population percentage. These are aggregate records of arrests and urbanization, not a direct, complete measurement of every crime committed or of individual people’s characteristics (R Core Team, n.d.-d).
We use the dataset included in R as distributed so that results are comparable with the historical example. Its documentation identifies a transcription error in Maryland’s urbanization value and provides additional rounding corrections. A substantive study should examine the corrected version and document sensitivity; the numbers below explicitly refer to the uncorrected built-in dataset.
R · standardization, multiple starts, and evaluation of k
library(cluster)
data("USArrests", package="datasets")
usa_z <- scale(USArrests)
dist_usa <- dist(usa_z, method="euclidean")
pca_usa <- orient_pca(prcomp(usa_z, center=FALSE, scale.=FALSE))
fits <- lapply(2:6, function(k) {
set.seed(20261113+k)
kmeans(usa_z, centers=k, nstart=100, iter.max=100)
})
k_comparison <- do.call(rbind, lapply(seq_along(fits), function(j) {
a <- fits[[j]]
data.frame(k=j+1, W=a$tot.withinss, B=a$betweenss,
silhouette=mean(silhouette(a$cluster, dist_usa)[,3]))
}))
km2 <- fits[[1]]
round(k_comparison, 4)
km2$size
round(aggregate(USArrests, list(cluster=km2$cluster), mean), 3)
stopifnot(abs(km2$totss-km2$tot.withinss-km2$betweenss) < 1e-8)
summary(pca_usa)The first two components explain approximately 62.01% and 24.74%, respectively, totaling 86.75%. PC1 and PC2 are combinations of all four variables. The 62.01% is neither a state’s murder percentage nor an average proportion of crime types: it is the fraction of total standardized variance captured by the first axis.
| Number of clusters | Within-cluster sum W | Between-cluster sum B | Mean silhouette |
|---|---|---|---|
| 2 | 102.8624 | 93.1376 | 0.4085 |
| 3 | 78.3233 | 117.6767 | 0.3094 |
| 4 | 56.4032 | 139.5968 | 0.3397 |
| 5 | 48.9442 | 147.0558 | 0.3031 |
| 6 | 42.8330 | 153.1670 | 0.2860 |
For k=2, the groups have sizes 20 and 30, a within-cluster sum of 102.8624, and a between-cluster sum of 93.1376. The total sum is 196: each of the four standardized columns contributes n−1=49. The between-cluster proportion is 93.1376/196≈47.52%; this percentage concerns the clustering criterion and should not be confused with the variance explained by PC1.
In this solution, the 20-state group has means of 12.165 for Murder, 255.250 for Assault, 68.400 for UrbanPop, and 29.165 for Rape. The 30-state group has means of 4.870, 114.433, 63.633, and 15.943. This description concerns the observed variables and historical period; it does not authorize causal inferences about urbanization or direct generalization to the present.
11.1. Silhouette: cohesion and separation
For observation i, a(i) is its average dissimilarity to the other observations in its cluster. For each other cluster, calculate the average dissimilarity between i and its members; b(i) is the minimum of these averages. The silhouette compares the two quantities (Rousseeuw, 1987):
A value near one indicates that the observation is comparatively closer to its own group; near zero, assignment is ambiguous under the chosen dissimilarity; a negative value suggests greater average proximity to another group. Their mean is a dimensionless index, not a distance between clusters. The ordinary silhouette is defined for solutions with at least two clusters and fewer clusters than observations.
Among the examined solutions with two to six clusters, the highest mean silhouette is 0.4085 for two clusters. This is a relative comparison among those solutions and within that geometry. A moderate mean does not establish that every state is well assigned; inspect individual silhouettes and differences between groups.
11.2. The gap statistic and its selection rule
The gap statistic, proposed by Tibshirani et al. (2001), compares observed dispersion with dispersion under a reference distribution without cluster structure. Simulating that reference is different from resampling observations to study partition stability. The function clusGap() allows the number of simulations, reference space, and distance power to be specified (Maechler, n.d.).
R · gap with 501 simulations and an explicit squared-distance setting
set.seed(20261113)
gap_usa <- clusGap(usa_z,
FUNcluster=function(x,k) list(cluster=kmeans(x, centers=k,
nstart=50, iter.max=100)$cluster),
K.max=6, B=501, d.power=2, spaceH0="scaledPCA", verbose=FALSE)
k_gap <- maxSE(gap_usa$Tab[,"gap"], gap_usa$Tab[,"SE.sim"],
method="Tibs2001SEmax")
round(gap_usa$Tab, 4)
k_gap # 2 in the documented run11.3. What “enhanced analysis” means in eclust()
factoextra::eclust() combines fitting, selection of the number of clusters, and visualization. It returns an object containing results of the chosen method and additional components; this does not make it a second-order tensor. In its documentation, nboot controls gap-statistic simulations when k is estimated. Increasing it can reduce Monte Carlo variability, but does not guarantee consistency, representativeness, or cluster stability (Kassambara & Mundt, n.d.-b).
R · optional interface; it does not replace explicit gap configuration
# Convenient alternative for fitting and visualization:
res_eclust <- factoextra::eclust(usa_z, FUNcluster="kmeans", k=2,
nstart=100, iter.max=100, graph=FALSE, seed=20261115)
factoextra::fviz_cluster(res_eclust, data=usa_z)
factoextra::fviz_silhouette(res_eclust)
# Here k is fixed: nboot does not enter its selection.
# With k=NULL, specify k.max, nboot, and gap_maxSE, and check
# the implementation settings before comparing results.12. Hierarchical clustering and dissimilarities
An agglomerative procedure begins with one observation per cluster and merges clusters according to a criterion. The dendrogram records this sequence. Sets are nested across levels, and cutting the tree yields a partition of disjoint groups. Such nesting is different from simultaneous membership in overlapping groups at the same level.
| Linkage | Between-cluster criterion | Meaning of height |
|---|---|---|
| Single | Minimum dissimilarity between a pair of members of the two groups. | Dissimilarity of the pair enabling the merge; can produce chaining. |
| Complete | Maximum dissimilarity between members of the two groups. | Criterion based on extreme separation between groups. |
| Average | Mean dissimilarity across pairs of members from the two groups. | Average dissimilarity at the merge. |
| Ward | Increase in within-cluster sum of squares. | Height associated with Ward’s criterion and the implementation’s scale, rather than a generic distance between centroids. |
In R, hclust() offers several linkages, and ward.D2 implements Ward’s criterion through a squared treatment of dissimilarities (R Core Team, n.d.-a). Here we supply ordinary Euclidean distances when using ward.D2; we do not square them beforehand. The call eclust(..., "hclust") has its own documented default, hc_method="ward.D2". BIRCH is another algorithm and does not describe this call.
R · Euclidean Ward clustering and a comparison with correlated profiles
hc_ward <- hclust(dist_usa, method="ward.D2")
ward_groups <- cutree(hc_ward, k=2)
plot(hc_ward, cex=.55, hang=-1)
rect.hclust(hc_ward, k=2, border="saddlebrown")
mean(silhouette(ward_groups, dist_usa)[,3])
# Compare profile similarity using average linkage:
profile_corr <- cor(t(usa_z), method="pearson")
d_cor <- as.dist(1-profile_corr)
hc_cor <- hclust(d_cor, method="average")
corr_groups <- cutree(hc_cor, k=2)
mean(silhouette(corr_groups, d_cor)[,3])| Configuration, k = 2 | Silhouette in its dissimilarity | ARI relative to Euclidean k-means |
|---|---|---|
| Ward.D2 / Euclidean | 0.4048 | 0.9199 |
| Average / 1-r | 0.6565 | 0.1115 |
Correlations between rows compare the relative shape of four values already standardized by column. This is not the correlation between the table’s variables, nor does it preserve each profile’s overall magnitude. With only four coordinates per state, this similarity warrants careful interpretation. The result may group similar profiles even when their absolute levels differ.
| Measure | Property and domain | Caution |
|---|---|---|
| Euclidean and Minkowski with p ≥ 1 | Metrics on the corresponding vector space. | Scales and weights determine the geometry. |
| Correlation r | An association coefficient, usually between −1 and 1. | Not a distance by itself. |
| 1 − r | Dissimilarity between profiles with defined correlation. | Can violate the triangle inequality and assign zero to distinct original profiles. |
| √(2(1 − r)) | Euclidean distance between centered profiles normalized to unit norm. | A metric on those representations; on the original profiles, it identifies location and positive-scale transformations. |
| Transformed Spearman or Kendall coefficients | Compare rankings; properties depend on the domain and handling of ties. | Do not assume that every transformation of a correlation is a metric on the original data. |
| Pseudometric | May assign zero distance to distinct objects while retaining the other usual metric properties. | The representation may identify differences considered irrelevant to the analysis. |
| Quasimetric | Allows asymmetry, according to the adopted axiomatic convention. | Algorithms expecting a symmetric matrix require adaptation. |
Completeness means that every Cauchy sequence converges within the space; it is not part of the general definition of a metric. The Minkowski norm on an ℓp space and the indefinite tensor of pseudo-Riemannian geometry are distinct constructions. An indefinite metric tensor does not automatically generate a nonnegative distance usable by the algorithms above.
13. PCA and clustering: a controlled comparison
To study what changes under dimensionality reduction, we hold the standardized data, two clusters, 100 initializations, and the algorithm fixed. We fit k-means first with all four variables and then with one, two, three, and four components. We compare labels using the adjusted Rand index (ARI) and calculate silhouettes both in the fitting space and in the original variables.
| Space used for clustering | Variance retained (%) | Silhouette in that space | Silhouette in 4 variables | ARI versus original |
|---|---|---|---|---|
| Four variables | 100.00 | 0.4085 | 0.4085 | 1.000 |
| PC1 | 62.01 | 0.6468 | 0.4085 | 1.000 |
| PC1-PC2 | 86.75 | 0.4758 | 0.4085 | 1.000 |
| PC1-PC3 | 95.66 | 0.4308 | 0.4085 | 1.000 |
| PC1-PC4 | 100.00 | 0.4085 | 0.4085 | 1.000 |
In this run, the five partitions are identical. However, the silhouette changes from 0.4085 in four variables to 0.6468 when measured only on PC1. The index improves because the geometry changes: assignments did not improve, because they did not change. With all components retained, distances and silhouettes are recovered, as required by a full orthogonal change of coordinates.
R · separate representation effects from effects on labels
ari <- function(a,b) {
m <- table(a,b)
c2 <- function(z) z*(z-1)/2
n <- sum(m); A <- sum(c2(m))
B <- sum(c2(rowSums(m))); C <- sum(c2(colSums(m)))
expected <- B*C/c2(n)
denominator <- (B+C)/2-expected
if (abs(denominator) < 1e-12) return(1)
(A-expected)/denominator
}
pca_comparison <- do.call(rbind, lapply(1:4, function(m) {
Tm <- pca_usa$x[,seq_len(m),drop=FALSE]
set.seed(20261115)
fit <- kmeans(Tm, centers=2, nstart=100, iter.max=100)
data.frame(components=m,
variance=100*sum(pca_usa$sdev[seq_len(m)]^2)/sum(pca_usa$sdev^2),
silhouette_reduced=mean(silhouette(fit$cluster, dist(Tm))[,3]),
silhouette_original=mean(silhouette(fit$cluster, dist_usa)[,3]),
ARI=ari(km2$cluster, fit$cluster))
}))
round(pca_comparison, 4)13.1. Retaining much variance can conceal a contrast
Now construct two categories defined by Y=−1 and Y=1, both with X values −10, −6, −2, 2, 6, and 10. Cross-covariance is zero. Variation in X is much greater than variation in Y, so covariance-based PCA selects PC1=X and retains 560/572≈97.90% of the variation. The two categories overlap point for point.
R · a low-variance contrast
bands <- data.frame(
X=rep(c(-10,-6,-2,2,6,10), 2),
Y=rep(c(-1,1), each=6))
pca_bands <- prcomp(bands, center=TRUE, scale.=FALSE)
100*pca_bands$sdev[1]^2/sum(pca_bands$sdev^2) # 97.9021
cov(bands)
# Standardization would give both columns variance 1 and change
# the geometry: the choice of scale is part of the question.13.2. Partition stability
Another question is whether assignment withstands perturbations of the data. In 200 subsamples of 40 states, drawn without replacement while keeping the original scaling, k-means was refitted with two groups and compared with the reference labels restricted to those states. Mean ARI was 0.9995, and the 5th, 50th, and 95th percentiles were 1 in the documented run. This is evidence of stability under that particular perturbation, not a population guarantee or causal validation.
Reproduce the subsampling stability evaluation
R code
set.seed(20261113)
stability <- replicate(200, {
ix <- sort(sample(nrow(usa_z), 40, replace=FALSE))
fit <- kmeans(usa_z[ix,], centers=2, nstart=50, iter.max=100)
ari(km2$cluster[ix], fit$cluster)
})
mean(stability)
quantile(stability, c(.05,.5,.95))
range(stability)Here scaling is fixed to isolate partition sensitivity. Re-estimating preprocessing within each subsample evaluates a different perturbation. An observation bootstrap, with replacement, also requires handling duplicates and defining how partitions will be compared. Neither operation should be confused with simulating the gap reference distribution.
14. Random projections and Johnson–Lindenstrauss
PCA adapts directions to variation in the data. A normalized random projection asks another question: can all distances between a finite number of points be approximately preserved using far fewer coordinates? The Johnson–Lindenstrauss lemma gives an affirmative answer, with dimension depending on the number of points and the tolerated distortion.
Consider N points in a Euclidean space, , and a failure tolerance . Random linear constructions exist for which a dimension of order suffices to preserve distances simultaneously with probability at least 1−δ. A common formulation controls squared distances:
The historical formulation with factors 1±ε on ordinary distances has the same dimensional order after adjusting constants. The Gaussian construction uses , with independent standard-normal entries of R. Randomness belongs to the projection matrix; the original observations need not follow a normal distribution (Johnson & Lindenstrauss, 1984; Matoušek, 2013).
Three distinctions are decisive. Dependence is proportional to ε−2, not merely to the logarithm of ε−2. The guarantee holds with high probability for the specified construction and settings; it is not an exact isometry with probability one. Finally, preserving distances in a finite set does not mean preserving every direction of the ambient space when dimension is reduced.
R · an experiment with 80 points, 800 original coordinates, and 120 projected coordinates
set.seed(20261113)
A <- matrix(rnorm(80*800), nrow=80)
R <- matrix(rnorm(120*800), nrow=120)/sqrt(120)
projected <- A %*% t(R)
d_original <- as.vector(dist(A))
d_projected <- as.vector(dist(projected))
ratio <- d_projected/d_original
range(ratio)
max(abs(ratio-1))
plot(d_original, d_projected, pch=16, cex=.35,
col="saddlebrown", xlab="Original distance",
ylab="Projected distance")
abline(0,1,col="gray40")The experiment illustrates the phenomenon; the proof explains how dimension, error, and probability are related. A sufficient theoretical bound may be conservative. The absence of large distortion in one realization does not replace a guarantee for future random realizations.
15. The scope of scientific interpretation
PCA articulates observed relationships among variables and constructs a representation that ranks their variation. In this sense, it can participate in identifying essential relationships of the object: it locates regularities, contrasts, and combinations whose interpretation develops through further conceptual and empirical mediations. Reducing this role to a simple rotation of axes would leave out its scientific use.
At the same time, variance is a particular criterion of relevance. It may capture structure, differences in measurement scale, measurement errors, or noise. A low-variance relationship can be decisive for a specific question, as the band example showed. Identifying essential determinations requires explaining why the variation examined expresses relationships relevant to the phenomenon and how it connects with its history, mechanisms, and other evidence.
Clusters are likewise constructions mediated by a geometry and a criterion. Their stability shows whether certain decisions withstand perturbations; interpretation requires explaining what observations share and why that similarity matters. A group of states defined by arrests and urbanization does not, by itself, constitute a social class, a causal mechanism, or a complete historical typology.
Dimensionality reduction makes a way of preserving relationships explicit. Scientific interpretation requires explaining why those relationships matter for the object being studied.
16. Proofs and extensions
The following extensions preserve the probabilistic and computational development of the original study with consistent notation. They can be read after the applied sections. Algebraic identities are derived here; general theorems and their antecedents are identified in the references.
A. From maximum variance to eigenvectors and reconstruction
For symmetric S, the Lagrangian is . Differentiation with respect to v gives . Writing a unit vector in an orthonormal eigenvector basis, with , gives . Equality is attained along a direction of the largest eigenvalue. Subject to orthogonality to earlier directions, the same argument yields subsequent directions.
For any rank-k orthogonal projector P, orthogonality of its parts gives . Maximizing the first term is equivalent to minimizing the second. The energy retained by a subspace of dimension k cannot exceed the sum of the k largest squared singular values; choosing P=VkVkT attains that bound.
The identity directly connects SVD and eigendecomposition. Symmetry and positive semidefiniteness of the covariance matrix are essential: claims about eigenvectors of an arbitrary nonsymmetric matrix should not be transferred to it without qualification.
B. Gaussian normalization, 2-stability, and sub-Gaussian tails
The Gaussian density’s normalization constant can be obtained without an elementary antiderivative. Let . Squaring and changing to polar coordinates:
If Z1,…,Zp are independent standard-normal variables, the moment-generating function of is:
Thus Y is normally distributed with mean zero and variance . This stability under linear combinations explains why a Gaussian row of a random matrix produces a normal projection of any fixed vector without requiring normally distributed data.
A sufficient condition for a centered variable to be sub-Gaussian is for every real t. Applying Markov’s inequality to the exponential and minimizing over t>0 gives:
Rademacher variables, taking +1 and −1 with probability 1/2 each, satisfy . Under independence, their combinations also have uniform bounds when the coefficient vector’s norm is fixed. A sub-Gaussian variable need be neither normal nor symmetric.
C. Johnson–Lindenstrauss: Gaussian proof and sub-Gaussian extension
Fix a nonzero vector x and a matrix R with m×p independent standard-normal entries. For , 2-stability implies that has a chi-squared distribution with m degrees of freedom.
Applying exponential Markov bounds to both tails and using logarithmic inequalities gives, for 0<ε<1, the bound:
For the N(N−1)/2 difference vectors from a set of N points, the union bound multiplies this probability by the number of pairs. Independence between the pairs’ failure events is unnecessary. It therefore suffices to require:
The overall success probability is at least 1−δ. If δ<1, some realization satisfies all the inequalities. This yields both an existence statement and a probabilistic construction. The proof concerns squared distances; the ordinary-distance formulation follows by taking square roots or adjusting the parameter.
Extension: what changes with sub-Gaussian entries
Now suppose entries are independent, centered, have variance one, and have a uniformly bounded sub-Gaussian parameter. For a unit vector a, each row produces with mean zero, variance one, and a sub-Gaussian bound whose parameter does not depend on p. This follows by factoring the moment-generating function and using .
The next step controls . Integrating a two-sided tail bound gives . Consequently, there is a uniform constant L such that for q≥2.
Row independence allows these bounds to be multiplied for the sum of the Zi. Another Chernoff argument yields a failure probability bounded by for 0<ε<1, with constants depending on the sub-Gaussian parameter. The same union bound completes the extension. The crucial points are controlling both signs of u, keeping constants uniform, and distinguishing quantifiers: first a fixed vector, then all differences in the finite set.
D. The spectral connection between PCA and k-means
Let H be the normalized indicator matrix: its column for group g equals on group members and zero elsewhere. Then , and reconstruction through centroids is . Between-cluster explained variation equals .
Membership imposes a particular discrete structure on H. Relaxing constraints produces spectral problems related to principal components. Moreover, the matrix of centroids repeated for each observation has rank at most k−1 for centered data. Optimality of the reduced-rank approximation therefore gives:
This relationship explains why leading directions may be useful for clustering without equating the two methods’ constraints. A general linear combination may have many nonzero coefficients; assignment to centroids uses membership indicators. The connection should be formulated through objectives and constraints, rather than turning “k-means is sparse PCA” into a general algorithmic identity.
E. NIPALS, missing data, and computational choices
NIPALS extracts components sequentially. A version for complete data starts with a residual matrix E and an initial score column t. It alternates , normalization of v, and the update until convergence. It then deflates using and seeks the next component. Component variance is obtained from .
Variants use only observed entries when updating each coefficient, but “handling missing values” requires specifying the procedure and assumptions. Missingness patterns may bias results; inserting NA into any implementation is not enough. prcomp() uses SVD and should not be described as an implementation of NIPALS.
If only a few components of a large matrix are needed, partial or randomized algorithms may be used. Their suitability depends on size, precision, and data structure. Comparisons must hold centering, scaling, retained dimension, and numerical tolerances fixed.
F. Reproducibility and verification of calculations
Tables and figures were recalculated for this revision. The numerical core was executed with R 4.2.2 Patched and cluster 2.1.4; the decathlon2 data were checked against the public distribution of factoextra. Vector figures represent those results rather than screenshots of old output. The factoextra visualization functions are offered as an optional alternative and may depend on additional package versions.
R · verifiable identities and environment information
# Checks on objects created in previous sections:
stopifnot(abs(sum(lambda_deca)-ncol(deca_active)) < 1e-8)
stopifnot(max(abs(cov(pca_deca$x)-diag(lambda_deca))) < 1e-8)
stopifnot(max(abs(colSums(contribution)-100)) < 1e-8)
stopifnot(all(representation_3 >= 0), all(representation_3 <= 1+1e-8))
stopifnot(abs(sum(usa_z^2)-196) < 1e-8)
stopifnot(max(abs(as.vector(dist(pca_usa$x))-
as.vector(dist_usa))) < 1e-8)
sessionInfo()The R blocks follow the article’s reading order; some reuse previously created objects. Examples can be executed in the R console or through RStudio. Changes in version, precision, or initialization can interchange cluster labels or reverse axis signs. Compare partitions and subspaces in addition to printed numbers.
References
The original document is retained as an antecedent, alongside sources needed for the results developed here. Proofs and numerical examples in this revision provide explicit steps; technical references link to documentation maintained by those responsible for the software.
- Ding, C., & He, X. (2004). K-means clustering via principal component analysis. In Proceedings of the twenty-first international conference on Machine learning (artículo 29). ACM. https://doi.org/10.1145/1015330.1015408
- Horn, J. L. (1965). A rationale and test for the number of factors in factor analysis. Psychometrika, 30, 179–185. https://doi.org/10.1007/BF02289447
- Johnson, W. B., & Lindenstrauss, J. (1984). Extensions of Lipschitz mappings into a Hilbert space. In Contemporary Mathematics (Vol. 26, pp. 189–206). American Mathematical Society. https://web.stanford.edu/class/cs114/readings/JL-Johnson.pdf
- Jolliffe, I. T., & Cadima, J. (2016). Principal component analysis: A review and recent developments. Philosophical Transactions of the Royal Society A, 374(2065), 20150202. https://doi.org/10.1098/rsta.2015.0202
- Kassambara, A., & Mundt, F. (n.d.-a). Athletes’ performance in decathlon: decathlon2 [factoextra documentation]. Retrieved November 13, 2026, from https://rpkgs.datanovia.com/factoextra/reference/decathlon2.html
- Kassambara, A., & Mundt, F. (n.d.-b). Visual enhancement of clustering analysis: eclust [factoextra documentation]. Retrieved November 13, 2026, from https://rpkgs.datanovia.com/factoextra/reference/eclust.html
- Maechler, M. (n.d.). Gap statistic for estimating the number of clusters: clusGap [cluster documentation]. Retrieved November 13, 2026, from https://stat.ethz.ch/R-manual/R-devel/library/cluster/html/clusGap.html
- Matoušek, J. (2013). Lecture notes on metric embeddings [Course notes]. Charles University. https://kam.mff.cuni.cz/~matousek/ba-a4.pdf
- Minitab. (n.d.). Interpret all statistics and graphs for Principal Components Analysis. Retrieved November 13, 2026, from https://support.minitab.com/en-us/minitab/help-and-how-to/statistical-modeling/multivariate/how-to/principal-components/interpret-the-results/all-statistics-and-graphs/
- Nabi, I. (2022). Embebimientos métricos, parte I: Análisis de componentes principales y análisis de conglomerados. Su interpretación conceptual, intuición-lógica geométrica, formalismo matemático y aplicaciones en RStudio y Minitab [Manuscript]. https://marxistphilosophyofscience.com/wp-content/uploads/2022/08/sobre-el-pca-isadore-nabi.pdf
- Pearson, K. (1901). On lines and planes of closest fit to systems of points in space. The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science, 2(11), 559–572. https://doi.org/10.1080/14786440109462720
- R Core Team. (n.d.-a). Hierarchical clustering: hclust [R documentation]. Retrieved November 13, 2026, from https://stat.ethz.ch/R-manual/R-devel/library/stats/html/hclust.html
- R Core Team. (n.d.-b). K-means clustering: kmeans [R documentation]. Retrieved November 13, 2026, from https://stat.ethz.ch/R-manual/R-devel/library/stats/html/kmeans.html
- R Core Team. (n.d.-c). Principal components analysis: prcomp [R documentation]. Retrieved November 13, 2026, from https://stat.ethz.ch/R-manual/R-devel/library/stats/html/prcomp.html
- R Core Team. (n.d.-d). Violent crime rates by US state: USArrests [R documentation]. Retrieved November 13, 2026, from https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/USArrests.html
- 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. https://doi.org/10.1016/0377-0427(87)90125-7
- Tibshirani, R., Walther, G., & Hastie, T. (2001). Estimating the number of clusters in a data set via the gap statistic. Journal of the Royal Statistical Society: Series B, 63(2), 411–423. https://doi.org/10.1111/1467-9868.00293
Original document · 127 pages
The historical manuscript preserves the 2022 version, published under the name Isadore Nabi. This page develops and revises its arguments.
Read the original PDFEnd of study · Geometry, representation, and interpretation of data.


Leave a Comment/Deja un Comentario