4.9.22 · D1Probability Theory & Statistics

Foundations — Linear regression — least squares, inference on coefficients

2,648 words12 min readBack to topic

Before you can read the parent note, you need to own every squiggle it writes. Below, each symbol gets three things: plain words, a picture, and why the topic needs it. They are ordered so each one leans only on the ones above it.


1. The raw ingredients: dots on paper

Picture: each pair is a single dot pinned to graph paper. Read off the bottom, off the side.

Why the topic needs it: the whole enterprise is "find the line through a cloud of dots." No dots, nothing to fit.

Picture: imagine walking along the dots one by one, dropping each dot's value into a running total.

Why: every formula in the topic is a total taken over all dots — the sign just saves us writing "".

Figure — Linear regression — least squares, inference on coefficients

2. Where the cloud sits: the means

Picture: is the horizontal balance-point of the dots (ignore heights); is the vertical balance-point. The pair marks the centre of mass — the spot where the cloud would balance on a pin.

Why: the best-fit line is forced to pass through . Knowing the centre first makes every later formula simpler, because we measure everything relative to this centre.

Picture: slide your graph so the centre of mass sits at the origin. Now each dot's coordinates are its centred values — a dot in the upper-right has both positive, a dot in the lower-left has both negative.

Figure — Linear regression — least squares, inference on coefficients

Why: the sign of these centred values is the engine of the slope (next section). Dots that are right-and-high or left-and-low will pull the line upward.


3. Spread and co-movement: and

Picture: for every dot draw a horizontal stick from the centre line to the dot's -position; is the total of the squared stick lengths. Dots far out left/right make it large; dots bunched in the middle make it small.

Why: a wide horizontal spread is a long lever — it lets you aim the line's tilt precisely. This exact quantity later sits under the slope's precision.

Picture (crucial): the sign of each product tells a story.

Why: this tally is the numerator of the slope. It is a close cousin of Covariance (which is ) and of the Correlation coefficient (which rescales it to lie in ).

Figure — Linear regression — least squares, inference on coefficients

4. The line and its parts: , hats, and residuals

Picture: stand at ; the line is at height . Walk one step right; the line climbs by .

Picture: the true line is invisible; the hatted line is the one we actually draw through the cloud.

Picture: is the length of the vertical segment from the dot down (or up) to the fitted line — the "miss." is the same idea but measured against the invisible true line.

Figure — Linear regression — least squares, inference on coefficients

5. The quantity we minimise, and the slope formula it produces

Picture: each residual stick from figure s04 gets turned into a square (side = the miss); is the total area of all those squares. A better-aimed line makes the squares smaller, so drops.

Why: least squares is defined as "pick that make as small as possible." So is the target — the very thing every derivation is pushing downhill. The prose "minimise the total squared residuals" and the symbol mean exactly the same thing.

Picture: is a bowl-shaped surface over the plane; the minimum is the lowest point of the bowl, where the ground is flat in every direction.

Setting both partials to zero and solving pins down the estimates in terms of the pieces we already built:

Why this matters now: the parent topic derives these boxed formulas by calculus, but you should recognise every symbol in them before the derivation — and know the one input configuration () that breaks them.


6. Trust language: variance, , standard error, and the

Picture: a fat vertical band of scatter around the true line means large ; a thin band means small .

Picture: overlay the many lines you'd get from many repeats; they form a fan. A narrow fan = small SE = trustworthy slope; a wide fan = large SE.

Why: dividing the summed squared residuals ( again!) by (not ) gives an unbiased estimate of .

Why: because we had to estimate from the same small sample, the bell curve gets fatter tails — that fattened curve is the -distribution.

The claim that this fit is the best possible unbiased linear one comes from the Gauss–Markov Theorem; extending from one input to several is the job of Multiple Regression.


Prerequisite map

Data points x_i y_i

Means x-bar y-bar

Centred values

Sxx spread

Sxy co-movement

S sum of squared residuals

Slope beta1-hat

Fitted line and residuals

Estimate sigma-squared

Standard error

t-statistic and trust

Partial derivatives

Variance idea

Everything on the left builds the line; everything on the right builds the trust in that line. Together they are exactly the two questions the parent topic answers.


Equipment checklist

Cover the right side and test yourself.

What does the subscript in mean?
A name tag for which dot — is dot 1's input, is dot 's.
What does instruct you to do?
Add the following expression for every dot, from the first to the last.
What is and what does it mark geometrically?
The average of the inputs; combined with it marks the centre of mass of the cloud.
What does a positive tell you?
That dot votes for an upward-sloping line (it's upper-right or lower-left of centre).
In words, what is ?
The total squared horizontal spread of the inputs about their mean.
What is the symbol and what do we do with it?
The sum of squared residuals — the total badness of a line; least squares makes it as small as possible.
Write the slope and intercept formulas from the pieces.
and .
What happens if , and when does that occur?
The slope is undefined (divide by zero); it occurs when all are equal, so there is no horizontal spread to fix a tilt.
Difference between and ?
is Nature's true unknown slope; is our estimate from the data (the hat = "estimated").
What is ?
The specific slope value we choose to test against (the hypothesised value), usually 0 meaning "no relationship."
Difference between error and residual ?
is the invisible true noise; is the visible gap from the dot to our fitted line.
What does measure?
The variance (typical squared wobble) of each noise term around the true line.
In one sentence, what is a standard error?
The typical amount our estimated slope would jump if we redid the experiment with fresh noise.
Why divide by instead of ?
Two constraints from estimating two coefficients leave only free residuals (degrees of freedom); it makes unbiased.
What does the -statistic count?
How many standard errors the estimated slope sits away from the tested value .
Why does a partial derivative appear?
To find the bottom of the two-variable error bowl by demanding zero slope in each of and separately.