Algebra

The nearest point is not the best guess

Measure ten unrelated quantities once each, with noise, and report the measurements. Nothing seems better. Yet pulling all ten towards nought by an amount the data choose gives a smaller total error whatever the true values are — in three dimensions or more, and never in one or two. The reason is a right angle: in many dimensions noise is nearly perpendicular to the truth, so a measurement is always too long, and the best correction is the shadow of the truth on it.

Worth reading first: The nearest point of a flat thing · The dot product is a shadow.

The nearest point of a flat thing turned an unanswerable question into a shadow. A set of measurements that no line passes through has, nevertheless, a nearest point on the space of lines, and that nearest point is the orthogonal projection of the data — the least-squares fit. Its whole justification was geometric: among all the points the model allows, report the one closest to what was seen.

This essay takes the simplest case of that rule, where the model allows everything. Suppose there are pp unknown numbers θ1,…,θp\theta_1, \ldots, \theta_p and each is measured once, with an error that is normally distributed, of mean nought and variance one, independently of the others. The measurements form a point XX in pp-dimensional space, and the unknowns form a point θ\theta. The model says θ\theta could be anywhere, so the nearest allowed point to XX is XX itself. Report the measurements. It is hard to see what else anybody could do, and for two centuries nobody did anything else.

In 1956 Charles Stein proved that in three or more dimensions this is a mistake — that there is another rule which, measured by the total squared error, is better than reporting XX whatever θ\theta is. In 1961 he and Willard James wrote one down.

Shrinking beats the nearest point at every true mean. p=3: ratio at |θ|²/p = 0, 1, 5: 0.667, 0.863, 0.976; p=5: ratio at |θ|²/p = 0, 1, 5: 0.400, 0.732, 0.931; p=10: ratio at |θ|²/p = 0, 1, 5: 0.200, 0.621, 0.886; p=25: ratio at |θ|²/p = 0, 1, 5: 0.080, 0.549, 0.855
Fig. 1 The expected total squared error of the James–Stein estimate, as a share of the measurement’s, for 3, 5, 10 and 25 unknowns, against how far the truth is from the origin. Every curve stays below the flat line of the measurement itself.

A rule that cannot lose, and then loses

The measurement XX is about as respectable as an estimate can be. It is unbiased: its average, over repeated measurement, is exactly θ\theta. It is the maximum-likelihood estimate. It is the least-squares estimate. Its expected squared error, E ∣X−θ∣2\mathbb{E}\,|X - \theta|^2, is the sum of the pp variances, which is exactly pp, and that number does not depend on θ\theta at all — the flat line in the figure. And in one dimension it is provably impossible to beat: any rule that does better than XX for some value of θ\theta does worse for another.

James and Stein’s rule is

θ^JS=(1−p−2∣X∣2)X.\hat\theta_{\text{JS}} = \left(1 - \frac{p - 2}{|X|^2}\right) X .

It takes the measurement and pulls it straight towards the origin, by a fraction that depends on how long the measurement is: a short XX is pulled hard, a long one hardly at all. Its expected squared error can be computed exactly. The squared length ∣X∣2|X|^2 is a sum of squares of normal variables with means θi\theta_i, a non-central chi-square, and the error of the rule works out to

E ∣θ^JS−θ∣2=p−(p−2)2 E ⁣[1∣X∣2],\mathbb{E}\,|\hat\theta_{\text{JS}} - \theta|^2 = p - (p - 2)^2\, \mathbb{E}\!\left[\frac{1}{|X|^2}\right],

where the last expectation is a sum of terms 1/(p−2+2k)1/(p - 2 + 2k) weighted by a Poisson distribution of mean ∣θ∣2/2|\theta|^2/2. The figure sums that series. Because the subtracted term is positive, every curve lies below pp, at every θ\theta.

The gain depends on where the truth is. When θ\theta is at the origin the error is exactly 22, in every dimension, so with ten unknowns the shrunk estimate has a fifth of the measurement’s error and with twenty-five unknowns a twelfth. When θ\theta is far from the origin the gain fades towards nothing. But it never becomes a loss, and that one-sidedness is what makes the result a paradox rather than a trade-off. A statistician who uses XX is choosing a rule that is beaten everywhere, which in the language of the subject makes XX inadmissible.

