DEVELOPED COURSE TEXT
Least squares, residuals and what the fitting criterion chooses
Minimization is a rule with consequences
Ordinary least squares selects coefficients that minimize the sum of squared vertical residuals for the specified model and dataset. Squaring makes large residuals contribute disproportionately. The method does not minimize every other useful business loss function, and it does not establish that vertical-error assumptions are correct. If predictor values are themselves measured with substantial error, the chosen model may require another treatment. Define the fitting criterion and the quantity being predicted.
Centering exposes the simple-line calculation
For a line with an intercept, the slope is the centered cross-product sum divided by the centered predictor squared sum, provided the latter is nonzero. The intercept makes the line pass through the sample means. These algebraic facts permit checking a software result by hand on a small dataset. They also show why no unique slope can be estimated when every predictor value is identical. The availability of a fitting routine does not manufacture variation absent from the data.
Fit summaries do not replace a model check
R-squared compares residual variation with total outcome variation in the fitted sample under the defined calculation. It is not a causal proportion, a guarantee of future accuracy or a test that the functional form is correct. A residual pattern can remain even when the summary seems favorable. An intercept least-squares fit has residuals summing to zero, but that algebraic property is not proof of independent, constant-variance or normally distributed errors.
Worked records
Record 1
Four fictional records have X = 0,1,2,3 and Y = 1,2,2,5. Fit a least-squares line with an intercept.
Develop the reasoning
The means are X-bar=1.5 and Y-bar=2.5. The centered cross-product sum is 6 and the centered X squared sum is 5, so the slope is 6/5=1.2. The intercept is 2.5−1.2×1.5=0.7. Predictions are 0.7,1.9,3.1,4.3 and residuals are 0.3,0.1,−1.1,0.7. Their sum is zero. Squared residuals total 1.8; total squared deviations of Y from 2.5 total 9. Thus R-squared is 1−1.8/9=0.8. Eighty percent is an in-sample variation summary for this fitted line, not the fraction of sales caused by X. The relatively large negative residual at X=2 deserves inspection, but the small dataset cannot establish a reliable error distribution.
Progressive practice — optional
1. Foundation
What is the fitted value at X=2.5?
Compare the worked reasoning
It is 0.7+1.2×2.5=3.7.
Change the record
The outcome is rounded to whole units in the recording process.
Compare the changed-record reasoning
State the measurement process; a noninteger conditional-mean prediction can still be meaningful even when individual outcomes are recorded as integers.
2. Application
If every X value were 2, could this formula estimate a unique slope?
Compare the worked reasoning
No. The centered X squared sum would be zero; the data do not distinguish slopes.
Change the record
A software package prints one parameterization anyway.
Compare the changed-record reasoning
A numerical output does not establish identifiability. Inspect the model rank and how the software handled the redundant specification.
3. Transfer
A fifth record far outside the original X range changes the slope substantially. Must it be discarded?
Compare the worked reasoning
No. Check its validity, influence and relevance to the target population; sensitivity analysis should explain rather than hide its effect.
Change the record
The record is a verified transcription error.
Compare the changed-record reasoning
Correction with an audit trail is justified by measurement evidence, not by a desire to preserve the preferred slope.
Sources and scope
- NIST/SEMATECH e-Handbook — Process modeling: Background on regression, model assumptions, residuals and prediction. Datasets and analyses here are original fictional business examples.