Rotate away a new observation while preserving the objective
Suppose \(A\) has full column rank \(p\), observations \(b\), and an orthogonal factorisation has already transformed the upper part of the problem into \(Rx=z\) with upper-triangular \(R\). Lower transformed rows carry residuals but no coefficients. Because the transformations are orthogonal,
where \(s^2\) is the accumulated minimum residual sum of squares. Appending row \(a^T\) and response \(y\) requires minimising \(\|Rx-z\|^2+(a^Tx-y)^2+s^2\). One can update the small augmented triangle instead of reloading every original sample. This is particularly useful when storing raw observations is expensive and fits need refreshing repeatedly.
Write the new row directly below \([R\;z]\). At column \(j\), combine diagonal value \(r\) with bottom value \(q\) using a Givens rotation with \(c=r/\operatorname{hypot}(r,q),\ s=q/\operatorname{hypot}(r,q)\). Multiplication of the two selected rows by \(\bigl(\begin{smallmatrix}c&s\\-s&c\end{smallmatrix}\bigr)\) gives a nonnegative diagonal \(\sqrt{r^2+q^2}\) and zero in the bottom column. Apply the same rotation to every remaining column and to the right side. If both inputs vanish choose the identity and investigate numerical rank separately. A robust hypotenuse evaluation avoids overflow when \(r^2+q^2\) itself exceeds the available range even though its square root is representable.
After sweeping all \(p\) columns the bottom row is zero in coefficients and has transformed response \(\gamma\). The new triangular solve gives the updated fit and the minimum residual sum rises by \(\gamma^2\). Each step preserves a squared norm, so this identity is a direct independent audit of online accumulation. Weighted least squares fits into the same calculation by scaling the row and response by the square root of its weight first. Dynamic reweighting of historical observations is a different operation and generally requires preserved information about individual rows.
Use one-dimensional corrections for interpretation
The rank-one update also has a useful algebraic form without explicitly computing a dense inverse. Set \(G=A^TA\), \(w=G^{-1}a\) evaluated by two triangular solves with \(R\), and \(h=a^Tw\). After adding a point the normal matrix becomes \(G+aa^T\). Subtracting the old normal equations from the new ones gives \((G+aa^T)\delta x=a(y-a^Tx)\), so \(\delta x=w(y-a^Tx)/(1+h)\), since \((G+aa^T)w=(1+h)a\). The increment to residual sum of squares is \((y-a^Tx)^2/(1+h)\). This formula for diagnostics is consistent with the orthogonal update and shows explicitly how a surprising response interacts with geometric leverage.
As an example fit a line \(y=c+dt\) at times \(t=-1,0,+1\) with readings \(0,1,2\). The exact line is \(c=d=1\), with \(G=\operatorname{diag}(3,2)\). A new observation at \(t=2\) reports \(y=4\) rather than predicted 3. Here \(a=(1,2)^T\), \(w=(1/3,1)^T\), \(h=7/3\). The corrected coefficients are \(c=1.1,\ d=1.3\), and residual sum rises by \(1/(1+7/3)=0.30\). Substitution back into all four data gives residuals \(0.2,-0.1,-0.4,0.3\); their squared sum is indeed 0.30. The update has moved a previously exact historical fit because the new reading changed the estimated slope and intercept.
Distinguish a safe deletion from rank loss
For deleting a row already included in the fitted \(G\), use that row's in-sample leverage \(\ell=a^TG^{-1}a\). It lies between zero and one as a diagonal element of the orthogonal projection \(A(A^TA)^{-1}A^T\). If \(\ell<1\), the remaining-data fit changes by \(-G^{-1}a\,r/(1-\ell)\), where \(r=y-a^Tx\) is the residual while the point was present. The leave-one-out prediction residual is \(r/(1-\ell)\). A point with small in-sample residual can therefore be highly influential when nearly essential to identification. If \(\ell=1\), deletion loses rank, and a formula dividing by \(1-\ell\) is warning of a structural change. Downdating a triangular factor should use a well-conditioned dedicated downdate or refactor with rank detection when close to this boundary. Squaring a poorly conditioned design into \(G\) just for convenience can lose accuracy.
Refit the line after one influential observation
Begin with three calibration pairs on y = x at x = −1, 0 and 1. Place a fourth sensor farther from the centre and choose its deviation from the old line. Predict its training residual and the error made when the entire fourth observation is omitted. Move it farther out with a fixed nonzero offset. Which residual approaches zero and which retains the full offset? Set the offset to zero and check whether a high-leverage point must also have a large residual.
The OneSimulation model fits the full augmented observation matrix with its dense least-squares solver. Compare this independent refit with the one-row update on screen.
Tutorial · inspect an update from three angles
Perform a complete scalar QR update
Three readings of a constant have average 2 and residual sum 0.50. Add value 5 at equal weight. Find the updated average, residual increment and scalar triangle.
Work through the solution
Before appending,
With appended row 1 the new diagonal is 2. The rotated right side is \((\sqrt3/2)(2\sqrt3)+(1/2)5=5.5\), giving average 2.75. The bottom response is \((-1/2)(2\sqrt3)+(\sqrt3/2)5=1.5\sqrt3\), contributing 6.75 to sum of squares and giving new total 7.25. The mean from the raw sum is also \((6+5)/4=2.75\).
Reverse the four-point line update
For the newly appended point in the line example, infer its in-sample leverage from the original append leverage, then recover the original leave-one-out residual.
Work through the solution
Adding its own row changes leverage from \(h\) to \(\ell=h/(1+h)=0.70\), obtained by solving \((G+aa^T)^{-1}a=w/(1+h)\). Its current fitted value is \(1.1+2(1.3)=3.7\), giving residual 0.3. Dividing by \(1-\ell=0.3\) recovers the predicted deletion residual 1.0. Confusing \(h\) with \(\ell\) would incorrectly put a leverage larger than one inside a leave-one-out formula.
Detect a geometry where a zero residual is inevitable
Fit a line with many observations at \(t=0\) and exactly one at \(t=1\). Show why the latter's in-sample residual can be zero for any value and why its fit quality cannot validate the slope.
Work through the solution
All \(t=0\) samples determine the intercept by their mean. The unique nonzero time then fixes the slope to hit its own response exactly, so its residual is always zero and its in-sample leverage is one. Removing it leaves only one time coordinate and the slope unidentifiable. An extra independent observation at a distinct time, or a justified physical slope prior, is needed to test predictive slope accuracy. Increased repetitions at \(t=0\) reduce intercept noise without repairing this missing diagnostic.