Why the measurement is too long

The first step to understanding the rule is to notice that XX is systematically too long. Its expected squared length is

E ∣X∣2=∣θ∣2+p,\mathbb{E}\,|X|^2 = |\theta|^2 + p,

since each coordinate contributes θi2\theta_i^2 plus a variance of one. The measurement points roughly the right way and overshoots. In one dimension the overshoot is a single unit of variance against whatever θ2\theta^2 is; in a hundred dimensions it is a hundred units, and unless the truth is very large, most of the measurement’s length is noise.

The geometry is worth seeing directly, because it is what turns the formula into a picture. The noise X−θX - \theta is a random vector with independent coordinates, and in many dimensions a random vector is nearly perpendicular to any fixed direction. That is the phenomenon of a sphere that is nearly all equator: measured from any pole, almost all of a high-dimensional sphere’s surface lies within a thin band around the equator, so a random direction makes an angle near ninety degrees with any given one. The noise’s component along θ\theta is a single normal variable of size about one, while its full length is about p\sqrt p.

So the three points 00, θ\theta and XX form, approximately, a right-angled triangle with the right angle at θ\theta. The figure draws one such triangle in the plane the three points span, for fifty unknowns.

The shrunk point is a shadow of the truth. p=50, |θ|=5, |X|²=78.82, best multiple 0.3785, James–Stein multiple 0.3910, errors 6.645 / 3.703 / 3.704.
Fig. 2 One measurement of fifty unknowns, drawn in the plane through the origin, the truth θ\theta and the measurement XX. The noise leaves θ\theta almost at a right angle, the foot of the perpendicular from θ\theta to the line through XX is the best multiple of XX, and the James–Stein point lands beside it.

This is a picture from the dot product is a shadow, with the roles of the arrows changed. The multiple of XX nearest to θ\theta is the shadow of θ\theta on the line through XX: the foot of the perpendicular dropped from θ\theta onto that line. Its length along XX is ⟨X,θ⟩/∣X∣2\langle X, \theta\rangle / |X|^2 times XX, and in the drawn example that factor is 0.379 — the best available correction shrinks the measurement to well under half its length. Nobody can compute that factor, because it needs θ\theta. But the right angle says what it approximately is. With the noise perpendicular to θ\theta, ⟨X,θ⟩≈∣θ∣2\langle X, \theta \rangle \approx |\theta|^2 and ∣X∣2≈∣θ∣2+p|X|^2 \approx |\theta|^2 + p, so

⟨X,θ⟩∣X∣2≈∣X∣2−p∣X∣2=1−p∣X∣2.\frac{\langle X, \theta\rangle}{|X|^2} \approx \frac{|X|^2 - p}{|X|^2} = 1 - \frac{p}{|X|^2}.

The unknown has cancelled. The shadow of the truth on the measurement can be read off the measurement’s own length, and the James–Stein rule is that reading, with pp adjusted to p−2p - 2. In the drawn example the rule shrinks by 0.391 against the shadow’s 0.379, and lands 3.70 from the truth where the measurement sat 6.65 away.

The window of shrinking that helps

The replacement of pp by p−2p - 2 comes from a calculation that is short enough to state. Try the general rule (1−a/∣X∣2)X(1 - a/|X|^2)X with any constant aa. Expanding its squared error and using an identity of Stein’s for normal variables — integration by parts in each coordinate, which converts the cross term ⟨X−θ,X/∣X∣2⟩\langle X - \theta, X/|X|^2 \rangle into (p−2)/∣X∣2(p - 2)/|X|^2 on average — gives

E ∣(1−a∣X∣2)X−θ∣2=p−(2a(p−2)−a2) E ⁣[1∣X∣2].\mathbb{E}\,\Big|\Big(1 - \frac{a}{|X|^2}\Big)X - \theta\Big|^2 = p - \big(2a(p - 2) - a^2\big)\, \mathbb{E}\!\left[\frac{1}{|X|^2}\right].

That is a parabola in aa, and the next figure draws it.

