Express a regularised fit as a map on measured data
Let whitened observations \(y\in\mathbb R^n\) be modelled by \(Ax\), and for \(\lambda>0\) minimise \(\|Ax-y\|^2+\lambda\|x\|^2\). The minimiser satisfies
Predicted data are \(\hat y=H_\lambda y\), where \(H_\lambda=A(A^TA+\lambda I)^{-1}A^T\). This “hat” matrix maps the observations to their own fitted values. If \(A=U\Sigma V^T\), its nonzero eigenvalues are
Their sum \(d(\lambda)=\operatorname{tr}H_\lambda\) is an effective degrees-of-freedom count. A weakly determined direction with small singular value can contribute a fraction of an independently fitted parameter.
The norm of the training residual decreases or stays constant as the penalty weakens. For a square full-rank model it tends to zero as the penalty tends to zero, even with noisy data. Individual residuals can change in either direction. It does not measure out-of-sample error. Instead ask how well the fitted model predicts each observation when it was left out. Repeating the full solve \(n\) times conceptually works but wastes structure. An exact deletion identity gives each left-out residual \(r_i^{(-i)}=(y_i-\hat y_i)/(1-H_{ii})\), where \(H_{ii}\) is the observation's leverage. To derive the formula, remove row \(a_i^T\), subtracting \(a_i a_i^T\) from the penalised normal matrix. Multiplying its inverse update by the original residual along \(a_i\) gives the factor \(1/(1-a_i^TG^{-1}a_i)\), with \(G=A^TA+\lambda I\). This derivation assumes the same penalty strength in the objective for the held-out and full fits.
Replace individual influences by their average only once
The leave-one-out score is the mean of \([r_i/(1-H_{ii})]^2\). Generalised cross-validation replaces the individual diagonal elements by the common mean \(d/n\), giving
When every leverage is equal, this approximation reproduces leave-one-out exactly. Its expression is invariant to orthogonal transformations of the whitened data space because both trace and residual norm are invariant. Exact leave-one-observation-out instead depends on which physical observations are removed, which matters for a particular instrument arrangement. GCV is useful when a rotationally averaged prediction criterion is appropriate; it is not a universal interpretation of removing an actual sensor or predicting an unmeasured parameter direction.
Consider \(A=(1,1,1)^T\) fitting a scalar common signal, \(y=(1.1,0.9,1.0)\), and \(\lambda=1\). The fit is \(\hat x=3/4=0.75\), so residuals are \(0.35,0.15,0.25\). All leverages are \(1/4\). Exact prediction errors on deleting each datum are residuals divided by 0.75. For example removing 1.1 leaves \((0.9+1.0)/(2+1)=0.6333\), giving 0.4667 error, equal to \(0.35/0.75\). GCV equals exact leave-one-out here. Clear agreement in this symmetric scalar case should be a first numerical verification before interpreting a higher-dimensional score whose influences vary.
Background · What counts as an independent observation when validating?
Suppose each specimen is read twice on the same instrument, and its calibration offset changes only between specimens. Omitting one reading leaves its twin available to the fit. A low single-reading validation error then describes another reading of an already observed specimen. It can be optimistic for the next specimen, whose offset is unknown.
For an omitted group \(G\), the scalar denominator \(1-h_{ii}\) from leave-one-out becomes a small matrix. With fixed regularisation, unchanged data weights and squared loss, the group prediction residual satisfies
The off-diagonal entries account for the influence that the two readings exert on each other. If removing an entire group leaves a poorly constrained direction, the solve amplifies that direction. Match the omitted group to the intended future experiment before choosing a score.
See how one sensitive observation can dominate a fit
For another scalar design \(A=(1,1,4)^T\) with \(\lambda=2\), \(G=20\) and \(H_{ii}=(0.05,0.05,0.80)\). A residual on the third sensor is multiplied by five in a true deletion while the first two are amplified only slightly. GCV uses the same factor \(1/(1-0.9/3)=1.429\) for all. If the model discrepancy is concentrated in that high-leverage reading, trace averaging can underestimate the consequence of losing it. Conversely if errors fall only on low-leverage sensors it can overstate their delete-one loss. Inspecting the leverage distribution is inexpensive compared with attributing precision to a single scalar tuning criterion.
Whitening rotates and rescales observations when errors are correlated. Leaving out one row after a dense whitening transformation is generally not the same experiment as removing one physical sensor before whitening. A time-correlated series may demand holding out an entire time block so training data cannot predict a held-out noise realisation through short-range correlation. Predictive selection should specify whether the intended prediction concerns a new repeat at known conditions, a missing detector or a new range of the physical parameters. A penalty that works well for a data prediction need not minimise reconstruction error in a weakly observable component of \(x\).
When does using the average leverage change the answer?
Four sensors have sensitivity one. Their readings are 1.10, 0.90, 1.05 and 0.95. The fifth reading equals its sensitivity plus an adjustable offset. First give all five equal sensitivity. The two scores coincide even with a nonzero offset. Now set the fifth sensitivity to 5 and its offset to 0.8. At λ = 1, compare the fifth leverage with the mean leverage. Predict the fifth reading from the other four, then use this single omitted-sensor error to check which score can reach 0.66.
The OneSimulation model refits five separate reduced data sets for every penalty. The first CSV score therefore measures actual omitted-sensor predictions. Compare it point by point with the faster identity used in the browser.
Tutorial · recover two kinds of influence from one factorisation
Compute the symmetric-case score
Using the common-signal example, evaluate GCV and verify it by explicit deletion of all three observations.
Work through the solution
The residual squared sum is
Its mean divided by \(0.75^2\) gives 0.12296. The three exact predictive residuals are \(0.4667,0.2000,0.3333\); squaring and averaging reproduces 0.12296. The unit of this score is squared whitened observation units. Taking its square root gives an rms predicted datum error, not a standard deviation of the fitted underlying parameter.
Recover effective dimension from singular values
A whitened model has singular values \(4,1,0.1\) and six readings. For \(\lambda=1\), calculate \(d\) and the GCV multiplier applied to mean square residual.
Work through the solution
The gains are
Their sum is 1.4511 and \(1/[1-d/6]^2\simeq1.740\). The weak singular direction barely enters the prediction even though the algebraic rank is three. With vanishing penalty all three nonzero gains tend to one; with very large penalty they approach zero. This continuous change is why a count of nonzero columns cannot replace the trace in the score.
Diagnose misleading use of the diagonal basis
For \(A=I\) of size \(n\) and the same ridge penalty, compute GCV for every positive \(\lambda\). Can these data identify a preferred penalty from that score?
Work through the solution
Here \(H=I/(1+\lambda)\),
Cancellation gives \({\rm GCV}=\|y\|^2/n\), independent of \(\lambda\). Leaving one coordinate out leaves no data at all about that independent parameter, so the prediction by the penalised system for that coordinate is always zero. A numerical minimum created by roundoff does not select a meaningful smoothing strength. Structural correlations, replication, a noise model or external validation are needed to decide how much shrinkage helps the intended task.