1.3 Orthogonal Reconstruction Error vs. Vertical Regression Residuals

A frequent point of confusion for students learning Principal Component Analysis is: "Don't we already have Ordinary Least Squares (OLS) linear regression to fit a line through a cloud of points? Why does PCA produce a different line?"

The difference is geometric and fundamental. OLS regression assumes one coordinate (xx) is a noise-free input and the other (yy) is a noisy target, so it minimizes vertical errors parallel to the yy-axis. PCA treats all coordinates symmetrically as noisy measurements of an underlying latent phenomenon, minimizing orthogonal (perpendicular) distances from each point to the line.

In this Article

1. Visualizing Vertical OLS Residuals vs. Orthogonal PCA Errors

Imagine a point xi=[xi1xi2]\mathbf{x}_i = \begin{bmatrix} x_{i1} \\ x_{i2} \end{bmatrix} sitting above a candidate line passing through the origin with slope mm. There are three distinct ways to measure the gap between the point and the line:

  1. Vertical Residual (Regressing x2x_2 on x1x_1): Hold xi1x_{i1} fixed and drop straight down to x^i2=mxi1\hat{x}_{i2} = m x_{i1}.
  2. Horizontal Residual (Regressing x1x_1 on x2x_2): Hold xi2x_{i2} fixed and move horizontally to x^i1=xi2/m\hat{x}_{i1} = x_{i2}/m.
  3. Orthogonal Residual (PCA / Total Least Squares): Move along the shortest perpendicular path to x^i=(uTxi)u\hat{\mathbf{x}}_i = (\mathbf{u}^T\mathbf{x}_i)\mathbf{u}.
            * x_i = (x_i1, x_i2)
            |  \
   Vertical |   \  Orthogonal PCA Residual e_i
   OLS      |    \ (Shortest 90-degree path to line)
   Residual |     v
   |y - mx| |     (o) x_hat_i = (u^T x_i) u
            v    /
           [x]  /  <-- Candidate Line (slope m)
               /
       Origin 0

2. Mathematical Formulation of Both Error Objectives

For a line of slope mm passing through the origin, the unit direction vector is u=11+m2[1m]\mathbf{u} = \frac{1}{\sqrt{1+m^2}}\begin{bmatrix} 1 \\ m \end{bmatrix}, and the unit normal vector perpendicular to the line is n=11+m2[−m1]\mathbf{n} = \frac{1}{\sqrt{1+m^2}}\begin{bmatrix} -m \\ 1 \end{bmatrix}.

  • OLS Vertical Squared Error: EOLS(m)=1n∑i=1n(xi2−mxi1)2E_{\text{OLS}}(m) = \frac{1}{n}\sum_{i=1}^n (x_{i2} - m x_{i1})^2
  • PCA Orthogonal Squared Error: Because ei=∣n⋅xi∣e_i = |\mathbf{n} \cdot \mathbf{x}_i|, the perpendicular squared distance is:

    EPCA(m)=1n∑i=1n(nTxi)2=1n∑i=1n(xi2−mxi1)21+m2E_{\text{PCA}}(m) = \frac{1}{n}\sum_{i=1}^n (\mathbf{n}^T \mathbf{x}_i)^2 = \frac{1}{n}\sum_{i=1}^n \frac{(x_{i2} - m x_{i1})^2}{1 + m^2}

Key Geometric Insight: The denominator 1+m21 + m^2 in EPCA(m)E_{\text{PCA}}(m) converts vertical distance into perpendicular distance via cos⁡2θ=11+m2\cos^2\theta = \frac{1}{1+m^2}. Without that denominator, OLS heavily penalizes steep slopes mm, flattening the regression line toward the horizontal axis whenever x1x_1 contains noise (a phenomenon statisticians call attenuation bias).

3. The Axis-Swap Paradox in Regression vs. Rotational Invariance in PCA

In OLS regression, the optimal slope for predicting x2x_2 from x1x_1 is m2∣1=Cov(x1,x2)Var(x1)=rs2s1m_{2|1} = \frac{\text{Cov}(x_1, x_2)}{\text{Var}(x_1)} = r \frac{s_2}{s_1}, where rr is the Pearson correlation. If you swap the axes and regress x1x_1 on x2x_2, the resulting line has slope 1/m1∣2=1rs2s11 / m_{1|2} = \frac{1}{r} \frac{s_2}{s_1} in the original plot!