The window of shrinking that helps. p=3: best ratio 0.8634; p=4: best ratio 0.7838; p=6: best ratio 0.6963; p=10: best ratio 0.6209
Fig. 3 The error of the rule that shrinks by a/∣X∣2a/|X|^2, as a share of the measurement’s, against aa in units of p−2p - 2, for 3, 4, 6 and 10 unknowns and a truth with ∣θ∣2=p|\theta|^2 = p. Every curve dips below the measurement between nought and twice p−2p - 2, deepest at p−2p - 2.

The bracket 2a(p−2)−a22a(p - 2) - a^2 is positive for every aa strictly between 00 and 2(p−2)2(p - 2), so every one of those rules beats the measurement at every θ\theta, and the best constant in the family is the vertex of the parabola, a=p−2a = p - 2. That is the whole derivation of the James–Stein rule. At a=2(p−2)a = 2(p - 2) the bracket is nought again and the rule exactly ties the measurement — a curious fact that the figure checks — and beyond it shrinking does harm.

The geometric argument above said the right amount was pp, and the exact calculation says p−2p - 2. The difference is the price of using one noisy length to estimate how much of itself is noise: 1/∣X∣21/|X|^2 is not the reciprocal of its average, and the integration by parts accounts for that exactly. In large dimensions the two agree to within the noise, which is why the triangle is a fair picture of what the rule does.

Why it starts at three

When p=2p = 2, the window (0,2(p−2))(0, 2(p - 2)) is empty, and the formula offers no rule that helps. When p=1p = 1 or p=2p = 2 there is a deeper failure: E[1/∣X∣2]\mathbb{E}[1/|X|^2] is infinite, because a normal point in one or two dimensions lands near the origin often enough for the reciprocal of its squared length to have no average. Any rule of this shape then has infinite error. The paradox does not weaken gradually as the dimension falls; it switches off between two and three, and for one and two unknowns the measurement really is unbeatable.

That threshold has appeared before, and the coincidence is not one. A walk that comes home found that a random walk on a lattice returns to its starting point with certainty in one and two dimensions and escapes with positive probability in three. Lawrence Brown proved in 1971 that the two facts are the same fact. Whether an estimate of the mean of a normal vector is admissible — whether nothing beats it everywhere — can be translated into whether a particular diffusion process, built from the estimate, returns to where it started or wanders off for ever. For the plain measurement XX the process is ordinary Brownian motion, which is recurrent in one and two dimensions and transient in three or more. Stein’s paradox is the statistical shadow of Pólya’s theorem about walks.

The connection also explains why the origin can be any point. Nothing in the argument used the origin except as the place to shrink towards; shrinking towards any fixed point cc, by (p−2)/∣X−c∣2(p - 2)/|X - c|^2, has the same guarantee. A good choice of cc gives a large gain and a bad one a small gain, but no choice gives a loss.

Twenty thousand measurements at each distance

A formula this surprising deserves a check that shares nothing with it, of the kind pi from dropped needles made the standard one: generate the experiment many times and average. The next figure generates, for ten unknowns, twenty thousand measurements at each of seven distances of the truth from the origin, and averages the squared errors of three rules: the measurement itself, the James–Stein estimate, and its positive part, which uses max⁡ ⁣(0,1−(p−2)/∣X∣2)\max\!\big(0, 1 - (p - 2)/|X|^2\big) so that a very short measurement is pulled to the origin and no further.

Twenty thousand measurements at each distance. |θ|=0: 10.005 / 2.011 (exact 2.000) / 1.261; |θ|=1: 9.998 / 2.749 (exact 2.738) / 2.080; |θ|=2: 10.023 / 4.386 (exact 4.376) / 3.988; |θ|=3: 9.983 / 5.978 (exact 5.986) / 5.859; |θ|=4: 9.950 / 7.148 (exact 7.172) / 7.128; |θ|=6: 9.981 / 8.474 (exact 8.487) / 8.474; |θ|=8: 9.976 / 9.049 (exact 9.088) / 9.049
Fig. 4 Twenty thousand seeded measurements of ten unknowns at each distance of the truth from the origin, with the average squared error of the measurement, of James–Stein and of its positive part, and the exact series for James–Stein drawn through.

The averages land on the series, within their sampling error, at every distance: 2.01 against the exact 2 at the origin, 4.39 against 4.38 at distance two, 9.05 against 9.09 at distance eight. The measurement’s own average sits at ten throughout, as it must.

