Intuition Blueprint

What story does a straight line tell about a cloud of points?Simple Regression

created: 2026-07-22 last-updated: 2026-07-22 statistics, regression, least-squares, inference
visual grammar Observed data Fitted line / estimate Residual / counterfactual prediction

You measured two things on each of \(n\) units — an input \(x\) and an output \(y\) — and the points form a cloud. A line is the simplest story you can tell about how \(y\) moves with \(x\). This blueprint is about what that line is really doing, what it promises, and where its promises stop.

01 — The starting point

Why a line is the simplest story two variables can tell

Suppose you want to summarize how \(y\) tends to move with \(x\), or to predict \(y\) for a new unit whose \(x\) you'll measure. You could report nothing, or you could report the mean of \(y\) and ignore \(x\) entirely — but that throws away everything you measured about \(x\). The next step up is to assume \(y\) changes at a constant rate as \(x\) moves. That assumption is a straight line. It needs only two numbers: a baseline (where the story starts) and a rate (how much \(y\) shifts per unit of \(x\)). Every more elaborate shape — curves, thresholds, interactions — is a story you have to earn with evidence. The line is the default, the first-order approximation, the thing you fit before you have a reason to fit anything else.

The line, as a story about y
$$\hat{y} = b_0 + b_1\,x$$
reading it
  • \(x\) — the predictor: the input you measured on each unit (continuous)
  • \(\hat{y}\) — the fitted value: the \(y\) the line predicts for that \(x\); the hat distinguishes the prediction from the observed \(y\)
  • \(b_0\) — the intercept: the \(y\) the line sits at when \(x=0\); the baseline of the story
  • \(b_1\) — the slope: how much \(\hat{y}\) rises for each one-unit increase in \(x\); the rate of the story
  • the whole line — "\(\hat{y}\) is a constant baseline plus a constant rate times \(x\)"; a first-order summary of how \(y\) moves with \(x\)
y x fitted line
A line is a two-number summary of a cloud: baseline plus rate. It's the story you tell before you've earned a curved one.
Remember

A straight line is the default, not the truth. It's the simplest story — baseline plus constant rate — that you fit before any evidence justifies a more complex shape.

02 — The fitting principle

Best fit means smallest total squared error

Many lines could be drawn through the cloud. To pick one we need a definition of "error." For each observed point \((x_i, y_i)\), the line's prediction \(\hat{y}_i = b_0 + b_1 x_i\) misses the actual \(y_i\) by a vertical gap called the residual, \(e_i = y_i - \hat{y}_i\). A good line makes the collection of residuals small. We can't just sum them — positives and negatives cancel, so a terrible line through the middle of a vertical scatter could sum to zero. Three properties make squares the conventional choice: squares are always positive (no cancellation), they penalize large misses disproportionately (a miss of 2 costs 4, a miss of 4 costs 16), and they are differentiable — which is what lets calculus produce the closed-form recipes in §03. Minimizing the sum of squared residuals is ordinary least squares (OLS).

y x e_i point (x_i, y_i)
Each dashed segment is a residual \(e_i = y_i - \hat{y}_i\): the vertical miss between the observed point and the line's prediction at the same \(x_i\). OLS picks the line that minimizes the sum of squared residuals.
Ordinary least squares objective
$$\min_{b_0,\,b_1}\; \sum_{i=1}^{n}\big(y_i - b_0 - b_1 x_i\big)^2$$
reading it
  • \(y_i,\,x_i\) — the observed output and predictor for unit \(i\)
  • \(b_0,\,b_1\) — the intercept and slope we are free to choose; the minimizer becomes the OLS estimate
  • \((y_i - b_0 - b_1 x_i)\) — the residual for unit \(i\), the vertical miss between \(y_i\) and the line's prediction at \(x_i\)
  • the square — makes every miss positive (no cancellation), weights large misses more heavily, and keeps the objective smooth so calculus can solve it
  • the sum over \(i\) — total squared error across all \(n\) units; the line that makes this as small as possible is "best fit"
