The geometry of correlation
Centre a variable's observations and scale them to length 1, and the variable becomes an arrow. The correlation of two variables is the cosine of the angle between their arrows. So a table of correlations is a table of angles, and it is a valid correlation matrix (positive semidefinite) exactly when some set of arrows has those angles. Each panel below turns one consequence of that into something you can rotate and push against.
1 A variable is an arrow
Take n observations of two variables, A and B. Subtract each variable's mean and divide what is left by its length: each variable is now an arrow of length 1 in n-dimensional observation space, one axis per observation. The dot product of the two arrows is Pearson's r, so r = cos θ for the angle θ between them. Centring puts every arrow on the plane where the coordinates sum to 0. With three observations that plane cuts the sphere in a great circle; with two, only two arrows are left.
Edit a value, or drag a numbered point in the scatterplot. The arrows ignore the variables' means and scales: shifting or stretching B leaves its arrow, and r, unchanged.
2 Fixing a correlation draws a cone
Give a third variable, C, correlation rBC with B. C's arrow must be at angle cos⁻¹ rBC from B's, so it lies on a cone around B. With three observations C must also lie on the great circle, and the cone meets the circle at only two points, C₁ and C₂: B turned by that angle one way or the other. Any other variable A then has one of exactly two correlations with C. Each extra observation adds a dimension, so with four the two points become a circle of choices.
These two values are the ends of the interval in panel 3. With only three observations the three arrows share a plane, so rAC can only be at an end.
3 The cosine rule: which rAC are possible?
Now let the arrows use as many dimensions as they need. Fix rAB = cos α and rBC = cos β. C can sit anywhere on the cone of angle β around B. As it goes round, it comes closest to A on A's side of B, at angle |α − β|, and is farthest on the opposite side, at α + β. So rAC lies between cos(α + β) and cos(α − β), which is rABrBC ± √((1 − rAB²)(1 − rBC²)). The bound comes from adding angles, not correlations.
0° puts C on A's side of B (largest rAC), 180° opposite (smallest).
det R = 1 − rAB² − rBC² − rAC² + 2rABrBCrAC as rAC varies: the squared volume of the box the arrows span. It is 0 at both ends of the bar, largest at its centre rABrBC (◇), and negative outside, where no arrows exist. The dot is C's current value.
4 How far apart can k arrows be?
Two arrows can point opposite ways, r = −1. Three can be at most 120° apart in pairs (r = −½), four at most 109.5° (r = −⅓, the corners of a tetrahedron). In general k arrows can all have correlation r only if r ≥ −1/(k − 1). At that limit they are the vertices of a regular simplex centred on the origin, and they add up to zero. Agreement is easy; mutual disagreement is not.
Eigenvalues
5 One entry's room to move
Fix every entry of a correlation matrix but one. The free entry, rij, can still move within an interval: its centre is riᵀS⁻¹rj and its half-width √((1 − riᵀS⁻¹ri)(1 − rjᵀS⁻¹rj)), where S holds the correlations among the other variables and ri, rj their correlations with i and j. The half-width is the product of the parts of the two arrows that the others leave unexplained, and the centre is the value that makes det R largest. Choose a cell to see its interval; edit any entry to move it.
Used by the button below and by the sample curve under the matrix.
Each cell is shaded by its interval's width (the stronger the blue, the more room), with the width under its value. The chosen cell is outlined and marked ●.
Expected room as variables are added
Expected width of one entry's interval in a p × p matrix, both scales logarithmic. Drawn uniformly from all correlation matrices (LKJ with η = 1), the room shrinks steadily as the other variables explain more of each arrow. The sample correlation matrix of n observations of independent variables shrinks faster: its arrows live in n − 1 dimensions, so it is singular once p ≥ n. At p = n every entry sits at one end of its interval, and from p = n + 1 every interval has width 0: each entry is fixed by the rest. The diamond is the matrix above (its mean width over all cells).
6 Estimating a noisy pair
Only 12 people have both A and C measured. Can six other variables help recover their correlation? Vary how precisely the other pairs are measured and how much the neighbors explain about A and C.
Target error at the selected sample size
How the estimates are fitted
The pairwise estimate uses only the 12 A–C observations. The two joint estimates find the closest positive-semidefinite correlation matrix by minimizing squared changes to all 28 sample correlations. One weights every pair equally. The other weights each pair by its sample size minus three, so a well-measured pair is more costly to move. At equal sample sizes the two fits coincide.
The six neighbors are independent Gaussian variables. A and C each have the selected R² against them. Their residual correlation varies uniformly from −0.8 to 0.8 across populations. Increasing sample size adds respondents to the other pair studies and keeps the target observations fixed.
What would an informative spectral prior add?
The fits above use the PSD constraint alone. A Bayesian model can also express how much variation a few directions are likely to explain. The eight eigenvalues of a correlation matrix sum to eight, so dividing each by eight gives eight shares on a simplex. A prior on the ordered shares can favor one dominant direction, several, or a flatter spectrum. LKJ(1) gives equal density to valid correlation matrices and induces its own distribution on those shares.
Variance by direction
How it works
Why the arrows exist
Centring a variable's n values gives a vector whose entries sum to 0; dividing by its length gives a unit vector. Pearson's r is the sum of products of two such vectors, their dot product, so it is the cosine of the angle between them. A correlation matrix is the Gram matrix of its variables' arrows, which is why it must be positive semidefinite: xᵀRx is the squared length of a combination of arrows. Conversely, any positive semidefinite matrix with 1s on the diagonal is the Gram matrix of some unit arrows, given enough dimensions.
Determinants are squared volumes
det R is the squared volume of the parallelotope the arrows span (√det R is the volume). It is 1 when the arrows are at right angles and 0 when they are linearly dependent, which happens when the matrix sits on the boundary of the positive semidefinite set.
Counting dimensions
With n observations, the centred arrows live in n − 1 dimensions. A full-rank set of p arrows needs p ≤ n − 1, so a sample correlation matrix is singular whenever p ≥ n. With three observations the arrows have two dimensions to share, which is why panel 2's cone meets the circle in exactly two points; with n observations the arrows at a fixed angle to one arrow form a sphere of dimension n − 3.
The intervals
For one entry, write det R as det S × [(1 − a)(1 − b) − (rij − c)²], with a, b and c the quadratic forms in the panel 5 formula. The bracket is a downward parabola in rij, so the entry's interval is where it is non-negative. When the other variables are themselves linearly dependent the page uses the pseudo-inverse of S, which gives the same interval. The expected widths are exact: in a uniform matrix, the parts of i and j the others leave unexplained are independent products of independent Beta-distributed partial correlations (the C-vine of Lewandowski, Kurowicka and Joe, 2009); in a sample matrix each is Beta((n − p + 1)/2, (p − 2)/2). The API provides the same computations.