Unless the data lies on a perfect straight line (∣r∣=1|r| = 1), OLS gives two different lines depending on which variable you label as the horizontal axis. By contrast, PCA's orthogonal error ∥xi−(uTxi)u∥2\|\mathbf{x}_i - (\mathbf{u}^T\mathbf{x}_i)\mathbf{u}\|^2 depends only on Euclidean lengths and angles, so rotating or swapping the axes rotates the principal component line by the exact same angle.

4. Concrete Worked Comparison on a Symmetric Cloud

Consider four centered points forming a diamond tilted along 45∘45^\circ: x1=[21]\mathbf{x}_1 = \begin{bmatrix} 2 \\ 1 \end{bmatrix}, x2=[12]\mathbf{x}_2 = \begin{bmatrix} 1 \\ 2 \end{bmatrix}, x3=[−1−2]\mathbf{x}_3 = \begin{bmatrix} -1 \\ -2 \end{bmatrix}, x4=[−2−1]\mathbf{x}_4 = \begin{bmatrix} -2 \\ -1 \end{bmatrix}.

MethodFormula AppliedResulting Line Slope mm
OLS: x2x_2 on x1x_1m=∑xi1xi2∑xi12=2+2+2+24+1+1+4=810m = \frac{\sum x_{i1} x_{i2}}{\sum x_{i1}^2} = \frac{2+2+2+2}{4+1+1+4} = \frac{8}{10}m=0.80m = 0.80 (Flattened below 45∘45^\circ!)
OLS: x1x_1 on x2x_2x1=0.80x2  ⟹  x2=10.80x1x_1 = 0.80 x_2 \implies x_2 = \frac{1}{0.80} x_1m=1.25m = 1.25 (Steepened above 45∘45^\circ!)
PCA (Orthogonal)Minimizes ∑(xi2−mxi1)21+m2\sum \frac{(x_{i2} - m x_{i1})^2}{1+m^2}m=1.00m = 1.00 (Exact 45∘45^\circ symmetry axis!)

5. Active Recall Check and Key Takeaways

Quick Check: Test Your Understanding

Question: For the point x=[13]\mathbf{x} = \begin{bmatrix} 1 \\ 3 \end{bmatrix} and the line x2=2x1x_2 = 2x_1 (slope m=2m=2), calculate both the squared vertical OLS residual and the squared orthogonal PCA residual.

Answer: The vertical prediction at x1=1x_1 = 1 is x^2=2(1)=2\hat{x}_2 = 2(1) = 2, so the squared vertical residual is (3−2)2=1.0(3 - 2)^2 = 1.0. The squared orthogonal PCA residual divides by 1+m2=1+22=51 + m^2 = 1 + 2^2 = 5: ePCA2=(3−2(1))21+22=15=0.2e_{\text{PCA}}^2 = \frac{(3 - 2(1))^2}{1 + 2^2} = \frac{1}{5} = 0.2. You can verify this via projection onto u=15[12]\mathbf{u} = \frac{1}{\sqrt{5}}\begin{bmatrix} 1 \\ 2 \end{bmatrix}: z=1+65=75z = \frac{1+6}{\sqrt{5}} = \frac{7}{\sqrt{5}}, x^=[1.42.8]\hat{\mathbf{x}} = \begin{bmatrix} 1.4 \\ 2.8 \end{bmatrix}, and ∥x−x^∥2=(−0.4)2+(0.2)2=0.16+0.04=0.20\|\mathbf{x} - \hat{\mathbf{x}}\|^2 = (-0.4)^2 + (0.2)^2 = 0.16 + 0.04 = 0.20.

Take a Quiz Based on This Article

Test your understanding with AI-generated questions tailored to this content

Adaptive Learning with SynLearn

Explore this article through guided practice that adapts to your answers

✓Step-by-step concepts & lessons
✓Active recall & adaptive feedback
✓Personalized spaced repetition
orthogonal-error
least-squares
linear-regression
pca
residuals
statistics