Skip to content
Multivariate Lab

Assignment 1 · Problems 1(c)–2 · submitted 11 Sep 2023

Wheat seeds PCA explorer

Seventy X-ray-scanned kernels from each of three wheat varieties (Kama, Rosa and Canadian), each described by seven shape measurements. Principal components turn seven correlated measurements into a few uncorrelated summaries, and here two of them are enough to see the three varieties pull apart.

kernels
210
kernels
measurements
7
measurements
varieties
3
varieties

The data

Seven measurements, one label

The eighth column is the variety code 1–3. It is a category, not a measurement, so it is left out of the PCA and only used to colour the plots (Problem 2(a)).

Problem 2

Principal components, three ways

PCA finds orthogonal directions γ1,γ2,…\gamma_1,\gamma_2,\dots of decreasing variance λ1≥λ2≥⋯\lambda_1\ge\lambda_2\ge\cdots. The cumulative proportion ψk=∑j≤kλj/∑jλj\psi_k=\sum_{j\le k}\lambda_j/\sum_j\lambda_j tells how much of the total variance the first k components keep. Switch the variant to see what changes when the analysis is done on the covariance matrix (as asked), on the correlation matrix, or in the mixed way it was submitted.

Which analysis?

Every chart below is recomputed in your browser (Jacobi eigen-decomposition, 210 × 7).

What the question asked: PCA of S
On the raw scale, area (X1) and perimeter (X2) have by far the largest variances, so PC1 alone explains 82.9% of the total variance and is essentially a size component. This is the usual argument for standardising first, but it is a different analysis from the one requested.
Scree plot and cumulative variance ψ
Eigenvalues of S · bars: share of variance, line: ψ_k
PC1: λ = 10.79, 82.94% of variancePC2: λ = 2.129, 16.36% of variancePC3: λ = 0.07363, 0.57% of variancePC4: λ = 0.01289, 0.10% of variancePC5: λ = 0.002748, 0.02% of variancePC6: λ = 0.001570, 0.01% of variancePC7: λ = 0.00002966, 0.00% of varianceψ1 = 82.94%ψ2 = 99.30%ψ3 = 99.87%ψ4 = 99.97%ψ5 = 99.99%ψ6 = 100.00%ψ7 = 100.00%
PC1234567
λ10.82.130.07360.01290.002750.001573.0e-5
share82.9%16.4%0.6%0.1%0.0%0.0%0.0%
ψ82.9%99.3%99.9%100.0%100.0%100.0%100.0%
PC1 vs PC2 scores by variety
centred X × eigenvectors of S
  • Kama (variety 1)
  • Rosa (variety 2)
  • Canadian (variety 3)

Explain this projectionoptional · AI · your own key

Sends a numeric summary of PC1 vs PC2 (eigenvalues, bootstrap intervals, loadings, variety means) to Anthropic, never the kernel data. Its intervals use the default bootstrap (seed 90138, 1,000 resamples), whatever the settings below. What is sent

Correlation circle: PC1 and PC2
ρ(Xᵢ, PCⱼ) = γᵢⱼ √λⱼ / √sᵢᵢ
X1 Area: (0.998, 0.051)X2 Perimeter: (0.995, 0.063)X3 Compactness: (0.599, -0.179)X4 Kernel length: (0.953, 0.101)X5 Kernel width: (0.966, 0.009)X6 Asymmetry: (-0.279, 0.960)X7 Groove length: (0.862, 0.244)X1X2X3X4X5X6X7
Loadings γ (weights of each variable)
first three principal components; bar length = |γᵢⱼ|
Variableγ·1γ·2γ·3
X1 Area
0.884
0.101
-0.265
X2 Perimeter
0.395
0.056
0.283
X3 Compactness
0.004
-0.003
-0.059
X4 Kernel length
0.129
0.031
0.400
X5 Kernel width
0.111
0.002
-0.319
X6 Asymmetry
-0.128
0.989
-0.064
X7 Groove length
0.129
0.082
0.762

