Espartaco

“Is that to say we are against Free Trade? No, we are for Free Trade, because by Free Trade all economical laws, with their most astounding contradictions, will act upon a larger scale, upon the territory of the whole earth; and because from the uniting of all these contradictions in a single group, where they will stand face to face, will result the struggle which will itself eventuate in the emancipation of the proletariat.”

Karl Heinrich Marx · Marx-Engels Collected Works, Vol. VI, p. 290

28,530 views since December 2020

28,530 visitas desde diciembre de 2020

EnglishEspañol

METRIC EMBEDDINGS, PART I: PRINCIPAL COMPONENT ANALYSIS AND CLUSTER ANALYSIS. THEIR CONCEPTUAL INTERPRETATION, GEOMETRIC LOGIC-INTUITION, MATHEMATICAL FORMALISM, AND COMPUTATIONAL APPLICATIONS

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 X∈ℝn×p 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.

zia=xia−x¯asa
(1) Columnwise standardization requires a positive standard deviation.

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.

Different transformations provide different guarantees.
OperationEffect on Euclidean distancesRole in the analysis
CenteringPreserved.Place the point cloud around its mean.
Full orthogonal change of coordinatesPreserved.Express the point cloud in a new orthonormal basis.
Truncation to k componentsMay decrease; equality holds if the difference has no discarded component.Reduce dimension with loss controlled through reconstruction.
StandardizationChange relative to the original units.Prevent a numerical scale from dominating automatically.
Normalized random projectionApproximately 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, ‖dV‖2=‖d‖2 holds. Splitting the basis into retained and discarded directions, the Pythagorean identity gives:

‖d‖22=‖dVk‖22+‖dV⟂‖22
(2) The loss of squared distance under truncation is exactly the squared component of the difference in the discarded subspace.

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.

S=XcTXcn−1,tj=Xcvj,Var(tj)=vjTSvj
(3) Scores tⱼ describe the observations along a direction vⱼ.

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.

maxvTv=1vTSv⟹Svj=λjvj,λ1≥⋯≥λp≥0
(4) The stationary condition follows from Lagrange multipliers; the maximum corresponds to the largest eigenvalue.

Singular value decomposition provides a direct and numerically convenient calculation. If Xc=UΣVT, the columns of V are the principal directions, the scores are T=XcV=UΣ, and the eigenvalues of S are λj=σj2/(n−1). 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).

X^c,k=XcVkVkT,‖Xc−X^c,k‖F2=(n−1)∑j>kλj
(5) The optimal rank-k reconstruction leaves an error equal to the sum of discarded variances multiplied by n−1.

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: Av=λv. 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.

λj=vjTSvj=Var(vjTX)=E[(vjT(X−μ))2]
(6) In this population expression, S = Cov(X), μ = E[X], and vⱼ has unit norm.

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.

λj=1n−1∑i=1ntij2
(7) Sample version, with centered scores and covariances calculated using n−1. If the divisor n is used, the entire convention must be changed consistently.

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.

Counterexample: the same coordinate average can accompany different eigenvalues.
Matrix S = diag(9, 1)Unit eigenvectorMean of its coordinatesEigenvalue
First direction(1, 0)ᵀ0.59
Second direction(0, 1)ᵀ0.51

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.

PCj=∑a=1pvaj(Xa−μa)
(8) Each component combines original variables through specific coefficients. With standardization, X here denotes the variables after standardization.

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.

Corr(Xa,PCj)=λjvajSaa
(9) Relationship between coefficient, eigenvalue, and correlation when Sₐₐ > 0 and λⱼ > 0.

For standardized variables, the coordinates in the correlation circle are λjvaj. 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 100vaj2 and sums to 100% across variables.

Ra(k)=∑j=1kλjvaj2,Qa(k)=Ra(k)Saa
(10) Rₐ(k) is the reconstructed variance of variable a; Qₐ(k) is the fraction of its variance represented by the k components.

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 Saa=∑j=1pλjvaj2, we have 0≤Qa(k)≤1. 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.

X=(12214554),Xc=(−2−1−1−21221),S=(10/38/38/310/3)
(11) Data, centering, and sample covariances: each column’s sum of squares is 10, and the cross-product sums to 8.

