A Least-Squares Line Through the Origin
A scalar slope through the origin can be selected to minimize the sum of squared vertical residuals.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Compute an exact example
For pairs \((1,2)\) and \((2,3)\), the slope \(\sum x_i y_i/\sum x_i^2\) equals \(8/5\). Multiplying by each input gives predictions 1.6 and 3.2. Dot products give the needed sums.
Check the denominator
If every input x is zero, the observations cannot identify the slope. A more general fit needs its own rank checks. See dependent data columns.[1][2]
Compute the coefficient from weighted sums
For samples \((1,2),(2,5)\) with positive weights one and two, minimize \(\sum_i w_i(y_i-bx_i)^2\). The slope is \(\sum_i w_i x_i y_i/\sum_i w_i x_i^2\), giving \(22/9\). See interpolation and fitting.
Numerator: 1×1×2 + 2×2×5 = 22
Denominator: 1×1² + 2×2² = 9
Slope ≈ 2.444
Check the model restriction and degenerate inputs
If all positively weighted inputs have zero \(x\), the denominator is zero and the slope cannot be identified. A free-intercept model answers a different fitting question. With the second weight reduced to zero and the first held fixed, the fit must pass through the sole positively weighted observation and the origin. Its slope becomes two.