The coefficients do not depend on the kernel i; the scores PCᵢ = γᵀ(Xᵢ − μ) do. Signs of eigenvectors are arbitrary (here the largest entry is made positive; the as-submitted view uses the 2023 signs).

Problem 1(d)

S=ΓΛΓ⊤S=\Gamma\Lambda\Gamma^{\top} for the wheat data

The covariance-PCA eigenvalues are exactly the entries of Λ\Lambda below. Computed here with a Jacobi eigen-solver in TypeScript and checked against R's eigen(cov(X)) to 10 decimal places in the test suite.

Sample covariance S (7 × 7)

Cell shade ∝ |sᵢⱼ|. Area (X1) has variance 8.47 while compactness (X3) has 5.6e-4: four orders of magnitude apart.

X1X2X3X4X5X6X7
X18.4663.7780.0421.2251.067-1.0041.235
X23.7781.7060.0160.5630.466-0.4270.572
X30.0420.0165.6e-40.0040.007-0.0120.003
X41.2250.5630.0040.1960.144-0.1140.203
X51.0670.4660.0070.1440.143-0.1470.139
X6-1.004-0.427-0.012-0.114-0.1472.261-0.008
X71.2350.5720.0030.2030.139-0.0080.242

Λ: eigenvalues of S

  1. λ110.7933
  2. λ22.1295
  3. λ30.0736
  4. λ40.0129
  5. λ52.748e-3
  6. λ61.570e-3
  7. λ72.966e-5

Γ: orthonormal eigenvectors (columns)

γ1γ2γ3γ4γ5γ6γ7
X10.8840.101-0.2650.1990.137-0.281-0.025
X20.3950.0560.283-0.579-0.5750.3020.066
X30.004-0.003-0.0590.0580.0530.0450.994
X40.1290.0310.400-0.4360.7870.1130.001
X50.1110.002-0.3190.2340.1450.896-0.082
X6-0.1280.989-0.064-0.0250.002-0.0030.001
X70.1290.0820.7620.613-0.0880.1100.009

