The regression line: slope, intercept and least squares
Simple linear regression explains a dependent variable Y with one independent variable X: Y = b₀ + b₁X + ε. Ordinary least squares (OLS) picks the line with the smallest sum of squared residuals, giving b̂₁ = Cov(X, Y) ÷ Var(X) and b̂₀ = Ȳ − b̂₁X̄.
Before this: Statistical Characteristics of Asset Returns
On the exam
- Describe, interpret, and explain simple linear regression, including coefficient estimation using the least squares criterion
Describe, interpret and explain simple linear regression and how ordinary least squares estimates the coefficients. Expect a slope from a covariance and a variance (or from sums of deviations), an intercept from the means, a predicted value or a residual, the type of data a regression uses, and an indicator variable read as two group means. Wrong options divide by the variance of Y or swap X and Y.
How deeply to learn each part
- Know the idea
- Understand it in general. It frames other topics, but you will not calculate with it.
- Use it
- Understand it well enough to solve a question with it. Recognize when it applies.
- Memorize
- Learn it by heart. The exam will not give it to you.
You know this one. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still do.
You tested strong here. The full lesson is folded away. The takeaways, formulas and checkpoint below are your quick refresher, and the checkpoint is a fair test of whether you still know it.
What is a simple linear regression?
A simple linear regression explains the variation in one variable using one other variable and a straight line. The variable you want to explain is the dependent variable , Y. The variable you use to explain it is the independent variable , X.
Fitting the line this way is called ordinary least squares (OLS) regression, and we say Y is regressed on X. One independent variable makes the regression simple; two or more make it a multiple regression, which is beyond this module.
The regression coefficients are the intercept , , and the slope coefficient , . The error term , , is everything about that the line does not capture. Once the data give estimates of the coefficients, we write them with hats, and .
- Dependent variable, Y Memorize the variable you want to explain
- Also called explained variable, predicted variable
-
- Independent variable, X Memorize the variable doing the explaining
- Also called explanatory variable, predictor
-
- Regression coefficients Memorize estimated from the data
- Intercept, b₀ predicted Y when X = 0
- Slope, b₁ change in predicted Y per one-unit rise in X
-
- Error term, ε Use it what the line leaves unexplained
- Residual, e the sample estimate of ε: actual Y minus fitted Y
-
Throughout this module we use one small data set. Six retailers report their marketing spend as a percentage of sales (X) and their revenue growth in percent (Y).
| Retailer | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| Marketing spend, X (%) | 2 | 3 | 5 | 6 | 8 | 9 |
| Revenue growth, Y (%) | 4 | 5 | 9 | 8 | 12 | 13 |
How does ordinary least squares choose the line?
Any line gives a fitted value , , for each observation. The miss, , is the residual : actual minus fitted. It is the sample’s estimate of the error term. Square each residual and add them up to get the sum of squares error , SSE. The OLS line is the one with the smallest SSE.
Squaring does two jobs. Positive and negative misses cannot cancel, and a big miss counts far more than a small one. Calculus then gives a closed-form answer for the two coefficients. The slope is the covariance of X and Y, Cov(X, Y), divided by the variance of X, Var(X).
Two properties follow, and both are tested: the fitted line always passes through the point of means, , and the residuals always add up to zero.
Both the covariance and the variance use n − 1, so the divisor cancels and the sums give the same slope.
The covariance of X and Y is 9.7 and the variance of X is 7.5. The slope of the regression of Y on X is closest to:
9.7 ÷ 7.5 = 1.2933
Slope coefficient, b̂₁1.2933
- 9.7÷7.5=
- 9.7ENTER7.5÷
ENTER enter (on the HP, puts the number on the stack)
The means are X̄ = 5.5 and Ȳ = 8.5, and the regression slope is 1.2933. The intercept is closest to:
8.5 − 1.2933 × 5.5 = 1.3869
Intercept, b̂₀1.3869
- 8.5−(1.2933×5.5)=
- 8.5ENTER1.2933ENTER5.5×−
ENTER enter (on the HP, puts the number on the stack)
Try this 0 of 3
- Drag your line until its SSE is within 10% of the minimum (no snapping needed).
- Snap to least squares and read the sum of the residuals.
- In “Move the data”, drag one point until it misses the line by 3 or more.
Your line Ŷ = 2.00 + 1.00X has a sum of squared residuals of 12.00. The least-squares line Ŷ = 1.39 + 1.29X has the smallest possible, 2.77. Least squares is the line with the smallest total area of squared misses.
Drag either round handle on the line, or focus it and use the arrow keys.
- Retailer
- Your line
- Squared miss
Your squares cover 4.3 times the least-squares area. Drag a handle, or snap to least squares.
Show working
Means: X̄ = 5.50, Ȳ = 8.50 (n = 6).
Σ(X − X̄)(Y − Ȳ) = 15.75 + 8.75 − 0.25 − 0.25 + 8.75 + 15.75 = 48.50.
Σ(X − X̄)² = 12.25 + 6.25 + 0.25 + 0.25 + 6.25 + 12.25 = 37.50.
b̂₁ = 48.50 ÷ 37.50 = 1.2933 (the same as Cov(X, Y) ÷ Var(X) = 9.7000 ÷ 7.5000).
b̂₀ = Ȳ − b̂₁X̄ = 8.50 − 1.2933 × 5.50 = 1.3867.
Least-squares residuals Y − Ŷ: 0.03, −0.27, 1.15, −1.15, 0.27, −0.03 (they sum to zero). SSE = 2.7733.
Your line Ŷ = 2.00 + 1.00X: SSE = 0.00² + 0.00² + 2.00² + 0.00² + 2.00² + 2.00² = 12.00.
- 2NDDATA2NDCLR WORKclear old data
- 2ENTER↓4ENTER↓X01, Y01
- 3ENTER↓5ENTER↓X02, Y02
- 5ENTER↓9ENTER↓X03, Y03
- 6ENTER↓8ENTER↓X04, Y04
- 8ENTER↓12ENTER↓X05, Y05
- 9ENTER↓13ENTER↓X06, Y06
- 2NDSTATpress 2ND SET until LIN shows
- ↓↓↓↓↓↓↓↓a = 1.3867 (intercept)
- ↓b = 1.2933 (slope)
- ↓r = 0.9786
2ND second function (the shifted label above a key) · DATA data worksheet · CLR WORK clear the worksheet · ENTER enter (on the HP, puts the number on the stack) · STAT statistics worksheet
- fCLEAR Σ
- 4ENTER2Σ+Y first, then X
- display1
- 5ENTER3Σ+Y first, then X
- display2
- 9ENTER5Σ+Y first, then X
- display3
- 8ENTER6Σ+Y first, then X
- display4
- 12ENTER8Σ+Y first, then X
- display5
- 13ENTER9Σ+Y first, then X
- display6
- 0gŷ,rSTO7a = 1.3867 (intercept: ŷ at x = 0
- storeitinR7,sinceΣ+keepsnandthesumsinR1toR6)
- x≷yr = 0.9786
- 1gŷ,rRCL7−b = 1.2933 (slope: ŷ at x = 1 minus ŷ at x = 0)
f gold shift key · CLEAR Σ clear the statistics registers · ENTER enter (on the HP, puts the number on the stack) · Σ+ add a data point · g blue shift key · ŷ,r estimated y and correlation · STO store · x≷y swap the last two numbers · RCL recall a stored number
Display: b₀ 1.3867, b₁ 1.2933, r 0.9786
What are the residuals telling you?
Put the fitted line next to the data and each retailer has a residual.
| Retailer | X | Y | Fitted Ŷ | Residual e |
|---|---|---|---|---|
| A | 2 | 4 | 3.97 | 0.03 |
| B | 3 | 5 | 5.27 | −0.27 |
| C | 5 | 9 | 7.85 | 1.15 |
| D | 6 | 8 | 9.15 | −1.15 |
| E | 8 | 12 | 11.73 | 0.27 |
| F | 9 | 13 | 13.03 | −0.03 |
The residuals add up to zero, and their squares add up to SSE = 2.773. No other straight line through these points has a smaller sum of squares.
Exam tip On the exam you will usually be handed the covariance and variance, or the sums of squares. Slope first, then intercept. Check that the slope has the variance of X underneath it.
Go deeper Slope and correlation
Dividing the covariance by both standard deviations gives the correlation, . Dividing by the variance of X alone gives the slope. So the two are linked by the ratio of standard deviations.
For the six retailers , and , and . A positive correlation always means a positive slope, and the slope is in units of Y per unit of X, while has no units.
Does a regression prove cause and effect?
Know the idea
No. A regression measures association: how Y tends to move with X. It cannot tell you that X causes Y, because a third factor can drive both. Retailers in fast-growing regions may spend more on marketing and also grow faster, so part of the 1.29 slope could reflect local demand rather than marketing. Read a slope as “goes with”, not “causes”. This is the point of correlation versus causation .
What kinds of data does a regression use?
The data come in three shapes. Cross-sectional data are many entities observed in the same period (indexed by ). Time-series data follow one entity over many periods (indexed by ). Panel data follow the same entities over many periods.
- Cross-sectional Memorize many entities, one period
- Time-series Memorize one entity, many periods
- Panel Memorize the same entities over many periods
The six retailers in one year are cross-sectional data. A regression of one company’s monthly returns on an index’s monthly returns uses time-series data. Forty countries’ bond yields against their debt ratios over ten years are panel data.
What if X is a yes-or-no variable?
An indicator variable (also called a dummy variable) equals 1 when a condition holds and 0 when it does not. With an indicator as X, the intercept is the mean of Y in the 0 group, the slope is the difference between the two group means, and the mean of the 1 group is intercept plus slope.
Lesson 3 tests whether that difference is real.
Go deeper Why squares and not absolute values?
Squares give a smooth function that calculus can minimize in one step, so the coefficients have simple formulas. They also punish large misses heavily, so one wild point pulls the line toward it. That is why a single outlier can tilt a least squares line, a point lesson 2 returns to.
Go deeper Beta is a regression slope
Regress a stock’s excess returns (its return minus the risk-free rate) on the market’s excess returns and the slope is the stock’s beta. Lesson 7 runs that regression step by step and turns the beta into an expected return.
Go deeper Running a regression in a spreadsheet
Spreadsheets do the same arithmetic. In Excel and Google Sheets, SLOPE and INTERCEPT return the coefficients, RSQ the R-squared (the share of the variation in Y that the line explains) and CORREL the correlation; LINEST returns the full set of regression statistics; FORECAST.LINEAR (FORECAST in Google Sheets) and TREND return predicted values. Statistical software (R’s lm function, Python’s scikit-learn or statsmodels) prints the same output table. On the exam you calculate by hand or read the output.
Memorize this
MemorizeThe least squares line
| Item | What to know |
|---|---|
| Model | |
| Slope | |
| Intercept | |
| Residual | (actual − fitted) |
| Criterion | minimize (SSE): ordinary least squares |
| Properties | line through ; |
| Indicator X | intercept = mean of the 0 group; slope = difference in means |
| Data | cross-sectional (many entities, one period), time-series (one entity, many periods), panel (both) |
Memory hook Slope = covariance over the variance of X, the variable you stand on. Divide by both standard deviations and you get r, not the slope. The line always passes through (X̄, Ȳ), so the intercept just finishes the job.
Know it cold Least squares minimizes the sum of SQUARED residuals. Plain residuals always sum to zero, so they cannot be the criterion.
- Dependent variable, Y Memorize the variable you want to explain
- Also called explained variable, predicted variable
-
- Independent variable, X Memorize the variable doing the explaining
- Also called explanatory variable, predictor
-
- Regression coefficients Memorize estimated from the data
- Intercept, b₀ predicted Y when X = 0
- Slope, b₁ change in predicted Y per one-unit rise in X
-
- Error term, ε Use it what the line leaves unexplained
- Residual, e the sample estimate of ε: actual Y minus fitted Y
-
- Cross-sectional Memorize many entities, one period
- Time-series Memorize one entity, many periods
- Panel Memorize the same entities over many periods
Quick example
Revenue growth (Y, %) on marketing spend (X, % of sales): Ŷ = 1.39 + 1.29X. A retailer spending 4% of sales is fitted at 1.39 + 1.29 × 4 = 6.55%; the gap to its actual growth is its residual.
- 1.29×4+1.39= 6.55
- 1.29ENTER4×1.39+ 6.55
ENTER enter (on the HP, puts the number on the stack)
Quick example
Cov(X, Y) = 0.0036 and Var(X) = 0.0045. Slope = 0.0036 ÷ 0.0045 = 0.80.
- 0.0036÷0.0045= 0.8
- 0.0036ENTER0.0045÷ 0.8
ENTER enter (on the HP, puts the number on the stack)
Quick example
Ȳ = 7, X̄ = 6 and slope 0.80. Intercept = 7 − 0.80 × 6 = 2.20.
- 7−(0.8×6)= 2.2
- 7ENTER0.8ENTER6×− 2.2
ENTER enter (on the HP, puts the number on the stack)
Quick example
Correlation 0.50, standard deviation of Y 8%, of X 5%. Slope = 0.50 × 8 ÷ 5 = 0.80.
- 0.5×8÷5= 0.8
- 0.5ENTER8×5÷ 0.8
ENTER enter (on the HP, puts the number on the stack)
Quick example
A lender's mean annual default rate was 1.8% before a rule change and 1.1% after. With AFTER = 1 after the change, the fitted line is Y = 1.8 − 0.7 × AFTER: the slope −0.7 is the change in the mean.
- 1.1−1.8= −0.7
- 1.1ENTER1.8− −0.7
ENTER enter (on the HP, puts the number on the stack)
How it is asked
-
Slope from covariance and variance
Cov(X, Y) = 0.0026, Var(X) = 0.0032, Var(Y) = 0.0052. Slope?
0.0026 ÷ 0.0032 = 0.81. Trap: dividing by Var(Y) gives 0.50; dividing by both standard deviations gives r = 0.64.
-
Intercept from the means
X̄ = 6, Ȳ = 9, slope 0.81. Intercept?
Ȳ − b̂₁X̄ = 9 − 4.86 = 4.14. Trap: swapping the roles gives 6 − 0.81 × 9 = −1.29.
-
Indicator variable
Fitted: Default rate = 1.8 − 0.7 × AFTER. Mean default rate after the change?
1.8 − 0.7 = 1.1%. Traps: 1.8% is the mean before, −0.7 is the change.
-
Interpret a coefficient
Ŷ = 4.5 + 0.8X. What is 4.5?
The predicted Y when X = 0: the intercept. The 0.8 is the change in Y per unit of X.
Exam traps
- Dividing the covariance by the variance of Y (or by both standard deviations, which gives the correlation r, not the slope).
- Swapping the dependent and independent variables: the regression of Y on X is not the regression of X on Y.
- Reading the intercept as meaningful when X = 0 lies far outside the observed data.
- Saying least squares minimizes the sum of the residuals. It minimizes the sum of the squared residuals.
- Reading a slope as proof that X causes Y. Regression measures association; a third factor can drive both.
- Reading an indicator variable's slope as the mean of the 1 group. It is the difference between the two group means.
Checkpoint
4 exam-style questions. About 90 seconds each.
1Cov(X, Y) = 0.0018, Var(X) = 0.0024 and Var(Y) = 0.0030. The slope of the regression of Y on X is closest to:
2With X̄ = 4% and Ȳ = 5%, and the slope from the previous question (0.75), the intercept is closest to:
3The least squares method chooses the regression coefficients that minimize the:
4In the fitted line Ŷ = 3.0 + 0.5X, the value 3.0 is best interpreted as the:
Key takeaways
- Y = b₀ + b₁X + ε; the residual is actual minus fitted.
- b̂₁ = Cov(X, Y) ÷ Var(X); b̂₀ = Ȳ − b̂₁X̄; the line passes through (X̄, Ȳ).
- Ordinary least squares minimizes the sum of squared residuals (SSE); the residuals sum to zero.
- Cross-sectional, time-series or panel: know which data a regression uses.
- With an indicator X, the intercept is the mean of the 0 group and the slope is the difference in means.
Quick example
Revenue growth (Y, %) on marketing spend (X, % of sales): Ŷ = 1.39 + 1.29X. A retailer spending 4% of sales is fitted at 1.39 + 1.29 × 4 = 6.55%; the gap to its actual growth is its residual.
- 1.29×4+1.39= 6.55
- 1.29ENTER4×1.39+ 6.55
ENTER enter (on the HP, puts the number on the stack)
Quick example
Cov(X, Y) = 0.0036 and Var(X) = 0.0045. Slope = 0.0036 ÷ 0.0045 = 0.80.
- 0.0036÷0.0045= 0.8
- 0.0036ENTER0.0045÷ 0.8
ENTER enter (on the HP, puts the number on the stack)
Quick example
Ȳ = 7, X̄ = 6 and slope 0.80. Intercept = 7 − 0.80 × 6 = 2.20.
- 7−(0.8×6)= 2.2
- 7ENTER0.8ENTER6×− 2.2
ENTER enter (on the HP, puts the number on the stack)
Quick example
Correlation 0.50, standard deviation of Y 8%, of X 5%. Slope = 0.50 × 8 ÷ 5 = 0.80.
- 0.5×8÷5= 0.8
- 0.5ENTER8×5÷ 0.8
ENTER enter (on the HP, puts the number on the stack)
Quick example
A lender's mean annual default rate was 1.8% before a rule change and 1.1% after. With AFTER = 1 after the change, the fitted line is Y = 1.8 − 0.7 × AFTER: the slope −0.7 is the change in the mean.
- 1.1−1.8= −0.7
- 1.1ENTER1.8− −0.7
ENTER enter (on the HP, puts the number on the stack)
All Quantitative Methods formulas, every lesson
Practice exam-style questions on Simple Linear Regression in Finance
Questions about this lesson?
Where this comes back
- Estimating beta with a CAPM regression Simple Linear Regression in Finance
- Simple Linear Regression in Finance Quantitative Methods
Questions candidates ask
How do you calculate the slope of a regression line?
Divide the covariance of X and Y by the variance of X: b̂₁ = Cov(X, Y) ÷ Var(X). Equivalently, sum the cross-products of deviations from the means and divide by the sum of squared deviations of X. Then get the intercept from b̂₀ = Ȳ − b̂₁X̄.
What does the intercept mean in a regression?
It is the predicted value of Y when X is zero. It is only meaningful if X = 0 is plausible and near the data you observed. Otherwise it is just the number that positions the line so it passes through the point of means.
What is the least squares criterion?
Ordinary least squares chooses the intercept and slope that make the sum of squared residuals as small as possible. Squaring stops positive and negative misses from cancelling and penalizes big misses more. It gives one best line with simple formulas for the coefficients.
What is an indicator variable in regression?
A variable that is 1 when a condition holds and 0 otherwise, also called a dummy variable. Regressing Y on it gives an intercept equal to the mean of Y when the indicator is 0 and a slope equal to the difference between the two group means.
Spotted an error? Tell us and we will fix it.