The characteristic polynomial is (10/3−λ)2−(8/3)2=0. It gives λ1=6 and λ2=2/3. We choose the directions v1=(1,1)T/2 and v2=(−1,1)T/2. They have unit norm, are orthogonal, and satisfy the eigenvector equation.

Scores obtained by multiplying X꜀V, and reconstructions to which the mean is added back.
ObservationCentered dataPC1PC2Reconstruction using PC1, in original units
A(−2, −1)−3/√2 ≈ −2.12131/√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.12131/√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.

PVE1=66+2/3=0.9,‖Xc−X^c,1‖F2=3(23)=2
(12) PC1 retains 90% of total variation; reconstruction loses 2 units of sum of squares.
Four observations projected onto PC1: two distinct pairs collapse to two coordinates while 90 percent of the variance is retained. −2 −1 0 1 2 Centered X1 −2 −1 0 1 2 Centered X2 A B C D Data, projections, and residuals −3 −2 −1 0 1 2 3 PC1 score A and B C and D Each pair shares one coordinate. 90% of the variance is retained. Reducing two dimensions to one
Figure 1. Open squares mark the projections. A and B, originally separated by √2, map to the same point when PC2 is discarded. Retaining 90% of the variance does not guarantee preserving every distance or distinguishing every pair.

For both variables, the reconstructed variance is 6(1/2)2=3. 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:

PVEj=λj∑ℓ=1pλℓ,PVE1:k=∑j=1kλjtr(S)
(13) In a PCA of p standardized variables, the eigenvalues sum to p.
Dimension selection should report its criterion rather than hide it behind an automatic output.
CriterionDecisionScope and limitations
Cumulative varianceRetain components until a chosen percentage is reached.The threshold depends on the objective. Neither 80% nor 90% provides a universal guarantee.
KaiserRetain 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 plotLook for a change in the slope of the eigenvalues.A graphical aid whose interpretation can be ambiguous.
Parallel analysisCompare eigenvalues with a reference lacking association between variables.The result depends on the reference, percentile, sample size, and simulation design.
Out-of-sample reconstructionEvaluate error on data not used for fitting.Avoid leakage from centering and scaling; repeated splits are useful.
Substantive objectiveRetain 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
Recalculated results: correlation matrix of ten variables and 23 active observations.
ComponentEigenvalueVariance (%)Cumulative (%)
PC14.124241.2441.24
PC21.838518.3959.63
PC31.239112.3972.02
PC40.81948.1980.21
PC50.70167.0287.23
PC60.42294.2391.46
PC70.30263.0394.48
PC80.27452.7497.23
PC90.15521.5598.78
PC100.12201.22100.00
The first three decathlon components explain 72.02 percent; permutation parallel analysis retains one in this run. 1 2 3 4 5 6 7 8 9 10 Component 0 5 10 15 20 25 30 35 40 Variance explained (%) 41.2 18.4 12.4 Decathlon: scree plot 1 2 3 4 5 6 7 8 9 10 Component 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 Eigenvalue Kaiser and parallel analysis Observed eigenvalues 95th percentile of permutations
Figure 2. The first three eigenvalues exceed one and together account for 72.02%. In the parallel analysis performed here, only the first eigenvalue exceeds its reference threshold. The parallel threshold comes from 500 independent column permutations, using the 95th percentile and seed 20261113.

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.”

Contribution and representation are distinct measures. Contributions to any one component sum to 100% across variables.
VariableCorrelation with PC1Contribution to PC1 (%)Represented in PC1–PC3 (%)
X100m-0.85117.5484.67
Long.jump0.79415.2974.59
Shot.put0.73413.0681.38
High.jump0.6109.0269.76
X400m-0.70211.9465.68
X110m.hurdle-0.76414.1678.60
Discus0.74313.3958.60
Pole.vault-0.2171.1470.80
Javeline0.4284.4569.74
X1500m0.0040.0066.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.

Athlete scores and correlation circle for ten events: points represent individuals and arrows represent variables. −4 −2 0 2 4 PC1 · 41.24 % −2 −1 0 1 2 PC2 · 18.39 % CLAY SEBRLE BOURGUIGNON Scores for 23 athletes −1.0 −0.5 0.0 0.5 1.0 Correlation with PC1 −1.0 −0.5 0.0 0.5 1.0 Correlation with PC2 X100m Long.jump Shot.put High.jump X400m X110m.hurdle Discus Pole.vault Javeline X1500m Variables: correlation circle
Figure 3. Points in the left panel are athletes, and their distances refer to the retained plane. Arrows in the right panel are correlations between variables and components. Selected athletes are labeled to preserve legibility; the full scores are available through 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: 1