Remember

Residuals are vertical misses, and OLS squares them so misses can't cancel, big ones hurt more, and the math gives a clean closed form. "Best fit" is always relative to a loss function — squares are a choice, not a law of nature.

03 — The recipes

The slope and intercept have closed-form recipes

Setting the derivative of the squared-error objective to zero yields two equations whose solution is a pair of formulas. To read the slope formula we need two pieces of vocabulary you already feel but haven't pinned down: variance and covariance. Variance is spread made precise — the average squared distance of each \(x\) from its own mean. Covariance is its two-variable cousin: the average product of "how far \(x\) is from its mean" times "how far \(y\) is from its mean." It is positive when \(x\) above its mean tends to travel with \(y\) above its mean, and negative when they move oppositely. The slope is literally their ratio: how much \(y\) and \(x\) move together divided by how much \(x\) moves at all. That is the rate at which \(y\) rises per unit \(x\), exactly what a slope should be.

Variance — spread along one variable
$$\mathrm{Var}(x)=\frac{1}{n}\sum_{i=1}^{n}(x_i-\bar{x})^2$$
reading it
  • \(\bar{x}\) — the sample mean of \(x\): the center \(x\) spreads around
  • \((x_i-\bar{x})\) — how far unit \(i\)'s \(x\) sits from that center
  • the square — makes left and right deviations both positive, so they add rather than cancel
  • the average of those squares — the typical squared distance from the mean; a precise number for "spread"
Covariance — how two variables' spreads co-move
$$\mathrm{Cov}(x,y)=\frac{1}{n}\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})$$
reading it
  • \((x_i-\bar{x}),\,(y_i-\bar{y})\) — how far unit \(i\) sits from each variable's mean
  • the product — positive when \(x\) and \(y\) deviate in the same direction from their means, negative when they deviate oppositely
  • the average of the products — positive when the variables tend to rise together, negative when one rises as the other falls, near zero when their deviations are unrelated
ȳ + × + = + − × − = + − × + = − + × − = −
Covariance is the average of the four-quadrant products. Points in the NE and SW quadrants push it positive (same-direction deviations); NW and SE push it negative. A cloud stretched along a rising diagonal has mostly positive contributions.
OLS slope and intercept
$$b_1=\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{\sum_{i=1}^{n}(x_i-\bar{x})^2}=\frac{\mathrm{Cov}(x,y)}{\mathrm{Var}(x)}\qquad b_0=\bar{y}-b_1\bar{x}$$
reading it
  • \(b_1\) — the OLS slope: how much \(\hat{y}\) rises per unit of \(x\)
  • numerator \(\mathrm{Cov}(x,y)\) — how much \(x\) and \(y\) move together
  • denominator \(\mathrm{Var}(x)\) — how much \(x\) moves at all; dividing by it converts "co-movement" into "rate per unit \(x\)"
  • \(b_0=\bar{y}-b_1\bar{x}\) — the intercept pinned so the line passes through the point of means \((\bar{x},\bar{y})\); the line always goes through the centroid of the cloud
Remember

The slope is co-movement divided by spread: \(\mathrm{Cov}/\mathrm{Var}\). The intercept just parks the line through the centroid \((\bar{x},\bar{y})\). Both come from setting the derivative of squared error to zero.

04 — Goodness of fit

R² tells you how much spread the line explains

