Skip to content
LeetQuant
QR04 Regression and Numerical Optimisation

QR04 · Regression and Numerical Optimisation · Lesson 1 of 6

Regression

OLS geometry, interpreting coefficients, and what R² does and doesn't tell you.

30 min

Simple regression

Fit y=α+βx+εy = \alpha + \beta x + \varepsilon by minimising the sum of squared residuals. The solution is

β^=Cov⁡(x,y)Var⁡(x)=ρxy σyσx,α^=yˉ−β^ xˉ.\hat\beta = \frac{\operatorname{Cov}(x, y)}{\operatorname{Var}(x)} = \rho_{xy}\,\frac{\sigma_y}{\sigma_x}, \qquad \hat\alpha = \bar y - \hat\beta\,\bar x .

The fitted line always passes through (xˉ,yˉ)(\bar x, \bar y). In finance, β^\hat\beta of a stock's returns on the market's returns is the stock's beta.

Because ∣ρ∣≤1|\rho| \le 1, the predicted yy is fewer standard deviations from its mean than xx is. This is regression to the mean, and it is why regressing yy on xx and xx on yy give two different lines.

Multiple regression and its geometry

With a design matrix XX (one column per regressor, including a column of ones),

β^=(X⊤X)−1X⊤y.\hat\beta = (X^\top X)^{-1} X^\top y .

Geometrically, Xβ^X\hat\beta is the orthogonal projection of yy onto the space spanned by the columns of XX. The residuals are orthogonal to every column: X⊤(y−Xβ^)=0X^\top(y - X\hat\beta) = 0. With an intercept, they therefore sum to zero.

Each coefficient is a partial effect: the change in yy for a one-unit change in that regressor holding the others fixed. Equivalently (Frisch–Waugh–Lovell), β^1\hat\beta_1 is the slope from regressing yy on the part of x1x_1 that the other regressors cannot explain.

R² and what it hides

R2=1−∑(yi−y^i)2∑(yi−yˉ)2.R^2 = 1 - \frac{\sum (y_i - \hat y_i)^2}{\sum (y_i - \bar y)^2} .

In simple regression R2=ρ2R^2 = \rho^2. Some cautions:

  • Adding a regressor never lowers in-sample R2R^2, even if it is pure noise. Use adjusted R2R^2 or out-of-sample tests.
  • A low R2R^2 is normal in finance. Predicting daily returns with R2=0.01R^2 = 0.01 would be extremely valuable.
  • A high R2R^2 between two trending series is often spurious: regress one random walk on another and you will usually find a "significant" relationship.

Worked example

a stock's beta

A stock's daily returns have a standard deviation of 2%, the market's 1%, and their correlation is 0.3. What are the stock's beta and the regression R2R^2? How much of the stock's variance is idiosyncratic?

Show solution

β=0.3×2%/1%=0.6\beta = 0.3 \times 2\% / 1\% = 0.6, and R2=0.32=0.09R^2 = 0.3^2 = 0.09.

The market explains β2σm2=0.36×(1%)2=0.36\beta^2\sigma_m^2 = 0.36 \times (1\%)^2 = 0.36 (in units of %2\%^2) of the stock's total variance of 44, which is 9%9\%. The other 91%91\% is idiosyncratic.

Omitted variables and correlated regressors

If the truth is y=β1x1+β2x2+εy = \beta_1 x_1 + \beta_2 x_2 + \varepsilon but you leave out x2x_2, your estimate of β1\beta_1 converges to

β1+β2 Cov⁡(x1,x2)Var⁡(x1).\beta_1 + \beta_2\,\frac{\operatorname{Cov}(x_1, x_2)}{\operatorname{Var}(x_1)} .

The coefficient picks up the effect of whatever correlated variable is missing. Conversely, including two highly correlated regressors leaves the fit fine but makes each coefficient's standard error large, because the data cannot tell the two apart.

Worked example

omitted-variable bias

Returns follow y=1.0 x1+0.5 x2+εy = 1.0\,x_1 + 0.5\,x_2 + \varepsilon, where Cov⁡(x1,x2)/Var⁡(x1)=0.4\operatorname{Cov}(x_1, x_2) / \operatorname{Var}(x_1) = 0.4. You regress yy on x1x_1 alone. What slope do you expect?

Show solution

1.0+0.5×0.4=1.21.0 + 0.5 \times 0.4 = 1.2. You would overstate the effect of x1x_1 by 20% because it partly stands in for x2x_2.

Knowledge check

A simple regression of y on x has R² = 0.25. What is the absolute correlation between x and y?

Knowledge check

You rescale a regressor from decimals to percentages (multiply it by 100). What happens to its slope and t-statistic?

Knowledge check

You add a regressor of pure random noise to a regression. What happens to the in-sample R²?

Practice problems

Finished reading?

Answer the 3 knowledge checks to complete this lesson (0 done).