This 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.

Reading guide: similar-looking plots do not necessarily represent the same object.
OutputObject representedInterpretation
Scree plotEigenvalues or percentages, depending on the chosen scale.Assess how variation is distributed among components.
ScoresCoordinates of observations on components.Examine patterns, separations, and distant observations; report how much variance the plane retains.
Coefficients or loadingsVariable weights or variable–component correlations.Check the software convention first. These are not observation scores.
Correlation circleCorrelations of variables with axes.Interpret angles as approximations to relationships when the variables are well represented in the plane.
BiplotObservations and variables in a joint representation.State the scaling. Do not give the same meaning to every distance between different kinds of objects.
ContributionsParticipation of observations or variables in an axis.Check which is displayed and which denominator is used.
Squared cosineQuality 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.

Di2=(xi−x¯)TS−1(xi−x¯)=∑j=1ptij2λj
(14) Squared Mahalanobis distance, with invertible S and all components having positive variance.

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.

Wk=∑g=1k∑i∈Cg‖zi−μg‖22,μg=1|Cg|∑i∈Cgzi
(15) K-means objective in the variables or coordinates z chosen for the analysis.

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).

TSS=Wk+Bk,Bk=∑g=1k|Cg|‖μg−z¯‖22
(16) Total sum of squares decomposes into within-cluster and between-cluster variation.

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.

All silhouettes in this table use the same Euclidean distance in the four standardized variables.
Number of clustersWithin-cluster sum WBetween-cluster sum BMean silhouette
2102.862493.13760.4085
378.3233117.67670.3094
456.4032139.59680.3397
548.9442147.05580.3031
642.8330153.16700.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.

K-means on the four standardized USArrests variables, shown in two components; the mean silhouette in the original space is 0.4085. −3 −2 −1 0 1 2 3 PC1 · 62.01 % −2.5 −2.0 −1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 PC2 · 24.74 % California Florida Alaska North Carolina Vermont New York Clusters fitted using four variables Cluster 1 Cluster 2 0.0 0.1 0.2 0.3 0.4 0.5 0.6 Silhouette calculated in four variables 1 2 Mean: 0.4085 Cohesion and separation for each state
Figure 4. The partition was computed with four variables; the two coordinates in the left panel are used for visualization. The silhouette in the right panel uses all four variables, so it is not estimated from the two-dimensional drawing. Cluster numbers may be interchanged between equivalent runs.

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):

s(i)=b(i)−a(i)max{a(i),b(i)},−1≤s(i)≤1
(17) Set s(i)=0 for singleton clusters. The degenerate case a=b=0 also requires an explicit convention.

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 run
k^=min{k:Gap(k)≥Gap(k+1)−sk+1}
(18) The one-standard-error rule of Tibshirani and colleagues, applied to consecutive candidates.
Silhouette and gap comparison: the one-standard-error rule selects two clusters even though the absolute gap maximum occurs at four. 2 3 4 5 6 Number of clusters 0.20 0.25 0.30 0.35 0.40 0.45 Mean silhouette From k = 2 to k = 6, k = 2 performs best 1 2 3 4 5 6 Number of clusters 0.3 0.4 0.5 0.6 Gap ± simulation error One-standard-error rule: k = 2
Figure 5. The specified rule selects k=2. The absolute gap maximum occurs at k=4; simply reporting that “the software chose the optimum” would therefore conceal a relevant decision. Error bars represent SE.sim, which incorporates simulation variability according to R’s implementation.

11.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.