Check: max |ΓΛΓᵀ − S| = 1.8e-14 (R's round(S - S.sample) in the 2023 answer printed a matrix of zeros).

Reading the results
With the covariance matrix the first component is dominated by area and perimeter, the two variables with the largest raw variances. After standardising, three components keep about 98.7% of the variance (ψ₃), matching the submitted “keep 3 PCs” conclusion. Along PC1 (size) Rosa kernels are the largest and Canadian the smallest, with Kama in between; PC2 sets Canadian further apart because its kernels are the least compact and the most asymmetric.

Added in 2026 · uncertainty

How sure are we about these components?

The numbers above come from one sample of 210 kernels. To see how much they would move with a different sample, the kernels are resampled with replacement and the whole PCA is redone each time (the bootstrap). Parallel analysis then asks a different question: which eigenvalues are larger than those of data with the same variables but no correlation between them?

The original 2023 numbers are unchanged; this section adds intervals around them. Why the covariance PCA is the primary analysis here is recorded in DR-002.

Bootstrap settings

Kernels resampled with replacement, the whole PCA redone each time; 95% percentile intervals. Same seed, same numbers.

Covariance PCA · seed 90138 · 1,000 bootstrap resamples and 1,000 column permutations · n = 210 kernels

82.9%
variance on PC1
95% CI 79.8–85.9%
99.3%
cumulative ψ₂ (PC1 + PC2)
95% CI 99.2–99.4%
1
component beyond chance
parallel analysis (95th percentile); 1 with the null mean
Variance share with 95% intervals
bars: observed share; whiskers: bootstrap interval; diamonds: 95th percentile of the permutation null
PC1: 82.9% (95% CI 79.8–85.9%)PC2: 16.4% (95% CI 13.5–19.5%)PC3: 0.6% (95% CI 0.4–0.7%)PC4: 0.1% (95% CI 0.1–0.1%)PC5: 0.0% (95% CI 0.0–0.0%)PC6: 0.0% (95% CI 0.0–0.0%)PC7: 0.0% (95% CI 0.0–0.0%)PC1: 95th percentile of the null = 65.7% of the observed total variancePC2: 95th percentile of the null = 18.2% of the observed total variancePC3: 95th percentile of the null = 13.1% of the observed total variancePC4: 95th percentile of the null = 2.0% of the observed total variancePC5: 95th percentile of the null = 1.5% of the observed total variancePC6: 95th percentile of the null = 1.1% of the observed total variancePC7: 95th percentile of the null = 0.0% of the observed total variance
  • observed share
  • 95% bootstrap interval
  • parallel-analysis threshold
How many components?
four common rules, applied to the same eigenvalues
  • Cumulative share ψ ≥ 95%

    the rule used in 2023 (with the correlation PCA)

    2
  • Kaiser: λ > mean λ

    eigenvalue above the average eigenvalue

    2
  • Parallel analysis, null mean

    Horn's original threshold

    1
  • Parallel analysis, null 95th percentile

    stricter: only structure unlikely under no correlation

    1

Under the permutation null each variable keeps its own variance, so a component only counts if it captures shared structure. PC2 of S is almost entirely asymmetry (X6): one variable's variance rather than shared structure, so parallel analysis does not count it.

Loadings on PC1 with 95% bootstrap intervals
after sign alignment with the full-sample eigenvector; grey: interval includes 0
−1.0−0.50.00.51.0loading γArea (X1): 0.884 (0.873 to 0.891)Area (X1)0.884 (0.873 to 0.891)Perimeter (X2): 0.395 (0.389 to 0.401)Perimeter (X2)0.395 (0.389 to 0.401)Compactness (X3): 0.004 (0.004 to 0.005)Compactness (X3)0.004 (0.004 to 0.005)Kernel length (X4): 0.129 (0.123 to 0.134)Kernel length (X4)0.129 (0.123 to 0.134)Kernel width (X5): 0.111 (0.107 to 0.116)Kernel width (X5)0.111 (0.107 to 0.116)Asymmetry (X6): -0.128 (-0.202 to -0.056)Asymmetry (X6)-0.128 (-0.202 to -0.056)Groove length (X7): 0.129 (0.120 to 0.139)Groove length (X7)0.129 (0.120 to 0.139)
Stability of PC1: median |cos| between bootstrap and full-sample loadings = 1.000
All components
estimates with 95% bootstrap percentile intervals
PCλ (95% CI)share (95% CI)ψ (95% CI)null meannull 95th pctstability
PC110.8 (9.35–12.1)82.9% (79.8–85.9%)82.9% (79.8–85.9%)8.498.551.000
PC22.13 (1.71–2.49)16.4% (13.5–19.5%)99.3% (99.2–99.4%)2.282.361.000
PC30.0736 (0.0590–0.0866)0.6% (0.4–0.7%)99.9% (99.8–99.9%)1.671.710.999
PC40.0129 (0.0102–0.0155)0.1% (0.1–0.1%)100.0% (100.0–100.0%)0.2430.2560.999
PC52.7e-3 (2.1e-3–3.4e-3)0.0% (0.0–0.0%)100.0% (100.0–100.0%)0.1920.2000.995
PC61.6e-3 (1.2e-3–1.8e-3)0.0% (0.0–0.0%)100.0% (100.0–100.0%)0.1370.1410.996
PC73.0e-5 (2.1e-5–3.6e-5)0.0% (0.0–0.0%)100.0% (100.0–100.0%)5.4e-45.5e-41.000

Bold null threshold: the observed eigenvalue is above it. Stability is the median absolute cosine between each bootstrap eigenvector and the full-sample one; values near 1 mean the direction is well determined (sign alignment cannot repair components that swap order, and this column would reveal that).