Lesson 1 of 9 · All lessons in this module
  1. The regression model and least squares
  2. Interpreting coefficients, fitted values and residuals
  3. The four assumptions and residual plotsVideo lesson
  4. Sums of squares, \(R^2\), the ANOVA table and the SEEVideo lesson
  5. Testing the slope: t-test, correlation test and F-testVideo lesson
  6. Intercept tests, indicator variables and p-values
  7. Forecasts and prediction intervals
  8. Functional forms: log-lin, lin-log and log-logVideo lesson
  9. Integrated cases: reading a full regression printout

Free lesson: the first lesson of every module is open to everyone.

Lesson 1 of 9 · 14 min

The regression model and least squares

Simple linear regression explains the variation in Y with one variable X by fitting the straight line that makes the sum of squared vertical misses as small as possible.

In short

  • The dependent variable (Y) is the one we want to explain; the independent variable (X) is the one doing the explaining. We say “Y is regressed on X”.
  • Population model: Yi=b0+b1Xi+εiY_i = b_0 + b_1X_i + \varepsilon_i. b0b_0 is the intercept, b1b_1 the slope coefficient, εi\varepsilon_i the error term.
  • Ordinary least squares (OLS) picks b^0\hat b_0 and b^1\hat b_1 to minimise the sum of squares error (SSE), the sum of squared residuals.
  • Slope = covariance of X and Y ÷ variance of X. Intercept = Yˉ−b^1Xˉ\bar Y - \hat b_1\bar X, so the line runs through (Xˉ,Yˉ)(\bar X, \bar Y).
  • The slope and the correlation always have the same sign, because both take the sign of the covariance.

What regression tries to explain

Suppose six companies have very different sales growth. Regression asks: can another variable account for those differences? The thing we measure is the spread of Y around its mean, the sum of squares total (SST): ∑(Yi−Yˉ)2\sum (Y_i - \bar Y)^2.

The variable whose variation we want to explain is the dependent variable (also called the explained variable), written Y. The variable we use to explain it is the independent variable (also called the explanatory variable), written X. On a scatter plot, Y goes on the vertical axis and X on the horizontal axis.

With one X the method is simple linear regression; with several X variables it is multiple regression (not in this module). The X variable must actually vary across observations: a constant cannot explain why Y differs, and neither can a variable that is pure noise.

0%2.5%5%7.5%10%0%2%4%6%8%Marketing spend XSales growth YȲ = 7%ABCDEF
The six companies' sales growth scattered around its mean of 7%. The squared vertical gaps to that line add up to SST = 56: the variation regression tries to explain. The pattern already hints that more marketing goes with faster growth.

Always ask “what is being explained by what?” The dependent variable is the thing in the question you want to predict or understand. If an analyst asks whether earnings revisions help explain share returns, returns are Y and revisions are X.

The model: intercept, slope and error

The population relationship is Yi=b0+b1Xi+εiY_i = b_0 + b_1X_i + \varepsilon_i. The intercept b0b_0 and slope b1b_1 are the regression coefficients. Not every point sits on the line; the error term εi\varepsilon_i captures how far each true Y lies from the true population line.

We never see the population values b0b_0 and b1b_1. We estimate them from a sample, and the estimates wear hats: b^0\hat b_0 and b^1\hat b_1. The fitted value for observation i is Y^i=b^0+b^1Xi\hat Y_i = \hat b_0 + \hat b_1X_i.

The residual is the sample counterpart of the error: ei=Yi−Y^ie_i = Y_i - \hat Y_i, the vertical distance from a point to the fitted line. The error term belongs to the population relationship; the residual belongs to the line fitted on your sample. A residual is measured in the units of Y (euros, percent, days and so on).

The least squares criterion

Many lines could be drawn through a cloud of points. OLS chooses the one that minimises the sum of squares error: SSE=∑(Yi−Y^i)2=∑ei2SSE = \sum (Y_i - \hat Y_i)^2 = \sum e_i^2. This is the least squares criterion, which is why the method is called ordinary least squares.

Why square the residuals? Positive and negative misses would otherwise cancel out, and squaring punishes large misses much more than small ones. In fact, for any OLS line with an intercept the plain residuals always add up to exactly zero, so their sum cannot measure fit.

Two useful by-products follow from the maths. The fitted line always passes through the point of means (Xˉ,Yˉ)(\bar X, \bar Y), and the average fitted value equals the average actual value Yˉ\bar Y. The expected value of the residual is zero.

  • OLS minimises squared vertical distances (in Y units), not horizontal or perpendicular distances.
  • Regressing Y on X gives a different line from regressing X on Y, so the roles matter.
0%2.5%5%7.5%10%0%2%4%6%8%Marketing spend XSales growth YABCDEF(X̄, Ȳ) = (5, 7)
The OLS line makes the sum of squared vertical misses as small as possible: SSE = 7.6, and no other straight line does better. It passes through the point of means (5, 7), and the misses above and below it cancel to zero.