Distance between observations and linkage criterion are separate decisions.
LinkageBetween-cluster criterionMeaning of height
SingleMinimum dissimilarity between a pair of members of the two groups.Dissimilarity of the pair enabling the merge; can produce chaining.
CompleteMaximum dissimilarity between members of the two groups.Criterion based on extreme separation between groups.
AverageMean dissimilarity across pairs of members from the two groups.Average dissimilarity at the merge.
WardIncrease 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])
Ward dendrogram on four standardized variables, with a cut producing two disjoint clusters. Alabama Louisiana Georgia Tennessee North Carolina Mississippi South Carolina Texas Illinois New York Florida Arizona Michigan Maryland New Mexico Alaska Colorado California Nevada South Dakota West Virginia North Dakota Vermont Idaho Montana Nebraska Minnesota Wisconsin Maine Iowa New Hampshire Virginia Wyoming Arkansas Kentucky Delaware Massachusetts New Jersey Connecticut Rhode Island Missouri Oregon Washington Oklahoma Indiana Kansas Ohio Pennsylvania Hawaii Utah 0 2 4 6 8 10 12 14 Merge height · Ward Cut producing two clusters USArrests · Euclidean distance and Ward criterion
Figure 6. Heights correspond to Ward’s implementation on standardized variables. The indicated cut produces two clusters; it does not mean that each height is an original Euclidean distance between two states.
Silhouettes are evaluated in different geometries; their magnitudes do not provide a universal ranking of algorithms. ARI compares labels on the same 50 observations.
Configuration, k = 2Silhouette in its dissimilarityARI relative to Euclidean k-means
Ward.D2 / Euclidean0.40480.9199
Average / 1-r0.65650.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.

Classification by axioms and domain avoids confusing similarity, distance, and geometric structure.
MeasureProperty and domainCaution
Euclidean and Minkowski with p ≥ 1Metrics on the corresponding vector space.Scales and weights determine the geometry.
Correlation rAn association coefficient, usually between −1 and 1.Not a distance by itself.
1 − rDissimilarity 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 coefficientsCompare 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.
PseudometricMay assign zero distance to distinct objects while retaining the other usual metric properties.The representation may identify differences considered irrelevant to the analysis.
QuasimetricAllows 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.

ARI adjusts for agreements expected by chance: 1 indicates identical partitions, apart from label names.
Space used for clusteringVariance retained (%)Silhouette in that spaceSilhouette in 4 variablesARI versus original
Four variables100.000.40850.40851.000
PC162.010.64680.40851.000
PC1-PC286.750.47580.40851.000
PC1-PC395.660.43080.40851.000
PC1-PC4100.000.40850.40851.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.

PC1 retains 97.90 percent of the variance of two horizontal bands but completely removes the category difference defined by Y. −10.0 −7.5 −5.0 −2.5 0.0 2.5 5.0 7.5 10.0 X: high dispersion −1.5 −1.0 −0.5 0.0 0.5 1.0 1.5 Y: contrast between categories Two categories defined by Y Category y = -1 Category y = 1 −10.0 −7.5 −5.0 −2.5 0.0 2.5 5.0 7.5 10.0 PC1 = X The two categories overlap point for point. PC1 retains 97.90% but loses the contrast
Figure 7. Categories are defined beforehand by Y to study a specific contrast; they are not claimed to be the optimal k-means partition. The example shows that maximizing variance and preserving a substantive contrast can diverge.

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, 0<ε<1, and a failure tolerance 0<δ<1. Random linear constructions exist for which a dimension of order m=O(ε−2log(N/δ)) suffices to preserve distances simultaneously with probability at least 1−δ. A common formulation controls squared distances:

(1−ε)‖xi−xj‖22≤‖f(xi)−f(xj)‖22≤(1+ε)‖xi−xj‖22
(19) The guarantee is required for every pair in the finite set. Taking square roots changes the factors to √(1−ε) and √(1+ε).

The historical formulation with factors 1±ε on ordinary distances has the same dimensional order after adjusting constants. The Gaussian construction uses f(x)=Rx/m, 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")
Gaussian projection from eight hundred to one hundred twenty dimensions for eighty points, comparing all 3,160 pairwise distances. 30 35 40 45 50 Original distance · 800 dimensions 30 35 40 45 50 Projected distance · 120 dimensions Gaussian projection: 80 points 0.7 0.8 0.9 1.0 1.1 1.2 Projected / original distance 0 50 100 150 200 250 300 350 Number of pairs Empirical distortion of 3,160 pairs
Figure 8. In this realization, projected/original distance ratios range from 0.7217 to 1.2476. The maximum relative distance error is 27.83%. These are empirical results for 3,160 pairs, not proof that this dimension satisfies any chosen tolerance and probability.

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 L(v,λ)=vTSv−λ(vTv−1). Differentiation with respect to v gives 2Sv−2λv=0. Writing a unit vector in an orthonormal eigenvector basis, v=∑jajvj with ∑jaj2=1, gives vTSv=∑jλjaj2≤λ1. Equality is attained along a direction of the largest eigenvalue. Subject to orthogonality to earlier directions, the same argument yields subsequent directions.

