Sub topic 12
The simple linear regression model
This chapter introduces the model that the rest of the regression material builds on. It assumes you know means, variances, standard deviations and correlation, and that you can write the equation of a straight line. It also assumes you know what a hypothesis test is. The chapter defines the model and its parts, and it lists the assumptions behind the model. Estimation, R-squared and slope tests come in later chapters.
What the model says
Simple linear regression describes how one variable, Y, depends on one other variable, X. For observation i, the model is:
Yi = b0 + b1 × Xi + e_i
The equation has a part you can predict and a part you cannot. The line b0 + b1 × Xi is the predictable part. The error term ei is everything else that moves Y.
| Symbol | Name | Meaning |
|---|---|---|
| Y | Dependent variable (explained variable, predicted variable) | The variable you want to explain or forecast |
| X | Independent variable (explanatory variable, predictor) | The variable used to explain Y |
| b0 | Intercept | The expected value of Y when X equals 0 |
| b1 | Slope coefficient | The expected change in Y for a one-unit change in X |
| e_i | Error term (disturbance) | The part of Y_i that the line does not explain |
Regression describes association, not causation. The labels "dependent" and "independent" say which variable you are explaining. They do not show that X causes Y.
Reading the intercept and the slope
Suppose you regress a stock's monthly return (Y, in %) on the market's monthly return (X, in %) and get b0 = 0.5 and b1 = 1.2.
- The slope says that a 1-percentage-point higher market return goes with a 1.2-percentage-point higher expected stock return. This slope is the stock's beta.
- The intercept says the expected stock return is 0.5% in a month when the market return is 0. In this setting it is the stock's average return that is unrelated to the market.
- If the market returns 5%, the predicted stock return is 0.5 + 1.2 × 5 = 6.5%.
The actual return will rarely equal 6.5%. The gap between actual and predicted is the error term.
The intercept can be meaningless. If X is a variable that never comes near 0 in your data, such as a company's market capitalization, the intercept is an extrapolation. It is needed to position the line, but you should not interpret it economically.
Population line and sample line
The equation above describes the population relationship, and its parameters b0 and b1 are unknown. You estimate them from a sample. The estimates are written with hats:
Y-hati = b0-hat + b1-hat × Xi
The difference between the observed Yi and the fitted value Y-hati is the residual. The residual is the sample counterpart of the error term. The error e_i is never observed, but the residual can be computed for each observation. Because b0-hat and b1-hat are calculated from a random sample, they are random variables. A different sample gives different estimates. This is why slope inference needs a standard error, which a later chapter covers.
Assumptions of the model
Inference about the line is only reliable when these assumptions hold:
- Linearity. The relationship between X and Y is linear in the parameters, so Y can be written as b0 + b1 × X plus an error.
- X is not random, or is uncorrelated with the error. The independent variable carries no information about the error term.
- Zero mean error. The expected value of the error is 0.
- Homoskedasticity. The variance of the error is the same for every observation.
- Independence. The errors are uncorrelated across observations. Violations of this are called serial correlation or autocorrelation.
- Normality. The errors are normally distributed. This matters mainly for small samples, because it is what makes the t and F tests valid.
Each assumption has a matching failure. Non-constant error variance is heteroskedasticity. Correlated errors are serial correlation. A later chapter treats these failures and their remedies.
Seeing the model in code
The program below simulates data from a known line, with intercept 0.5, slope 1.2 and an error standard deviation of 2. It then estimates the line from the sample. It also checks two properties of the sample residuals. They sum to zero, and they are uncorrelated with X.
import numpy as np
rng = np.random.default_rng(42)
n = 200
# Data generated from the population model Y = 0.5 + 1.2 * X + e
x = rng.normal(0.8, 4.0, n)
e = rng.normal(0.0, 2.0, n)
y = 0.5 + 1.2 * x + e
# Sample estimates: slope = cov(x, y) / var(x), intercept from the means
b1 = np.cov(x, y, ddof=1)[0, 1] / np.var(x, ddof=1)
b0 = y.mean() - b1 * x.mean()
y_hat = b0 + b1 * x
resid = y - y_hat
print("intercept estimate:", round(b0, 3))
print("slope estimate:", round(b1, 3))
print("residuals sum to zero:", abs(resid.sum()) < 1e-9)
print("residuals uncorrelated with x:", abs(np.corrcoef(x, resid)[0, 1]) < 1e-9)The estimates will be close to 0.5 and 1.2 but not equal to them. That difference is sampling error. The two checks print True because they hold by construction for any least squares fit that includes an intercept. They tell you nothing about whether the true errors satisfy the assumptions. To check the assumptions you inspect the residuals, for example by plotting them against X or against time.
Common errors
- Swapping X and Y. Regressing Y on X gives a different slope than regressing X on Y. Choose Y as the variable you want to explain or forecast.
- Reading the slope as causal. A slope of 1.2 means the variables move together. It does not mean a change in X produces that change in Y.
- Interpreting the intercept outside the data. Check whether X = 0 is a plausible value before you give the intercept a meaning.
- Forgetting the units. The slope is in units of Y per unit of X. If returns are in percent, a slope of 1.2 means 1.2 percentage points per percentage point.
- Confusing error and residual. The error belongs to the population model and is unobserved. The residual belongs to the fitted sample line and is computed.
Exercise
A regression of a fund's monthly return (Y, %) on its benchmark's monthly return (X, %) gives an intercept of -0.2 and a slope of 0.9. (a) What return does the model predict for the fund when the benchmark returns 4%? (b) The fund actually returned 3.1%. What is the residual?
Show answer
(a) The predicted return is -0.2 + 0.9 × 4 = 3.4%. (b) The residual is the observed value minus the fitted value: 3.1 - 3.4 = -0.3 percentage points. The fund did 0.3 points worse than the line predicted.
Exercise
An analyst finds that the residuals from a regression of monthly sales on advertising spend are small for low spending months and much larger for high spending months. Which assumption is most likely violated, and what is the name of the problem?
Show answer
Homoskedasticity, which requires the error variance to be the same for every observation. Error variance that changes with the level of X is called heteroskedasticity.