The positive part is the more instructive line. When ∣X∣2<p−2|X|^2 < p - 2 the James–Stein factor is negative, and the rule reflects the measurement through the origin — it reports a point on the far side of nought from what was seen, which no sensible procedure would do. Clamping the factor at nought removes that, and the squares in the figure show it helps most where the truth is near the origin, bringing the error there from 2.01 down to 1.26. So the rule that first exposed the measurement as inadmissible is itself inadmissible, beaten by an obvious repair. That is not a defect in the theorem. The theorem’s content is that the measurement can be beaten, and once that is known the question becomes how well, which has a long tail of refinements.

The total improves while one quantity worsens

The theorem is about the total squared error over all pp coordinates, and it is worth seeing what it does not say. The next figure puts one unknown far from nought and the other nine at nought, and measures the error coordinate by coordinate.

The total improves while one coordinate worsens. 1:2.386, 2:0.673, 3:0.678, 4:0.669, 5:0.685, 6:0.674, 7:0.669, 8:0.676, 9:0.675, 10:0.665; total 8.449.
Fig. 5 Ten unknowns, one of them equal to six and the rest nought, and the average squared error of the James–Stein estimate in each coordinate over 40,000 seeded measurements. The large one is estimated worse than its own measurement; the nine small ones better.

The large coordinate is dragged towards nought with the rest and is estimated worse, with an error of 2.39 against the measurement’s 1. The nine small ones are estimated better, at 0.67 each. The total, 8.45 against 10, is what the theorem is about. Nobody who cares about one particular quantity has been offered anything: for that quantity alone, the measurement is admissible, because it is a one-dimensional problem.

This is where the paradox earns its reputation. The ten unknowns need have nothing to do with each other — a price of tea, a rainfall, the mass of a beetle — and the rule still pools them, because its shrinking factor depends on the length of the whole vector. The joint estimate is better in total than ten separate ones, even though no physical connection links them. Bradley Efron and Carl Morris, who did most to explain the result to a wide audience, put the resolution plainly: the improvement is a statement about a sum of errors, and whether that sum is the right thing to minimise is a question about the purpose of the estimates, which the mathematics cannot settle.

Eighteen rates pulled towards their average

The version used in practice shrinks not towards a fixed point but towards the average of the measurements themselves. With pp measurements and their average Xˉ\bar X, the rule multiplies each measurement’s distance from Xˉ\bar X by 1−(p−3)σ2/S1 - (p - 3)\sigma^2/S, where S=∑(Xi−Xˉ)2S = \sum (X_i - \bar X)^2 is their spread and σ2\sigma^2 the noise variance. Subtracting the average is a projection: it removes each measurement’s component along the direction (1,1,…,1)(1, 1, \ldots, 1), exactly the single subtraction of one subtraction clears a direction, and leaves a vector in a space of one dimension fewer. The rule is James–Stein applied in that smaller space, so the guarantee now needs four or more measurements rather than three.

Eighteen rates pulled towards their average. shrink factor 0.3527; total squared error 0.01647 → 0.00881.
Fig. 6 Eighteen invented rates near 0.27, each measured once with noise of standard deviation 0.04, and each pulled towards the average of all eighteen. The pulled values sit nearer the true rates in total, and the extreme measurements are pulled furthest.

The figure is the shape of the famous example Efron and Morris used in 1975, built here from invented numbers rather than their data: eighteen success rates, each estimated from a small sample, so that the measured spread is largely noise. The shrinking factor comes out at 0.353 — the data say that roughly two-thirds of their own spread is noise — and the total squared error falls from 0.0165 to 0.0088, close to half. The rates that measured highest and lowest are pulled hardest, which is the formal version of regression towards the mean: an extreme measurement is extreme partly because its noise happened to be large, and regression is a square completed halfway drew the same pull for two correlated quantities.

Read this way, the rule has a second derivation. If the true rates were themselves drawn from a normal distribution around some centre, then Bayes’ theorem would give each one a posterior mean that is exactly a weighted average of its measurement and the centre, with weights set by the ratio of the noise variance to the spread of the rates. The James–Stein factor estimates that ratio from the data. Efron and Morris called this empirical Bayes: the prior is not assumed but read off the collection, and the paradox is the observation that this is possible only when there is a collection to read it off.