Cov(Xcvi,Xcvj)=viTSvj=λjviTvj
(20) Covariance is zero for i≠j and equals λⱼ for i=j.

For any rank-k orthogonal projector P, orthogonality of its parts gives ‖Xc‖F2=‖XcP‖F2+‖Xc(I−P)‖F2. 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 XcTXc=VΣTΣVT 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 I=∫−∞∞e−x2/2dx. Squaring and changing to polar coordinates:

I2=∫R2e−(x2+y2)/2dxdy=2π∫0∞re−r2/2dr=2π
(21) Since I>0, I=√(2π). The standard-normal density is e^(−x²/2)/√(2π).

If Z1,…,Zp are independent standard-normal variables, the moment-generating function of Y=∑jajZj is:

E[etY]=∏jE[etajZj]=∏jet2aj2/2=et2‖a‖22/2
(22) The product of expectations uses independence. Linearity of expectation alone does not justify that step.

Thus Y is normally distributed with mean zero and variance ‖a‖22. 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 EetY≤eK2t2/2 for every real t. Applying Markov’s inequality to the exponential and minimizing over t>0 gives:

Pr(Y≥u)≤inft>0exp(−tu+K2t2/2)=exp(−u2/(2K2))
(23) Applying the same argument to −Y gives a two-sided bound with factor 2.

Rademacher variables, taking +1 and −1 with probability 1/2 each, satisfy EetY=cosh(t)≤et2/2. 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 f(x)=Rx/m, 2-stability implies that m‖f(x)‖22/‖x‖22 has a chi-squared distribution with m degrees of freedom.

Eet(Z2−1)=e−t(1−2t)−1/2,t<1/2
(24) Moment-generating function of a centered squared standard-normal variable. It controls a sum of m independent squares.

Applying exponential Markov bounds to both tails and using logarithmic inequalities gives, for 0<ε<1, the bound:

Pr(|‖f(x)‖22‖x‖22−1|>ε)≤2exp[−m(ε24−ε36)]
(25) Control for a fixed vector. The zero vector satisfies preservation trivially.

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:

m≥log(N(N−1)/δ)ε2/4−ε3/6
(26) A sufficient condition from this proof for failure probability at most δ. The bound is not asserted to be necessary.

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 Yi=∑jRijaj 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 ∑jaj2=1.

The next step controls Zi=Yi2−1. Integrating a two-sided tail bound Pr(|Yi|>t)≤2e−ct2 gives E|Yi|2q≤2q!c−q. Consequently, there is a uniform constant L such that E|Zi|q≤q!Lq for q≥2.

EeuZi≤1+∑q≥2|u|qLq≤exp(2L2u2),|u|≤12L
(27) The linear term vanishes exactly because E[Zᵢ]=0; the remaining series is bounded by a geometric series.

Row independence allows these bounds to be multiplied for the sum of the Zi. Another Chernoff argument yields a failure probability bounded by 2e−c0mε2 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 1/|Cg| on group members and zero elsewhere. Then HTH=I, and reconstruction through centroids is HHTXc. Between-cluster explained variation equals tr(HTXcXcTH).

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:

Bk≤(n−1)∑j=1k−1λj,Wk≥(n−1)∑j≥kλj
(28) Add zero eigenvalues if needed. The bound concerns the objective and does not automatically identify the optimal partition.

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 v=ETt/(tTt), normalization of v, and the update t=Ev until convergence. It then deflates using E←E−tvT and seeks the next component. Component variance is obtained from tTt/(n−1).

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.

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 PDF

End of study · Geometry, representation, and interpretation of data.


Discover more from Marxist Philosophy of Science

Subscribe to get the latest posts sent to your email.

Follow the blogSeguí al blog

Comments

Leave a Comment/Deja un Comentario