Rotate the line
Rotate the line through the centroid until the points spread out along it as much as they can. Watch both readouts as you go.
Projection and perpendicular residuals through the centroid
- Spread along the line
- 6.181818
- Spread away from the line
- 5.000000
- Total
- 11.181818 constant
- Sum squared along
- 68.000000
- Sum squared away
- 55.000000
- Total squared deviations
- 123.000000 constant
- Direction
- 0.00 degrees
Sum squared along the line plus sum squared away from it is 123.000000 for this built-in cloud, whatever direction you choose.
Projection and perpendicular residuals through the centroid
- Spread along the line
- 9.904304
- Spread away from the line
- 1.277515
- Total
- 11.181818 constant
- Sum squared along
- 108.947339
- Sum squared away
- 14.052661
- Total squared deviations
- 123.000000 constant
- Direction
- 41.06 degrees
That is the maximal direction, at 41.06 degrees.
These published figures and readouts are complete without JavaScript.
That line is an eigenvector
Drag v until Av points along the same line as v. Two directions work, and one of them is the line you already found.
A vector and its image under the current matrix
- Classification
- two distinct real eigenvalues
- v
- (1.000000, 0.000000)
- Av
- (6.181818, 4.272727)
- Length of Av
- 7.514724
- Alignment signal
- 34.3%
The covariance matrix is symmetric, so its eigenvectors are at right angles and reconstruct it as V diag(lambda) V transpose.
Two directions, ranked
Line up both axes at once. You are looking for the angle where covariance between the two projected coordinates reaches zero.
Two orthogonal directions and their variance shares
- Variance along axis 1
- 6.181818
- Variance along axis 2
- 5.000000
- Covariance between projected coordinates
- 4.272727
At 41.063 degrees the variances are 9.904304 and 1.277515 and their cross covariance is zero. Normalizing those eigenvalues gives the explained-variance shares.
The sign of a component
If v is an eigenvector then the vector pointing the other way is too. The calculator makes each component's largest-magnitude entry positive and lets you flip it deliberately.
Now do it with real data
Turn foods on and off and watch which countries separate. Every variable is grams per person per week, so covariance is the starting basis.
PC2 against PC1
- Foods in the analysis
- 17
- Components available
- min(4 - 1, 17) = 3
- PC1 variance
- 67.4%
| Food | Coefficient on PC1 |
|---|---|
| Fresh fruit | 0.6326409 |
| Alcoholic drinks | 0.4639682 |
| Fresh potatoes | -0.4014021 |
| Other meat | 0.2589167 |
| Other Veg | 0.2435937 |
| Soft drinks | -0.2322441 |
| Fresh Veg | 0.1518499 |
| Fish | 0.0844150 |
| Cheese | 0.0569554 |
| Carcass meat | -0.0479276 |
| Cereals | 0.0477029 |
| Sugars | 0.0376210 |
| Processed Veg | 0.0364883 |
| Confectionery | 0.0296502 |
| Processed potatoes | 0.0268862 |
| Beverages | 0.0261878 |
| Fats and oils | 0.0051936 |
Multiply a coefficient by the square root of its eigenvalue and you get the loading, which is what the calculator prints beside this column.
Northern Ireland sits alone at one end of PC1. Fresh fruit, alcoholic drinks and fresh potatoes carry the largest coefficients.
When PCA does not work
Move the sample size and watch which of these four problems more observations fix.
One control, four panels. They all redraw together.
A condition PCA does not repair
- Scenario
- unstandardized
- Observations
- 60
- PC1 variance
- 100.0%
A condition PCA does not repair
- Scenario
- near-tie
- Observations
- 60
- PC1 variance
- 56.3%
A condition PCA does not repair
- Scenario
- n-less-than-p
- Observations
- 60
- PC1 variance
- 21.7%
- Components available
- min(60 - 1, 6) = 6
A condition PCA does not repair
- Scenario
- nonlinear
- Observations
- 60
- PC1 variance
- 57.1%
What PCA is and is not for
Regression predicts a response and measures vertical error. PCA has no response and measures perpendicular error. Factor analysis and nonlinear embeddings ask different questions.
This page takes no data. Nothing here has a paste box, because every figure exists to make one idea move. When you have your own table, the PCA calculator runs the decomposition and names every convention it used.