More coordinates make the shrinking exact

The right-angle argument was approximate, and the approximation improves with dimension. The last figure fixes the ratio ∣θ∣2/p|\theta|^2/p and lets the number of unknowns grow.

More coordinates make the shrinking exact. c=0.25: p=3 0.739, p=200 0.2083, oracle 0.2000; c=1: p=3 0.863, p=200 0.5062, oracle 0.5000; c=4: p=3 0.969, p=200 0.8033, oracle 0.8000
Fig. 7 The James–Stein error as a share of the measurement’s, for truths with ∣θ∣2|\theta|^2 equal to a quarter of pp, to pp and to four times pp, as the number of unknowns grows from 3 to 200. The curves settle on the dashed lines, the error of the best multiple of XX.

The dashed lines are what an oracle would achieve if it knew ∣θ∣|\theta| and used the best fixed multiple of XX, which is ∣θ∣2/(∣θ∣2+p)|\theta|^2/(|\theta|^2 + p) and gives an error of that same share of pp. As pp grows the James–Stein curves fall onto those lines. The reason is the average settling while the wobble does not: ∣X∣2/p|X|^2/p is an average of pp squared coordinates, and its fluctuation shrinks like 1/p1/\sqrt p — the same bound on how far an average strays from its mean that every concentration argument starts from. In two hundred dimensions the measurement’s length reveals, almost exactly, how much of it is signal, and estimating the oracle’s factor costs almost nothing.

The size of the gain is set by the ratio. With a weak signal, ∣θ∣2=p/4|\theta|^2 = p/4, the shrunk estimate has a fifth of the measurement’s error; with a strong one, ∣θ∣2=4p|\theta|^2 = 4p, it has four-fifths. Shrinking matters most exactly when the noise dominates, which is when a single measurement says least.

What a total of squared errors does not promise

The figures measure one thing, the expected total squared error, and the guarantee is about that quantity and no other. The coordinate-by-coordinate figure already showed one consequence: no individual coordinate is promised anything, and a coordinate far from where the rule shrinks is estimated worse. Two more limits are worth stating.

The first is the noise model. Everything above assumes the errors are normal, independent and of equal, known variance. With unequal variances, rules that beat the measurement everywhere still exist in three or more dimensions, but no single one is best and the formulas change; with heavy-tailed errors the length ∣X∣|X| no longer measures the noise reliably, because one wild coordinate can dominate it. The picture of a right-angled triangle is a picture of normal noise, whose coordinates are independent and individually small.

The second is the meaning of better. A rule that beats the measurement in expected squared error does not produce narrower honest error bars around each coordinate, and confidence statements built naively around the shrunk values are wrong in the coordinates that were pulled furthest. The figures show averages over repeated measurement, and an experimenter who measures once holds one draw, in which — as the shadow figure illustrates — the shrunk point is usually better and occasionally worse.

Still open: the best rule of this kind

The measurement is beaten by James–Stein, James–Stein is beaten by its positive part, and the positive part is itself inadmissible: Qiang Shao and William Strawderman exhibited in 1994 a rule that improves on it at every θ\theta, by a very small margin. The chain of improvements does not obviously end in a rule that is both admissible and simple. Admissible rules that beat the measurement do exist — Brown’s correspondence characterises them through the recurrence of their associated diffusions, and rules derived from suitable priors, such as Strawderman’s of 1971, are among them — but they are not of the elementary shrink-by-a-formula kind, and whether an admissible rule as simple as the positive part exists is a question that, as far as the literature records, has no settled answer.

The practical question behind it is where to shrink to. The guarantee holds towards any point, the gain depends heavily on the choice, and the empirical-Bayes version chooses the average because that is what the data suggest. In problems with structure — rates that depend on a known covariate, measurements on a grid where neighbours resemble one another — the target can be a fitted model rather than a single number, and that is the nearest point of a flat thing returning one level up: shrink towards the projection of the measurements onto a model, by an amount the residuals choose. How to pick the model is not a theorem. What the right angle guarantees is only that, once there are three or more unknowns, refusing to shrink at all is never the best choice.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Concentration of measureEstimatorLeast squaresMonte CarloNormal distributionProjectionShrinkageUnbiased estimator