Lesson 1 of 9 · All lessons in this module
- The regression model and least squares
- Interpreting coefficients, fitted values and residuals
- The four assumptions and residual plotsVideo lesson
- Sums of squares, \(R^2\), the ANOVA table and the SEEVideo lesson
- Testing the slope: t-test, correlation test and F-testVideo lesson
- Intercept tests, indicator variables and p-values
- Forecasts and prediction intervals
- Functional forms: log-lin, lin-log and log-logVideo lesson
- 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: . is the intercept, the slope coefficient, the error term.
- Ordinary least squares (OLS) picks and to minimise the sum of squares error (SSE), the sum of squared residuals.
- Slope = covariance of X and Y ÷ variance of X. Intercept = , so the line runs through .
- 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): .
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.
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 . The intercept and slope are the regression coefficients. Not every point sits on the line; the error term captures how far each true Y lies from the true population line.
We never see the population values and . We estimate them from a sample, and the estimates wear hats: and . The fitted value for observation i is .
The residual is the sample counterpart of the error: , 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: . 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 , and the average fitted value equals the average actual value . 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.
Computing the slope and the intercept
The slope is the covariance of X and Y divided by the variance of X. Because both have 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: . This is just the statement that the line goes through the point of means.
Compare the slope with the correlation, . 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: .
| Slope | Correlation r | |
|---|---|---|
| Numerator | Cov(X, Y) | Cov(X, Y) |
| Denominator | Var(X) | |
| Units | Units of Y per unit of X | None, between −1 and +1 |
| Sign | Sign of the covariance | Sign of the covariance |
Formulas
- Simple linear regression model
Population relationship. = intercept, = slope, = error term.
- Sum of squares error (minimised by OLS)
is the residual: actual minus fitted.
- Slope
Use the sums form with raw data, the covariance/variance form with summary statistics.
- Intercept
- Correlation and the slope shortcut
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, = 3 and = 9. A second analyst only has r = 0.75, = 8% and = 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 : 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
Q1The sum of cross-products of deviations is −36, the sum of squared X deviations is 48, = 10 and = 6. The estimated intercept is closest to:
Q2Ordinary least squares chooses the intercept and slope that minimise the:
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:
Q4An analyst asks whether credit spreads help explain equity market volatility. The independent variable is:
Q5Which statement about the error term and the residual is most accurate?
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.