The total spread of \(y\) around its own mean — the total sum of squares, TSS — can be split into two pieces: the spread the line accounts for (the explained sum of squares, ESS) and the spread left over as residuals (the residual sum of squares, RSS). For each point, the deviation \((y_i-\bar{y})\) decomposes as \((\hat{y}_i-\bar{y})\) (the line's part) plus \((y_i-\hat{y}_i)\) (the residual). Squaring and summing gives \(\text{TSS}=\text{ESS}+\text{RSS}\). \(R^2\) is the fraction of \(y\)'s spread the line explains: \(R^2 = 1 - \text{RSS}/\text{TSS}\). It runs from 0 (the line explains nothing — no better than using \(\bar{y}\) for everyone) to 1 (the line explains everything — every point sits on it). A high \(R^2\) says the line fits this cloud well; it says nothing about causation, and a more flexible model can always push \(R^2\) toward 1 by overfitting, so it is a measure of fit, not of truth.

ȳ ŷ_i − ȳ (explained) y_i − ŷ_i (residual) total: y_i − ȳ
The total deviation \(y_i-\bar{y}\) is the magenta (line's part) stacked on the teal (residual). Sum the squares across all points: \(\text{TSS}=\text{ESS}+\text{RSS}\), and \(R^2\) is the magenta share of the total.
The variance decomposition and R²
$$\underbrace{\sum_i(y_i-\bar{y})^2}_{\text{TSS}}=\underbrace{\sum_i(\hat{y}_i-\bar{y})^2}_{\text{ESS}}+\underbrace{\sum_i(y_i-\hat{y}_i)^2}_{\text{RSS}}$$ $$R^2=1-\frac{\text{RSS}}{\text{TSS}}=\frac{\text{ESS}}{\text{TSS}}$$
reading it
  • TSS — total sum of squares: the total spread of \(y\) around its mean; what you'd still have to explain if you ignored \(x\) and used \(\bar{y}\) for everyone
  • ESS — explained sum of squares: the spread of the fitted values \(\hat{y}_i\) around \(\bar{y}\); the part the line accounts for
  • RSS — residual sum of squares: the leftover spread the line leaves on the table (the objective from §02 at its minimum)
  • \(R^2\) — the fraction of \(y\)'s spread the line explains; \(0\) = no better than \(\bar{y}\), \(1\) = perfect fit
Remember

\(R^2\) is the line's share of \(y\)'s spread. High \(R^2\) means the line summarizes the cloud well — not that the model is right, not that \(x\) causes \(y\), and a wiggly enough model can always force it to 1.

05 — When the line can be trusted

The line is only honest under assumptions

OLS always computes a line — feed it any \(x,y\) and it returns numbers. Whether those numbers mean what you want depends on assumptions about where the data came from. Linearity: the true relationship between \(x\) and \(y\) is straight. If it's curved, the fitted slope is a misleading average and no amount of data fixes that. Independence: observations don't carry information about each other (no clustering, no time series linkage). If it fails, the standard errors in §06 are simply wrong. Homoscedasticity: the spread of the residuals is the same at every \(x\). If it funnels, standard errors are wrong again (though the slope itself is still unbiased). Normality of errors: the residuals are drawn from a normal distribution. This is only needed for the exact \(t\)-tests and confidence intervals in §06; with a decent sample size the central limit theorem lets you mostly ignore it. The first assumption is about the line being the right shape; the other three are about the inference machinery being honest.

healthy random scatter, even spread linearity violated curved pattern → slope misleads homoscedasticity violated spreads as x grows → SEs lie
A residual-vs-\(x\) plot is the diagnostic. Left: no structure, even fan — assumptions look fine. Center: a curve means a line is the wrong shape. Right: a funnel means the error spread depends on \(x\), so standard errors are wrong even though the slope is unbiased.
Remember

Linearity is about the line being the right shape and it fails irrecoverably. Independence and homoscedasticity are about the inference machinery being honest; normality is only needed for exact small-sample \(t\)-tests.

06 — Quantifying uncertainty

How confident is the slope, really?

The slope \(b_1\) is an estimate from one sample. Draw a different sample and you'd get a different \(b_1\). That sampling spread has a standard deviation, called the standard error of \(b_1\). Two ingredients set it: how noisy the residuals are (\(\sigma^2\), estimated by \(s^2=\text{RSS}/(n-2)\)), and how much \(x\) actually varies (more spread in \(x\) pins the line's tilt more firmly). Divide \(b_1\) by its SE and you get a \(t\)-statistic: "how many standard errors the estimate sits from zero." Under the null hypothesis that the true slope is zero, it follows a \(t\)-distribution with \(n-2\) degrees of freedom. A large \(|t|\) is unlikely under that null, so we call the slope "statistically significant." A confidence interval brackets the estimate: \(b_1 \pm t^{\!*}\cdot\mathrm{SE}(b_1)\). "Significant" only means we'd be surprised if the true slope were zero — it says nothing about whether the effect is large, whether the model is right, or whether \(x\) causes \(y\).

b₁ b₁ − t*·SE b₁ + t*·SE 95% CI −1 SE +1 SE
The slope's sampling distribution is a bell centered at the true slope; \(\mathrm{SE}(b_1)\) is its spread. The 95% confidence interval is the estimate \(\pm\) about two SEs — the range of plausible true slopes consistent with what you saw.
Standard error of the slope
$$\mathrm{SE}(b_1)=\sqrt{\frac{s^2}{\sum_{i}(x_i-\bar{x})^2}},\qquad s^2=\frac{\text{RSS}}{n-2}$$
reading it
  • \(s^2\) — estimated variance of the residuals: how noisy the leftover scatter is; dividing by \(n-2\) (not \(n\)) accounts for the two parameters we already estimated (\(b_0,b_1\))
  • \(\sum_i(x_i-\bar{x})^2\) — the total spread of \(x\) (the denominator of the slope from §03); more spread in \(x\) means the tilt is pinned more firmly, so the SE shrinks
  • \(\mathrm{SE}(b_1)\) — the standard deviation of the slope's sampling distribution; bigger residual noise widens it, more \(x\)-spread and more data narrow it
t-statistic and confidence interval
$$t=\frac{b_1}{\mathrm{SE}(b_1)},\qquad \text{CI}=b_1\pm t^{\!*}\cdot\mathrm{SE}(b_1)$$
reading it
  • \(t\) — how many standard errors the estimate sits from zero; under the null "true slope = 0," it follows a \(t\)-distribution with \(n-2\) degrees of freedom
  • \(t^{*}\) — the critical value from that \(t\)-distribution for the desired confidence level (≈ 2 for 95% with large \(n\))
  • the CI — the range of true-slope values that the data would not surprise; if it excludes 0, the slope is "statistically significant"
  • "significant" — "we'd be surprised if the true slope were 0"; not large, not important, not causal, not "the model is right"
Remember

The slope's standard error shrinks with less residual noise, more spread in \(x\), and more data. "Significant" just means "distinguishable from zero at a chosen threshold" — it is a statement about surprise, not about importance.

07 — Why OLS, specifically

Gauss–Markov: why least squares is the best linear unbiased estimator

Of all the estimators you could cook up for the slope, why use OLS? The Gauss–Markov theorem gives the answer: among all estimators that are linear in \(y\) and unbiased, OLS has the smallest variance. It is the Best Linear Unbiased Estimator — BLUE. The assumptions it needs are linearity, exogeneity (\(E[\varepsilon\mid x]=0\): the errors have mean zero at every \(x\)), homoscedasticity, and no autocorrelation. Notice what is not on that list: normality. Normality is only required for the exact \(t\)-tests in §06; Gauss–Markov holds without it. The theorem is a constrained optimality result — "best" only among estimators that are both linear and unbiased. Drop the unbiasedness constraint and biased estimators (ridge, lasso) can beat OLS on variance, often dramatically, by accepting a little bias to shrink the sampling spread. That trade-off is the door to shrinkage and regularization, which a future blueprint covers.

true slope β₁ OLS · tightest another linear unbiased estimator
Both bells are centered on the true slope (both unbiased), but OLS's is narrower — smaller variance. Gauss–Markov: among linear unbiased estimators, none has a tighter sampling distribution than OLS.
Gauss–Markov in one line
$$\text{OLS}=\arg\min_{\hat{\beta}_1\,\in\,\text{linear \& unbiased}}\;\mathrm{Var}(\hat{\beta}_1)$$
reading it
  • \(\hat{\beta}_1\) — any estimator of the slope that is a linear function of the \(y_i\)'s and has expectation equal to the true slope \(\beta_1\)
  • \(\mathrm{Var}(\hat{\beta}_1)\) — the variance of that estimator's sampling distribution (how much it wobbles sample to sample)
  • \(\arg\min\) — "the choice that minimizes"; OLS is the one whose sampling distribution is tightest
  • the constraint "linear & unbiased" — the result only holds inside this constraint; a biased estimator (e.g. ridge) can have smaller variance by accepting some bias
Remember

OLS is the tightest unbiased linear estimator — no normality required for that, only linearity, exogeneity, homoscedasticity, no autocorrelation. "Best" is conditional on staying linear and unbiased; step outside and you trade bias for variance.

08 — The bridge

Regression adjusts for a covariate — the bridge to causal inference

Fit simple regression with a binary \(x\) taking values 0 and 1 — say, control vs treated. The math collapses to something familiar: the slope \(b_1\) is exactly the difference between the two group means, and the intercept \(b_0\) is the control mean. In other words, simple regression on a binary predictor is the naive group comparison — the very thing the causal-inference blueprint warns lies (causal-inference §01). The line isn't doing any adjustment; with one predictor there is nothing to adjust for. Adjustment enters when you add more covariates (multiple regression, a future blueprint): each coefficient becomes the effect of its variable holding the others fixed. That is the regression analogue of matching — instead of finding literal twins, you fit a plane and read off a partial slope. Both methods lean on the same unconfoundedness assumption: that the covariates you conditioned on capture every trait driving both the treatment and the outcome. Regression is just a smoother, continuous way to compare like with like.

y b₁ = ȳ_treated − ȳ_control x = 0 (control) x = 1 (treated)
With a binary predictor the regression line just connects the two group means, and the slope is the naive difference. Simple regression does no adjustment — that only begins when further covariates enter the model.
The binary-predictor collapse
$$\hat{y}=b_0+b_1\,x,\quad x\in\{0,1\}\;\Longrightarrow\; b_1=\bar{y}_{T}-\bar{y}_{C},\quad b_0=\bar{y}_{C}$$
reading it
  • \(x\in\{0,1\}\) — a binary treatment indicator (0 = control, 1 = treated)
  • \(b_1\) — the slope, which here equals the difference in group means — i.e. the raw (naive) treatment effect estimate
  • \(b_0\) — the intercept, which equals the control group's mean (the line's value at \(x=0\))
  • the implication — simple regression on a binary predictor is the naive comparison; to adjust for a covariate you must add it to the model, turning the slope into a partial effect
Remember

With a binary predictor, regression's slope is just the group-mean gap — the naive estimate, unadjusted. Adjustment begins only with more covariates, and then regression and matching are two routes to the same unconfoundedness destination.

In one breath

A straight line is the simplest story two variables can tell — a baseline plus a constant rate — and OLS picks the line that minimizes total squared vertical error, squaring so misses neither cancel nor stay cheap and the math yields a closed form. The slope is co-movement over spread, \(\mathrm{Cov}/\mathrm{Var}\), and the line always passes through the centroid; \(R^2\) is the share of \(y\)'s variance the line explains. The line is only honest under linearity, independence, homoscedasticity, and (for exact inference) normality; the slope's standard error tells you how much it wobbles sample to sample, and "significant" means distinguishable from zero — not important or causal. Gauss–Markov makes OLS the tightest linear unbiased estimator, conditional on staying linear and unbiased. And with a binary predictor, regression's slope is just the group-mean gap — the naive estimate — so adjustment, and the bridge to causal inference, only opens once further covariates enter the model.

prereqs none yet leads to causal-inference