Computing the slope and the intercept

The slope is the covariance of X and Y divided by the variance of X. Because both have n−1n-1 in the denominator, it simplifies to the sum of cross-products of deviations divided by the sum of squared X deviations.

Once you have the slope, the intercept comes from the means: b^0=Yˉ−b^1Xˉ\hat b_0 = \bar Y - \hat b_1\bar X. This is just the statement that the line goes through the point of means.

Compare the slope with the correlation, r=Cov(X,Y)/(sXsY)r = \text{Cov}(X,Y)/(s_X s_Y). They share the numerator; only the denominator differs. Since standard deviations and variances are positive, a positive covariance gives a positive slope and a positive correlation, and a negative covariance makes both negative. Combining the two formulas gives a handy shortcut: b^1=r×sY/sX\hat b_1 = r \times s_Y / s_X.

Slope versus correlation
Slope b^1\hat b_1Correlation r
NumeratorCov(X, Y)Cov(X, Y)
DenominatorVar(X)sX×sYs_X \times s_Y
UnitsUnits of Y per unit of XNone, between −1 and +1
SignSign of the covarianceSign of the covariance

Formulas

Simple linear regression model
Yi=b0+b1Xi+εi,i=1,…,nY_i = b_0 + b_1X_i + \varepsilon_i, \quad i = 1, \ldots, n

Population relationship. b0b_0 = intercept, b1b_1 = slope, εi\varepsilon_i = error term.

Sum of squares error (minimised by OLS)
SSE=∑i=1n(Yi−Y^i)2=∑i=1nei2SSE = \sum_{i=1}^{n} (Y_i - \hat Y_i)^2 = \sum_{i=1}^{n} e_i^2

ei=Yi−Y^ie_i = Y_i - \hat Y_i is the residual: actual minus fitted.

Slope
b^1=Cov(X,Y)Var(X)=∑(Yi−Yˉ)(Xi−Xˉ)∑(Xi−Xˉ)2\hat b_1 = \dfrac{\text{Cov}(X,Y)}{\text{Var}(X)} = \dfrac{\sum (Y_i-\bar Y)(X_i-\bar X)}{\sum (X_i-\bar X)^2}

Use the sums form with raw data, the covariance/variance form with summary statistics.

Intercept
b^0=Yˉ−b^1Xˉ\hat b_0 = \bar Y - \hat b_1\bar X
Correlation and the slope shortcut
r=Cov(X,Y)sXsY,b^1=r sYsXr = \dfrac{\text{Cov}(X,Y)}{s_X s_Y}, \qquad \hat b_1 = r\,\dfrac{s_Y}{s_X}

Worked examples

Example 1 Fitting the line from raw data

Six companies report marketing spend (X, % of sales) of 1, 3, 4, 6, 8, 8 and sales growth (Y, %) of 2, 4, 7, 10, 9, 10. What are the OLS slope and intercept?

Example 2 Slope from summary statistics

For a sample of fund returns, Cov(X, Y) = 6.3, Var(X) = 4.5, Xˉ\bar X = 3 and Yˉ\bar Y = 9. A second analyst only has r = 0.75, sYs_Y = 8% and sXs_X = 4% for another pair of series. What slope and intercept does the first analyst get, and what slope does the second get?

Example 3 Which variable is which?

A strategist wants to know whether a country's money supply growth helps explain its inflation rate. She collects 25 years of annual data. Identify Y and X, and state what the slope would mean.

On the exam

Expect a slope or intercept from summary statistics, a question on what OLS minimises, and identification of the dependent variable from a short vignette.

  • Using b^0=Yˉ+b^1Xˉ\hat b_0 = \bar Y + \hat b_1\bar X: the intercept subtracts slope × mean of X.
  • Dividing the covariance by the variance of Y instead of the variance of X.
  • Thinking OLS minimises the sum of residuals: that sum is always zero.
  • Mixing up the error term (population) and the residual (sample).

Check yourself

  1. Q1The sum of cross-products of deviations is −36, the sum of squared X deviations is 48, Xˉ\bar X = 10 and Yˉ\bar Y = 6. The estimated intercept is closest to:

  2. Q2Ordinary least squares chooses the intercept and slope that minimise the:

  3. Q3The correlation between X and Y is −0.60. The standard deviations of Y and X are 10% and 4%. The OLS slope of Y on X is closest to:

  4. Q4An analyst asks whether credit spreads help explain equity market volatility. The independent variable is:

  5. Q5Which statement about the error term and the residual is most accurate?

0/5Check yourself

Answer the 5 questions: +10 XP for each one you get right first time.

Liked this lesson? Get the rest free for 7 days

Create a free account to open the other 8 lessons in this module, with videos, flashcards that come back before you forget them, the question bank and full mocks. No card needed.